Application Development 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: 

Function module for posting the Idoc

Former Member
0 Kudos
104

Hi,

I am developing a function module to post the Idoc. That is inserting records in a customised table. If suppose there is an error in posting the Idoc what are the values to be passed for example the status of the idoc and what else should be passed

2 REPLIES 2

Former Member
0 Kudos
71

Preetha,

This certainly depends on your requirement. Will it be possible to let us know what IDOC type and FM that you are trying to use?

What do you expect the IDOC to do once it is in error? start a workflow or just show the error status

Ganesh

former_member404244
Active Contributor
0 Kudos
71

Hi preetha,

if the idoc goes to error u have to use idoc status internal table and fill.please have a look at the below code.probably it gives some idea..

also u functiom module parameters should be like this.

Local Interface:

*" IMPORTING

*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD

*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC

*" EXPORTING

*" REFERENCE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT

*" REFERENCE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR

*" REFERENCE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK

*" REFERENCE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS

*" TABLES

*" IDOC_CONTRL STRUCTURE EDIDC

*" IDOC_DATA STRUCTURE EDIDD

*" IDOC_STATUS STRUCTURE BDIDOCSTAT

*" RETURN_VARIABLES STRUCTURE BDWFRETVAR

*" SERIALIZATION_INFO STRUCTURE BDI_SER

*" EXCEPTIONS

*" WRONG_FUNCTION_CALLED

for example...u have to fill like this.

data : retn_info TYPE bapiret2.

if sy-subrc ne 0(means error).

status = '51'.

retn_info-type = 'E'.

retn_info-id = <message class>.

retn_info-number = <message number>.

retn_info-message_v1 = <givesome information>.

then..u have to fill the idoc status like this.

idoc_status-docnum = idoc_contrl-docnum.

idoc_status-msgty = retn_info-type.

idoc_status-msgid = retn_info-id.

idoc_status-msgno = retn_info-number.

idoc_status-appl_log = retn_info-log_no.

idoc_status-msgv1 = retn_info-message_v1.

idoc_status-repid = sy-repid.

idoc_status-status = status.

APPEND idoc_status.

else.

status = '53'.

retn_info-type = 'S'.

retn_info-id = <message class>.

retn_info-number = <message number>.

retn_info-message_v1 = <givesome information>.

idoc_status-docnum = idoc_contrl-docnum.

idoc_status-msgty = retn_info-type.

idoc_status-msgid = retn_info-id.

idoc_status-msgno = retn_info-number.

idoc_status-appl_log = retn_info-log_no.

idoc_status-msgv1 = retn_info-message_v1.

idoc_status-repid = sy-repid.

idoc_status-status = status.

APPEND idoc_status.

ENDIF.

Regards,

Nagaraj

Message was edited by: nagaraj kumar nishtala