SAPAbapProgramming

Its all about SAP Abap

&
 

Jun 18 2008

Converting Data Into IDoc Segment Format

Published by asoka at 6:09 pm under EDI Edit This

The physical format of the IDocs records is always the same. Therefore the
application data must be converted into a 1000 character string.An IDocs is a file with a rigid formal structure. This allows the correspondents to correctly interpret the IDoc information. Were it for data exchange between SAP-systems only, the IDoc segments could be simply structured like the correspondent DDIC structure of the tables whose data is sent.
However, IDocs are usually transported to a variety of legacy systems which do not run SAP. Both correspondents therefore would agree an IDoc structure which is known to the sending and the receiving processes.
All data needs to be compiled in an internal table with the structure of the standard SAP table EDIDD. The records for EDIDD are principally made up of a header string describing the segment and a variable length character field (called SDATA) which will contain the actual segment data.

FORM PACK_LINE TABLES IDOC_DATA USING ‘THEAD’ E_THEAD.
TABLES: THEAD.
MOVE-CORRESPONDING E:THEAD to Z1THEAD.
MOVE ‚Z1THEAD’ TO IDOC_DATA-SEGNAM.
MOVE Z1THEAD TO IDOC_DATA-SDATA.
APPEND IDOC_DATA.
ENDFORM.

Finally the control record has to be filled with meaningful data, especially telling the IDoc type and message type.

IF IDOC_CONTRL-SNDPRN IS INITIAL.
SELECT SINGLE * FROM T000 WHERE MANDT EQ SY-MANDT.
MOVE T000-LOGSYS TO IDOC_CONTRL-SNDPRN.
ENDIF.
IDOC_CONTRL-SNDPRT = ‘LS’.
* Trans we20 -> Outbound Controls muss entsprechend gesetzt werden.
* 2 = Transfer IDoc immediately
* 4 = Collect IDocs
IDOC_CONTRL-OUTMOD = ‘2′. “1=imediately, subsystem
CLEAR IDOC_CONTRL.
IDOC_CONTRL-IDOCTP = ‘YAXX_TEXT’.
APPEND IDOC_CONTRL.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
Possibly-related Articles:                                        (auto-generated)

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.
Not A Member? Register for Free!

Some Today.com contributors may have received a fee or a promotional product or service from a manufacturer for promotional consideration, while others receive no consideration at all. Each contributor is responsible for disclosing any such promotional consideration.