P. 1
IDocBook

IDocBook

3.0

|Views: 465|Likes:
Published by mukesh0286
sap abap
sap abap

More info:

Published by: mukesh0286 on Aug 22, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

12/03/2012

pdf

text

original

Inbound processing is basically the reverse process of an outbound.. The received IDoc has to
be unpacked, interpreted and transferred to an application for further processing.

FUNCTION

*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR
*" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
*" VALUE(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
*"----------------------------------------------------------------------

DATA: XTHEAD LIKE THEAD .
DATA: TLINES LIKE TLINE OCCURS 0 WITH HEADER LINE.
CLEAR XTHEAD.
REFRESH TLINES.

* *** --- Unpacking the IDoc --- ***

LOOP AT IDOC_DATA.
CASE IDOC_DATA-SEGNAM.
WHEN 'YAXX_THEAD'.
MOVE IDOC_DATA-SDATA TO XTHEAD.
WHEN 'YAXX_TLINE'.
MOVE IDOC_DATA-SDATA TO TLINES.

ENDCASE.

ENDLOOP.

* *** --- Calling the application to process the received data --- ***

CALL FUNCTION 'SAVE_TEXT'
EXPORTING

HEADER = XTHEAD
SAVEMODE_DIRECT = 'X'

TABLES

LINES = TLINES.

ADD SY-SUBRC TO OK.

* füllen IDOC_Status
* fill IDOC_Status

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-MSGV1 = IDOC_CONTRL-IDOCTP.
IDOC_STATUS-MSGV2 = XTHEAD.
IDOC_STATUS-MSGID = '38'.
IDOC_STATUS-MSGNO = '000'.
IF OK NE 0.
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-MSGTY = 'E'.

ELSE.

IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-MSGTY = 'S'.
CALL_TRANSACTION_DONE = 'X'.

ENDIF.
APPEND IDOC_STATUS.

ENDFUNCTION.

Figure 12: Sample IDoc outbound function module

This example of a simple inbound function module expects as input an IDoc with
rows of plain text as created in the outbound example above. The procedure will
extract the text name and the text line from the IDoc and hand over the text data to
the function module SAVE_TEXT which will store the text in the text pool.

The received IDoc data is processed record by record and data is sorted out

Inbound processing
function module

Unpacking the IDoc data

Axel Angeli et.al. SAP R/3 Guide to EDI ISBN 3528157291

35

according to the segment type.

* *** --- Unpacking the IDoc --- ***
LOOP AT IDOC_DATA.bb
CASE IDOC_DATA-SEGNAM.
WHEN 'YAXX_THEAD'.

PERFORM UNPACK_IDOC TABLES IDOC_DATA USING XTHEAD.

WHEN 'YAXX_TLINE'.

PERFORM UNPACK_TAB TABLES IDOC_DATA TLINES.

ENDCASE.

ENDLOOP.

When the IDoc is unpacked data is passed to the application.

* *** --- Calling the application to process the received data --- ***
CALL FUNCTION 'SAVE_TEXT'
EXPORTING

HEADER = XTHEAD

TABLES

LINES = TLINES.

Figure 13: Storing data

Finally the processing routine needs to pass a status record to the IDoc processor.
This status indicates successful or unsuccessful processing and will be added as a
log entry to the table EDIDS.

* fill IDOC_Status
IF OK NE 0.
IDOC_STATUS-STATUS = '51'.
* IDOC_STATUS-.. = . fill the other fields to log information

ELSE.

IDOC_STATUS-STATUS = '53'.

ENDIF.
APPEND IDOC_STATUS.

Figure 14: Writing a status log

The status value '51' indicates a general error during application processing and the
status '53' indicates everything is OK.

Axel Angeli et.al. SAP R/3 Guide to EDI ISBN 3528157291

36

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->