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

Adapting BAPIs

Former Member
0 Likes
464

Hello gurus,

I had to add some additional fields to the positions of sales orders.

Nevertheless I would like to have a non-SAP-system create orders in SAP. Normally I would use BAPI_SALESORDER_CREATEFROMDAT2 for this.

My question is: Can I in some way change BAPI_SALESORDER_CREATEFROMDAT2 so that the new fields in my orders are being filled with data from the external system, too?

Thanks in advance

Jens

2 REPLIES 2
Read only

Former Member
0 Likes
432

Jens,

There is a tables parameter called extensionin in the function module interface. This table can be used to populate your additional fields assuming that they are included in the appends for VBAK, VBKD, VBAP and VBEP.

The function module documentaion provides details on how to populate this parameter. Select the function module documentation, and then click on the extensionin link and it should take you there.

Best Regards,

Chris H.

Read only

0 Likes
432

Hi, Jens!

I believe that note 143580 would be a good starting point for you. I never did

it with BAPI_SALESORDER_CREATEFROMDAT2, but I'll show you how I did it with BAPI_PO_CREATE1. It has the EXTENSIONIN table parameter

so I suppose they function in similar way. So:

1. You need to find which structures

fits your function to be extended. For BAPI_PO_CREATE1 it was BAPI_TE_MEPOHEADER for

purchase order header and BAPI_TE_MEPOITEM for items. Sometimes there are pairs to structures with the same name and trailing "X", like BAPI_TE_MEPOHEADERX. They containt one-character flag for each field for marking the fields which need to be passed.

2. Find an .INCLUDE in this structure which was included there for enhancements. In my case it was CI_EKKODB. This is the structure which you

need to modify.

3. Just add your field here, but be careful! This structure was

included in many other tables and structures, and if there's already field with

the same name, you're in trouble. That was my case, so I had to name it

differently. To stay on the safe side, it's common (though not obligatory) to

name it with leading "Z".

4. Pass this field using EXTENSIONIN structure. It works in somewhat

weird way. The EXTENSIONIN structure (in your case BAPIPAREX) has 5 fields: STRUCTURE and 4 VALUEPART fields.

This is how it worked with me:

s_extensionin-structure        = 'BAPI_TE_MEPOHEADER'.
s_bapi_te_mepoheader-zoic_mot   = l_field.
s_extensionin-valuepart1       = s_bapi_te_mepoheader.
APPEND s_extensionin TO t_extensionin.
CLEAR s_extensionin.
s_extensionin-structure        = 'BAPI_TE_MEPOHEADERX'.
s_bapi_te_mepoheaderx-zoic_mot = 'X'.
s_extensionin-valuepart1       = s_bapi_te_mepoheaderx.
APPEND s_extensionin TO t_extensionin.
*...
CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING poheader         = s_po_header
            poheaderx        = s_po_headerx
  IMPORTING exppurchaseorder = <outtab_valid>-ebeln
  TABLES    return           = t_return
            poitem           = t_po_items
            poitemx          = t_po_itemsx
            poschedulex      = t_po_schedulex
            poschedule       = t_po_schedule
            extensionin      = t_extensionin
            potextheader     = t_po_texthead.

With your function it is probably similar, but not the same. I hope the

mentioned note would help you.

Now you passed your field, but what to do with it? You need to find some user-

exit to handle this field and pass value to where it belongs. I found a BADI for my

function, and did:

ls_mepoheader-oic_mot = ls_mepoheader-zoic_mot.
im_header->set_data( ls_mepoheader ).

This was specific for my use - you need to find out how to do it in your case. I hope with the note from the beginning of my post and similar procedure to mine, you'll be able to do it.

Regards,

Igor