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

Assign values to bapi structure dynamically

PS_1978
Active Participant
0 Likes
1,348

Hi,

I have to use the BAPI, BAPI_MATERIAL_SAVEDATA to extend the material to different plant specific views. I have to use the structure BAPI_MARC and other structures in order to do this. But the values to be passed to the structure BAPI_MARC are not fixed. These values will be maintained in a custom table against the structure name and field name for a particular plant.

In the program I have to extract the structure name and field name for a corresponding plant from custom table and fill the corresponding value in BAPI structure BAPI_MARC.

Now, internal table in the program is having these details.

How can I fill the bapi structure BAPI_MARC based on this information.

For example, if in custom table, value 0001 is maintained against the field PUR_GROUP, I have to fill the field PUR_GROUP in strcutre BAPI_MARC with 0001.

Hope I am clear in explaining the problem. Please let me know how to aciheve this?

Best Regards,

Kumar.

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
1,099

extract the custom table entries to a internal table .

(i assume that the internal table has two fields, NAME and VALUE and name holds PUR_GROUP and value holds 0001)

field-symbols: <fs> type BAPI_MARC ,

<field> type any .

loop at customitab into itab_wa.

assign component itab_wa-name of structure <fs> to <field> .

if <field> is assigned .

<field> = itab_wa-value .

endif .

endloop .

6 REPLIES 6
Read only

athavanraja
Active Contributor
0 Likes
1,100

extract the custom table entries to a internal table .

(i assume that the internal table has two fields, NAME and VALUE and name holds PUR_GROUP and value holds 0001)

field-symbols: <fs> type BAPI_MARC ,

<field> type any .

loop at customitab into itab_wa.

assign component itab_wa-name of structure <fs> to <field> .

if <field> is assigned .

<field> = itab_wa-value .

endif .

endloop .

Read only

PS_1978
Active Participant
0 Likes
1,099

Hi,

Thanks for your reply. But assign is not succesful. Could you help me in solving this please?

Best Regards,

Kumar.

Read only

0 Likes
1,099

do you mean if <field> assigned is failing?

what is the value of itab_wa-name in the following stt.

assign component itab_wa-name of structure <fs> to <field> .

Read only

PS_1978
Active Participant
0 Likes
1,099

Hi,

I have tried to implement that in a sample program first. Please have a look at the code below.

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

col3 TYPE i,

END OF line.

DATA comp(4) TYPE c VALUE 'COL3'.

FIELD-SYMBOLS: <f1> TYPE ANY, <f3> TYPE ANY.

ASSIGN line TO <f1>.

ASSIGN COMPONENT comp OF STRUCTURE <f1> TO <f3>.

IF <f3> IS ASSIGNED.

ENDIF.

I checked in the debugging mode and the value of <f3> in debugging mode is 0, but not line-col3.

Best Regards,

Kumar

Read only

0 Likes
1,099

when <f3> is assinged, you are not assigning the field name to the field-symbol.

Read only

PS_1978
Active Participant
0 Likes
1,099

Hi,

I am not much familiar with field symbols. If you dont mind, could you please help me in getting the value line-col3 in field symbol <f3>? So, that if I assign some value to <f3>, it should get reflected in line-col3 field.

Thank you very much for your help.

Best Regards,

Kumar.