Data structures 如何编写结构?

Data structures 如何编写结构?,data-structures,abap,Data Structures,Abap,我怎样才能做到以下几点: data: ls_header type BAPIMEPOHEADER. " fill it write ls_header. 目前我收到一个错误,因为write无法将复杂类型解析为字符串。有没有一种简单的方法可以让这段代码在abap中运行?我知道两种方法,一种是过程式的,另一种是面向对象的。 以下是程序方法 从数据字典表DD03L中选择结构的字段(或您可能需要的任何其他字段)到本地内部表中 把桌子绕到工作区 检查当前字段是否为单一数据类型,如果是 将结构ls\U标头

我怎样才能做到以下几点:

data: ls_header type BAPIMEPOHEADER.
" fill it
write ls_header.

目前我收到一个错误,因为
write
无法将复杂类型解析为字符串。有没有一种简单的方法可以让这段代码在abap中运行?

我知道两种方法,一种是过程式的,另一种是面向对象的。 以下是程序方法

  • 从数据字典表DD03L中选择结构的字段(或您可能需要的任何其他字段)到本地内部表中
  • 把桌子绕到工作区
  • 检查当前字段是否为单一数据类型,如果是
  • 将结构ls\U标头的组件工作区字段名指定给anyfieldsymbol
  • 写入任意字段符号

  • 你需要代码吗?

    我知道两种方法,一种是程序化的,另一种是面向对象的。 以下是程序方法

  • 从数据字典表DD03L中选择结构的字段(或您可能需要的任何其他字段)到本地内部表中
  • 把桌子绕到工作区
  • 检查当前字段是否为单一数据类型,如果是
  • 将结构ls\U标头的组件工作区字段名指定给anyfieldsymbol
  • 写入任意字段符号

  • 你需要代码吗?

    我知道两种方法,一种是程序化的,另一种是面向对象的。 以下是程序方法

  • 从数据字典表DD03L中选择结构的字段(或您可能需要的任何其他字段)到本地内部表中
  • 把桌子绕到工作区
  • 检查当前字段是否为单一数据类型,如果是
  • 将结构ls\U标头的组件工作区字段名指定给anyfieldsymbol
  • 写入任意字段符号

  • 你需要代码吗?

    我知道两种方法,一种是程序化的,另一种是面向对象的。 以下是程序方法

  • 从数据字典表DD03L中选择结构的字段(或您可能需要的任何其他字段)到本地内部表中
  • 把桌子绕到工作区
  • 检查当前字段是否为单一数据类型,如果是
  • 将结构ls\U标头的组件工作区字段名指定给anyfieldsymbol
  • 写入任意字段符号

  • 您需要代码吗?

    您可以使用以下代码:

    DATA: g_struct TYPE bapimepoheader.
    
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE g_struct TO FIELD-SYMBOL(<f>).
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
      WRITE: / <f>.
    ENDDO.
    
    DATA:g_结构类型bapimepoheader。
    做
    将结构g_struct的组件sy索引分配给字段-SYMBOL()。
    如果sy subrc NE为0。
    出口
    恩迪夫。
    写:/。
    恩多。
    
    您可以使用以下内容:

    DATA: g_struct TYPE bapimepoheader.
    
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE g_struct TO FIELD-SYMBOL(<f>).
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
      WRITE: / <f>.
    ENDDO.
    
    DATA:g_结构类型bapimepoheader。
    做
    将结构g_struct的组件sy索引分配给字段-SYMBOL()。
    如果sy subrc NE为0。
    出口
    恩迪夫。
    写:/。
    恩多。
    
    您可以使用以下内容:

    DATA: g_struct TYPE bapimepoheader.
    
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE g_struct TO FIELD-SYMBOL(<f>).
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
      WRITE: / <f>.
    ENDDO.
    
    DATA:g_结构类型bapimepoheader。
    做
    将结构g_struct的组件sy索引分配给字段-SYMBOL()。
    如果sy subrc NE为0。
    出口
    恩迪夫。
    写:/。
    恩多。
    
    您可以使用以下内容:

    DATA: g_struct TYPE bapimepoheader.
    
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE g_struct TO FIELD-SYMBOL(<f>).
      IF sy-subrc NE 0.
        EXIT.
      ENDIF.
      WRITE: / <f>.
    ENDDO.
    
    DATA:g_结构类型bapimepoheader。
    做
    将结构g_struct的组件sy索引分配给字段-SYMBOL()。
    如果sy subrc NE为0。
    出口
    恩迪夫。
    写:/。
    恩多。
    
    您可以将结构写入字符串,然后输出该字符串。创建idoc段的方法相同。

    您可以将结构写入字符串,然后输出字符串。创建idoc段的方法相同。

    您可以将结构写入字符串,然后输出字符串。创建idoc段的方法相同。

    您可以将结构写入字符串,然后输出字符串。创建idoc段的方法相同。

    ClassCL\u ABAP\u容器实用程序是SAP专门为其引入的

    使用
    FILL\u CONTAINER\u C
    方法以
    WRITE
    方式输出结构:

    DATA: ls_header type BAPIMEPOHEADER.
    
    CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
     EXPORTING
      IM_VALUE                = ls_header
     IMPORTING
      EX_CONTAINER            = DATA(container)
     EXCEPTIONS
      ILLEGAL_PARAMETER_TYPE = 1
      others                 = 2.
    
    WRITE container.
    

    ClassCL\u ABAP\u CONTAINER\u实用程序是SAP专门为其引入的

    使用
    FILL\u CONTAINER\u C
    方法以
    WRITE
    方式输出结构:

    DATA: ls_header type BAPIMEPOHEADER.
    
    CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
     EXPORTING
      IM_VALUE                = ls_header
     IMPORTING
      EX_CONTAINER            = DATA(container)
     EXCEPTIONS
      ILLEGAL_PARAMETER_TYPE = 1
      others                 = 2.
    
    WRITE container.
    

    ClassCL\u ABAP\u CONTAINER\u实用程序是SAP专门为其引入的

    使用
    FILL\u CONTAINER\u C
    方法以
    WRITE
    方式输出结构:

    DATA: ls_header type BAPIMEPOHEADER.
    
    CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
     EXPORTING
      IM_VALUE                = ls_header
     IMPORTING
      EX_CONTAINER            = DATA(container)
     EXCEPTIONS
      ILLEGAL_PARAMETER_TYPE = 1
      others                 = 2.
    
    WRITE container.
    

    ClassCL\u ABAP\u CONTAINER\u实用程序是SAP专门为其引入的

    使用
    FILL\u CONTAINER\u C
    方法以
    WRITE
    方式输出结构:

    DATA: ls_header type BAPIMEPOHEADER.
    
    CALL METHOD CL_ABAP_CONTAINER_UTILITIES=>FILL_CONTAINER_C
     EXPORTING
      IM_VALUE                = ls_header
     IMPORTING
      EX_CONTAINER            = DATA(container)
     EXCEPTIONS
      ILLEGAL_PARAMETER_TYPE = 1
      others                 = 2.
    
    WRITE container.
    

    也许不是你期望的答案:如果你列出每个字段

    这可以通过SE38中的模式掩码轻松完成:

  • 选择写入模式:
  • 输入所需的结构:
  • 选择字段 用“副本”确认
  • 确认后,您将获得

    WRITE: bapimepoheader-po_number,
           bapimepoheader-comp_code,
           bapimepoheader-doc_type,
           bapimepoheader-delete_ind,
           bapimepoheader-status,
           bapimepoheader-creat_date,
           bapimepoheader-created_by,
           bapimepoheader-item_intvl,
           bapimepoheader-vendor,
           bapimepoheader-langu,
           bapimepoheader-langu_iso,
           bapimepoheader-pmnttrms,
           bapimepoheader-dscnt1_to,
           bapimepoheader-dscnt2_to,
           bapimepoheader-dscnt3_to,
           bapimepoheader-dsct_pct1,
           bapimepoheader-dsct_pct2,
           bapimepoheader-purch_org,
           bapimepoheader-pur_group,
           bapimepoheader-currency,
           bapimepoheader-currency_iso,
           bapimepoheader-exch_rate,
           bapimepoheader-ex_rate_fx,
           bapimepoheader-doc_date,
           bapimepoheader-vper_start,
           bapimepoheader-vper_end,
           bapimepoheader-warranty,
           bapimepoheader-quotation,
           bapimepoheader-quot_date,
           bapimepoheader-ref_1,
           bapimepoheader-sales_pers,
           bapimepoheader-telephone,
           bapimepoheader-suppl_vend,
           bapimepoheader-customer,
           bapimepoheader-agreement,
           bapimepoheader-gr_message,
           bapimepoheader-suppl_plnt,
           bapimepoheader-incoterms1,
           bapimepoheader-incoterms2,
           bapimepoheader-collect_no,
           bapimepoheader-diff_inv,
           bapimepoheader-our_ref,
           bapimepoheader-logsystem,
           bapimepoheader-subitemint,
           bapimepoheader-po_rel_ind,
           bapimepoheader-rel_status,
           bapimepoheader-vat_cntry,
           bapimepoheader-vat_cntry_iso,
           bapimepoheader-reason_cancel,
           bapimepoheader-reason_code,
           bapimepoheader-retention_type,
           bapimepoheader-retention_percentage,
           bapimepoheader-downpay_type,
           bapimepoheader-downpay_amount,
           bapimepoheader-downpay_percent,
           bapimepoheader-downpay_duedate,
           bapimepoheader-memory,
           bapimepoheader-memorytype,
           bapimepoheader-shiptype,
           bapimepoheader-handoverloc,
           bapimepoheader-shipcond,
           bapimepoheader-incotermsv,
           bapimepoheader-incoterms2l,
           bapimepoheader-incoterms3l.
    
    现在,您可以用
    ls_header
    简单地替换
    bapimepoheader
    ,并获得结构的所有字段的输出


    也许这并不优雅,如果结构发生变化,你必须调整你的报告。但我喜欢这种方式,因为我通常不需要所有字段,我可以用一种简单的方式选择字段。

    也许不是你期望的答案:如果你列出每个字段

    这可以通过SE38中的模式掩码轻松完成:

  • 选择写入模式:
  • 输入所需的结构:
  • 选择字段 用“副本”确认
  • 确认后,您将获得

    WRITE: bapimepoheader-po_number,
           bapimepoheader-comp_code,
           bapimepoheader-doc_type,
           bapimepoheader-delete_ind,
           bapimepoheader-status,
           bapimepoheader-creat_date,
           bapimepoheader-created_by,
           bapimepoheader-item_intvl,
           bapimepoheader-vendor,
           bapimepoheader-langu,
           bapimepoheader-langu_iso,
           bapimepoheader-pmnttrms,
           bapimepoheader-dscnt1_to,
           bapimepoheader-dscnt2_to,
           bapimepoheader-dscnt3_to,
           bapimepoheader-dsct_pct1,
           bapimepoheader-dsct_pct2,
           bapimepoheader-purch_org,
           bapimepoheader-pur_group,
           bapimepoheader-currency,
           bapimepoheader-currency_iso,
           bapimepoheader-exch_rate,
           bapimepoheader-ex_rate_fx,
           bapimepoheader-doc_date,
           bapimepoheader-vper_start,
           bapimepoheader-vper_end,
           bapimepoheader-warranty,
           bapimepoheader-quotation,
           bapimepoheader-quot_date,
           bapimepoheader-ref_1,
           bapimepoheader-sales_pers,
           bapimepoheader-telephone,
           bapimepoheader-suppl_vend,
           bapimepoheader-customer,
           bapimepoheader-agreement,
           bapimepoheader-gr_message,
           bapimepoheader-suppl_plnt,
           bapimepoheader-incoterms1,
           bapimepoheader-incoterms2,
           bapimepoheader-collect_no,
           bapimepoheader-diff_inv,
           bapimepoheader-our_ref,
           bapimepoheader-logsystem,
           bapimepoheader-subitemint,
           bapimepoheader-po_rel_ind,
           bapimepoheader-rel_status,
           bapimepoheader-vat_cntry,
           bapimepoheader-vat_cntry_iso,
           bapimepoheader-reason_cancel,
           bapimepoheader-reason_code,
           bapimepoheader-retention_type,
           bapimepoheader-retention_percentage,
           bapimepoheader-downpay_type,
           bapimepoheader-downpay_amount,
           bapimepoheader-downpay_percent,
           bapimepoheader-downpay_duedate,
           bapimepoheader-memory,
           bapimepoheader-memorytype,
           bapimepoheader-shiptype,
           bapimepoheader-handoverloc,
           bapimepoheader-shipcond,
           bapimepoheader-incotermsv,
           bapimepoheader-incoterms2l,
           bapimepoheader-incoterms3l.
    
    现在,您可以用
    ls_header
    简单地替换
    bapimepoheader
    ,并获得结构的所有字段的输出


    也许这并不优雅,如果结构发生变化,你必须调整你的报告。但我喜欢这种方式,因为我通常不需要所有字段,我可以用一种简单的方式选择字段。

    也许不是你期望的答案:如果你列出每个字段

    这可以通过SE38中的模式掩码轻松完成:

  • 选择写入模式:
  • 输入所需的结构:
  • 选择字段 用“副本”确认
  • 确认后,您将获得

    WRITE: bapimepoheader-po_number,
           bapimepoheader-comp_code,
           bapimepoheader-doc_type,
           bapimepoheader-delete_ind,
           bapimepoheader-status,
           bapimepoheader-creat_date,
           bapimepoheader-created_by,
           bapimepoheader-item_intvl,
           bapimepoheader-vendor,
           bapimepoheader-langu,
           bapimepoheader-langu_iso,
           bapimepoheader-pmnttrms,
           bapimepoheader-dscnt1_to,
           bapimepoheader-dscnt2_to,
           bapimepoheader-dscnt3_to,
           bapimepoheader-dsct_pct1,
           bapimepoheader-dsct_pct2,
           bapimepoheader-purch_org,
           bapimepoheader-pur_group,
           bapimepoheader-currency,
           bapimepoheader-currency_iso,
           bapimepoheader-exch_rate,
           bapimepoheader-ex_rate_fx,
           bapimepoheader-doc_date,
           bapimepoheader-vper_start,
           bapimepoheader-vper_end,
           bapimepoheader-warranty,
           bapimepoheader-quotation,
           bapimepoheader-quot_date,
           bapimepoheader-ref_1,
           bapimepoheader-sales_pers,
           bapimepoheader-telephone,
           bapimepoheader-suppl_vend,
           bapimepoheader-customer,
           bapimepoheader-agreement,
           bapimepoheader-gr_message,
           bapimepoheader-suppl_plnt,
           bapimepoheader-incoterms1,
           bapimepoheader-incoterms2,
           bapimepoheader-collect_no,
           bapimepoheader-diff_inv,
           bapimepoheader-our_ref,
           bapimepoheader-logsystem,
           bapimepoheader-subitemint,
           bapimepoheader-po_rel_ind,
           bapimepoheader-rel_status,
           bapimepoheader-vat_cntry,
           bapimepoheader-vat_cntry_iso,
           bapimepoheader-reason_cancel,
           bapimepoheader-reason_code,
           bapimepoheader-retention_type,
           bapimepoheader-retention_percentage,
           bapimepoheader-downpay_type,
           bapimepoheader-downpay_amount,
           bapimepoheader-downpay_percent,
           bapimepoheader-downpay_duedate,
           bapimepoheader-memory,
           bapimepoheader-memorytype,
           bapimepoheader-shiptype,
           bapimepoheader-handoverloc,
           bapimepoheader-shipcond,
           bapimepoheader-incotermsv,
           bapimepoheader-incoterms2l,
           bapimepoheader-incoterms3l.
    
    现在你可以做一个sim卡了