Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8372

Re: How to fill dynamic fields of a Structure with a Condition?

$
0
0

Use DDIF_NAMETAB_GET to get a list of fields, then loop on the returned table and assign each field to a field-symbol if both successful, set or clear the field in the X structure. Also insure the X-field is actually a BAPIUPDATE field, some X structures begin with some key values.

 

Sample:

CALLFUNCTION'DDIF_NAMETAB_GET'

  EXPORTING

    tabname  = 'BAPIMEPOHEADERX'

  TABLES

    dfies_tab = dfies_tab

  EXCEPTIONS

    not_found = 1

    OTHERS   = 2.

IF sy-subrc <>0.

  MESSAGEID sy-msgid TYPE sy-msgty NUMBER sy-msgno

          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

 

LOOPAT dfies_tab ASSIGNING<dfies>WHERE rollname = 'BAPIUPDATE'.

  ASSIGN COMPONENT <dfies>-fieldname OFSTRUCTURE wa_poheaderx TO<headerfieldx>.

  CHECK<headerfieldx>ISASSIGNED." not actually required?

  ASSIGN COMPONENT <dfies>-fieldname OFSTRUCTURE wa_poheader TO<headerfield>.

  CHECK<headerfield>ISASSIGNED.

  IF<headerfield>ISINITIAL.

    CLEAR<headerfieldx>.

  ELSE.

    <headerfieldx> = abap_true.

  ENDIF.

ENDLOOP.

Hint: You could also replace the DDIF module with some RTTS class like cl_abap_structdescr.

 

Regards,

Raymond


Viewing all articles
Browse latest Browse all 8372

Trending Articles