Chinaunix首页 | 论坛 | 博客
  • 博客访问: 203385
  • 博文数量: 54
  • 博客积分: 2056
  • 博客等级: 大尉
  • 技术积分: 568
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 12:07
文章分类

全部博文(54)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(2)

2010年(1)

2009年(11)

2008年(28)

2007年(9)

我的朋友

分类: 嵌入式

2009-07-30 14:59:14

关于ST(Simple Transformation)的OnlineHelp,请查看:

1、创建Transformation,事务码:STRANS,Transformation Type选择为Simple Transformation,例如Z1766TEST01,内容如下:


 
 
 

 
   
     
       
         
           
         

         
           
         

       

       
         
           
             
               
             

             
               
             

           

         

       

       
         
           
             
               
             

             
               
             

             
               
             

             
               
             

           

         

       

     
   
 

2、创建调用程序Z1766_ST_XML,注意Internal Table不能带Header Line,内容如下:

*&---------------------------------------------------------------------*
*& Report  Z1766_ST_XML
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z1766_st_xml.

DATA: BEGIN OF s_head,
        order_id LIKE z1crm_sales_head-order_id,
        status_h  LIKE z1crm_sales_head-status_h,
        creat_date_h LIKE z1crm_sales_head-creat_date_h,
        creat_time_h LIKE z1crm_sales_head-creat_time_h,
        sold_to LIKE z1crm_sales_head-sold_to,
        ship_to LIKE z1crm_sales_head-ship_to,
        cont_total LIKE z1crm_sales_head-cont_total,
        zzroute LIKE z1crm_sales_head-zzroute,
        ship_cond LIKE z1crm_sales_head-ship_cond,
        pmnttrms LIKE z1crm_sales_head-pmnttrms,
       END OF s_head,
      itab_head   LIKE STANDARD TABLE OF s_head.

DATA: BEGIN OF s_item,
        itemcode LIKE z1crm_sales_item-number_int,
        pn_group  LIKE z1crm_sales_item-pn_group,
        matnr LIKE z1crm_sales_item-matnr,
        charg  LIKE z1crm_sales_item-charg,
        status_i LIKE z1crm_sales_item-status_i,
       END OF s_item,
      itab_item   LIKE STANDARD TABLE OF s_item.

DATA: BEGIN OF adminfo,
        object  TYPE string,
        version TYPE string,
       END OF adminfo,
       p_info  LIKE STANDARD TABLE OF adminfo.

DATA:  BEGIN OF it_xml OCCURS 0,
         line(100) TYPE c,
       END OF it_xml.
DATA: w_xml TYPE string,
      w_len TYPE i.
PARAMETERS:order_id LIKE z1crm_sales_head-order_id DEFAULT '8895100207'.

START-OF-SELECTION.
  PERFORM getdata.
  PERFORM create_xml.

END-OF-SELECTION.


*&---------------------------------------------------------------------*
*&      Form  getdata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM getdata .
  REFRESH:itab_head,itab_item.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE itab_head
  FROM z1crm_sales_head
  WHERE order_id = order_id.
  READ TABLE itab_head INTO s_head INDEX 1.

  SELECT number_int AS itemcode pn_group matnr charg status_i
  INTO CORRESPONDING FIELDS OF TABLE itab_item
  FROM z1crm_sales_item
  WHERE order_id = order_id.

  adminfo-object  = '17'.
  adminfo-version = '2'.

ENDFORM.                    " getdata
*&---------------------------------------------------------------------*
*&      Form  create_xml
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_xml .
  CALL TRANSFORMATION z1766test01
  SOURCE p_info = adminfo
         header = itab_head
         item = itab_item
  RESULT XML  w_xml.

  CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
    EXPORTING
      text      = w_xml
    IMPORTING
      length    = w_len
    TABLES
      ftext_tab = it_xml.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename   = 'c:\temp\xmlforghw.xml'
      filetype   = 'BIN'
    IMPORTING
      filelength = w_len
    TABLES
      data_tab   = it_xml.
ENDFORM.                    " create_xml

3、输入结果如下:

   
  xml version="1.0" encoding="GBK" ?>
- <BOM>
- <BO>
+ <AdmInfo>
  <Object>17Object>
  <Version>2Version>
  AdmInfo>
- <Documents>
+ <row>
  <NumAtCard>8895100207NumAtCard>
  <U_NumAtCardDate>2009-07-09U_NumAtCardDate>
  row>
  Documents>
- <Document_Lines>
- <row>
  <ItemCode>0000000010ItemCode>
  <FreeTxt>GZ0300FreeTxt>
  <Matnr>43250003Matnr>
  <Charg>0000000003Charg>
  row>
- <row>
  <ItemCode>0000000020ItemCode>
  <FreeTxt>GZ0300FreeTxt>
  <Matnr>43250003Matnr>
  <Charg>0000000003Charg>
  row>
- <row>
  <ItemCode>0000000030ItemCode>
  <FreeTxt>GZ0300FreeTxt>
  <Matnr>43255002Matnr>
  <Charg>0000000093Charg>
  row>
- <row>
  <ItemCode>0000000040ItemCode>
  <FreeTxt>GZ0300FreeTxt>
  <Matnr>43255002Matnr>
  <Charg>0000000093Charg>
  row>
Document_Lines>
  BO>
  BOM>
 
文件: xmlforghw.rar
大小: 0KB
下载: 下载
阅读(1453) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

couragelove2009-07-31 17:09:45

111