Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Populating BAPI change structures

Former Member
0 Likes
1,295

Hi Gurus,

In BAPI import paramters we have change structures. E.g. in BAPI_FIXEDASSET_CREATE we have import parameter GENERALDATAX as change structure for the import parameter GENERALDATA.

Is there a functional module or something which can automatically populate the change structure? e.g. a function module to populate GENERALDATAX based on data in GENERALDATA.

Please let me know. Thanks in advance.

1 ACCEPTED SOLUTION
Read only

arseni_gallardo
Active Participant
0 Likes
953

Hi,

Create this subroutine in your program:


*&---------------------------------------------------------------------*
*&      Form  set_x_flags
*&---------------------------------------------------------------------*
FORM set_x_flags    USING is_data  TYPE any
                 CHANGING cs_datax TYPE any.

  FIELD-SYMBOLS: <l_field>  TYPE ANY,
                 <l_fieldx> TYPE ANY.

  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE is_data TO <l_field>.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    ASSIGN COMPONENT sy-index OF STRUCTURE cs_datax TO <l_fieldx>.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    IF <l_field> IS NOT INITIAL.
      <l_fieldx> = 'X'.
    ENDIF.
  ENDDO.
ENDFORM.                    "set_x_flags

And you can use it this way:


  DATA: ls_generaldata  TYPE bapi1022_feglg001,
        ls_generaldatax TYPE bapi1022_feglg001x,
        ls_inventory    TYPE bapi1022_feglg011,
        ls_inventoryx   TYPE bapi1022_feglg011x.

* Populate LS_GENERAL_DATA and LS_INvENTORY manually

*... then populate flags
  PERFORM set_x_flags: USING ls_generaldata  CHANGING ls_generaldatax,
                       USING ls_inventory    CHANGING ls_inventoryx.

2 REPLIES 2
Read only

arseni_gallardo
Active Participant
0 Likes
954

Hi,

Create this subroutine in your program:


*&---------------------------------------------------------------------*
*&      Form  set_x_flags
*&---------------------------------------------------------------------*
FORM set_x_flags    USING is_data  TYPE any
                 CHANGING cs_datax TYPE any.

  FIELD-SYMBOLS: <l_field>  TYPE ANY,
                 <l_fieldx> TYPE ANY.

  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE is_data TO <l_field>.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    ASSIGN COMPONENT sy-index OF STRUCTURE cs_datax TO <l_fieldx>.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    IF <l_field> IS NOT INITIAL.
      <l_fieldx> = 'X'.
    ENDIF.
  ENDDO.
ENDFORM.                    "set_x_flags

And you can use it this way:


  DATA: ls_generaldata  TYPE bapi1022_feglg001,
        ls_generaldatax TYPE bapi1022_feglg001x,
        ls_inventory    TYPE bapi1022_feglg011,
        ls_inventoryx   TYPE bapi1022_feglg011x.

* Populate LS_GENERAL_DATA and LS_INvENTORY manually

*... then populate flags
  PERFORM set_x_flags: USING ls_generaldata  CHANGING ls_generaldatax,
                       USING ls_inventory    CHANGING ls_inventoryx.

Read only

Former Member
0 Likes
953

The answer, as far as I know is: No, there's nothing that can automatically populate the "X"s in your badi X structure.

You'll have to use custom code as suggested above.

BR