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

How to create BAPI structure dynamically

former_member602416
Participant
0 Likes
2,197

Hi Experts,

I have a requirement to call sales order create/change BAPIs from my report program . These BAPIS do not exist in development environment but available at RFC destination. I need to write logic to call them from development environment and test it from development itself.

Can you please advice how can i define structures and table to pass the data to BAPI function as BAPI structures are not available in development.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,571

You could use in your program a variable for the FM name, and could create dynamic internal structure and table from ddic structure reference get from a RFC enabled FM such as DDIF_FIELDINFO_GET using class such as cl_abap_structdescr or cl_abap_tabledescr, so what is your exact problem?

bapi_name = 'BAPI_SALESDOCU_CREATEFROMDATA1'.
CALL FUNCTION bapi_name DESTINATION target
  EXPORTING
    sales_header_in = <header>
    sales_header_inx = <headerx>
  IMPORTING
    salesdocument_ex = <v_vbeln>
  TABLES
    return = return
    sales_items_in = <item>.
    " ...
3 REPLIES 3
Read only

UweFetzer_se38
Active Contributor
1,571

What do you expect from us? You can define structures/internal tables either in your program or in DDIC. But I think this is not the answer you want to hear, do you?

Read only

former_member602416
Participant
0 Likes
1,571

Thanks for replying back on my post. I should have been more specific.

I have a requirement to call multiple BAPI's which are not available in development environment, not even their structures, for example in below example i need to define header, headerx, v_vbeln......etc in data declaration but structure bapisdhead1, bapisdhead1x.. etc are not available in development system. I do not want to create all structures in DDIC as these are many .I am looking if i can create structure type dynamically.

DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,572

You could use in your program a variable for the FM name, and could create dynamic internal structure and table from ddic structure reference get from a RFC enabled FM such as DDIF_FIELDINFO_GET using class such as cl_abap_structdescr or cl_abap_tabledescr, so what is your exact problem?

bapi_name = 'BAPI_SALESDOCU_CREATEFROMDATA1'.
CALL FUNCTION bapi_name DESTINATION target
  EXPORTING
    sales_header_in = <header>
    sales_header_inx = <headerx>
  IMPORTING
    salesdocument_ex = <v_vbeln>
  TABLES
    return = return
    sales_items_in = <item>.
    " ...