cancel
Showing results for 
Search instead for 
Did you mean: 

BADI Impl. from ME_PROCESS_PO_CUST Method = PROCESS_ITEM - Used to trigger web service

former_member210563
Participant
0 Kudos

Hi,

I use the BADI above to trigger a web service outbound to send PO data to a third party system.

I need to send Work Order No for Item Lines in the WSDL and I have added this code in the above method in order to read the accounting data for item lines:

LOOP AT im_item->get_accountings( ) ASSIGNING FIELD-SYMBOL(<fs_accounting>).
IF sy-subrc = 0.
IF NOT <fs_accounting>-accounting->get_data( )-aufnr IS INITIAL.
** Do checks needed..
ENDIF.
ENDIF.
ENDLOOP.

However, I need the field AUFNR to be used in a method in the web service because I to write it to the WSDL. I read the data in PROCESS_ITEM but I need the data in another method.

How can this data be available to my method?

SimoneMilesi
Active Contributor
0 Kudos

Marginal note

LOOP AT im_item->get_accountings( ) ASSIGNING FIELD-SYMBOL(<fs_accounting>).
IF sy-subrc = 0.

You do not need the IF: you are inside the loop and surely you found the record 🙂

Accepted Solutions (1)

Accepted Solutions (1)

nick_giannakis
Explorer
0 Kudos

By "method in the web service" you mean the generated operation in proxy, or just another object that actually builds and send the request payload?

I think a good approach for such cases is a use of a singleton class. In POST method of your badi, generate an instance (if needed) of your singleton, and set the data that you want in that instance.

Then in your followed method retrieve that instance with the respective attributes to use them as you like.

Answers (4)

Answers (4)

raymond_giuseppi
Active Contributor

Are you consuming the web service when the PO is saved to database and not everytime user press enter when changing an item?

In this case, shouldn't your code be triggered from POST method, there you have the final data, and from received im_header parameter you can get list of items with get_items method and then list of orders in accounting block from get_accountings method.

former_member210563
Participant
0 Kudos

Thanks Nick,

I created a singleton class with one attribute and I can now read the AUFNR field where I need it.

Regards,Peter

former_member210563
Participant
0 Kudos

Thanks, but still; how will the data in the field symbol be available in my method in the web service which is outside the BADI?

former_member210563
Participant
0 Kudos

Yes, the consuming happens when the user presses SAVE. But placing the code in POST sounds more correct as you write, but I need the data for validation in the method of the web service that actually generates the XML?