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: 

inbound idoc processing

Former Member
0 Kudos
151

Hi friends..

I have to select data from SAP and put itin internal table and then put that data in IDOC and process that idoc...there is no transaction involved..

its SAP to SAP Posting ie within same client using IDOC.

i have tested in WE19..its OK..

how shud i do coding and triggering of process code.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
122

hi

refer the follwing code, it may be helful

REPORT ZALE_USR.

CONSTANTS: C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZUSRDET01',Idoctype

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01', segmenttype

C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZUSRDET'. message type

DATA: IT_ZUSR02 TYPE USR02 OCCURS 10,

IT_EDIDC TYPE EDIDC OCCURS 0,

IT_EDIDD TYPE EDIDD OCCURS 0,

WA_ZUSR02 TYPE USR02,

WA_EDIDC TYPE EDIDC,

WA_EDIDD TYPE EDIDD,

WA_Z1USRDET01 TYPE Z1USRDET01,

V_OCCMAX TYPE IDOCSYN-OCCMAX,

V_NBSEG TYPE I.

CLEAR WA_ZUSR02.

CLEAR WA_EDIDC.

  • Save the message type and the basic IDoc type in the control segment.

MOVE C_MESTYP TO WA_EDIDC-MESTYP.

MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.

  • Retrieve the maximum number of segments in the basic IDoc type.

SELECT MIN( OCCMAX ) FROM IDOCSYN INTO V_OCCMAX WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.

  • Save the whole USR02 table content in the IT_ZUSR02 internal table.

SELECT * FROM USR02 INTO CORRESPONDING FIELDS OF TABLE IT_ZUSR02.

  • Create a data segment for each line of IT_ZUSR02.

LOOP AT IT_ZUSR02 INTO WA_ZUSR02 .

MOVE-CORRESPONDING WA_ZUSR02 TO WA_Z1USRDET01.

CLEAR WA_EDIDD.

MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.

MOVE WA_Z1USRDET01 TO WA_EDIDD-SDATA.

APPEND WA_EDIDD TO IT_EDIDD.

CLEAR WA_ZUSR02.

CLEAR WA_Z1USRDET01.

ENDLOOP.

  • Count the number of data segments.

DESCRIBE TABLE IT_EDIDD LINES V_NBSEG.

  • If the number of data segments exceeds the maximum allowed number,then display an error message.

IF V_NBSEG GT V_OCCMAX.

WRITE:/ 'ERROR'.

ENDIF.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = WA_EDIDC

  • OBJ_TYPE = ''

  • CHNUM = ''

tables

communication_idoc_control = IT_EDIDC

master_idoc_data = IT_EDIDD

EXCEPTIONS

ERROR_IN_IDOC_CONTROL = 1

ERROR_WRITING_IDOC_STATUS = 2

ERROR_IN_IDOC_DATA = 3

SENDING_LOGICAL_SYSTEM_UNKNOWN = 4

OTHERS = 5

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

It will populate your idoc, once u execute the prog and run<b> bd87</b>

<b>reward points for useful ans</b>

Regards

Aarti

4 REPLIES 4

Former Member
0 Kudos
122

What is the IDoc message type. Is it Standard.

Former Member
0 Kudos
123

hi

refer the follwing code, it may be helful

REPORT ZALE_USR.

CONSTANTS: C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZUSRDET01',Idoctype

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01', segmenttype

C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZUSRDET'. message type

DATA: IT_ZUSR02 TYPE USR02 OCCURS 10,

IT_EDIDC TYPE EDIDC OCCURS 0,

IT_EDIDD TYPE EDIDD OCCURS 0,

WA_ZUSR02 TYPE USR02,

WA_EDIDC TYPE EDIDC,

WA_EDIDD TYPE EDIDD,

WA_Z1USRDET01 TYPE Z1USRDET01,

V_OCCMAX TYPE IDOCSYN-OCCMAX,

V_NBSEG TYPE I.

CLEAR WA_ZUSR02.

CLEAR WA_EDIDC.

  • Save the message type and the basic IDoc type in the control segment.

MOVE C_MESTYP TO WA_EDIDC-MESTYP.

MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.

  • Retrieve the maximum number of segments in the basic IDoc type.

SELECT MIN( OCCMAX ) FROM IDOCSYN INTO V_OCCMAX WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.

  • Save the whole USR02 table content in the IT_ZUSR02 internal table.

SELECT * FROM USR02 INTO CORRESPONDING FIELDS OF TABLE IT_ZUSR02.

  • Create a data segment for each line of IT_ZUSR02.

LOOP AT IT_ZUSR02 INTO WA_ZUSR02 .

MOVE-CORRESPONDING WA_ZUSR02 TO WA_Z1USRDET01.

CLEAR WA_EDIDD.

MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.

MOVE WA_Z1USRDET01 TO WA_EDIDD-SDATA.

APPEND WA_EDIDD TO IT_EDIDD.

CLEAR WA_ZUSR02.

CLEAR WA_Z1USRDET01.

ENDLOOP.

  • Count the number of data segments.

DESCRIBE TABLE IT_EDIDD LINES V_NBSEG.

  • If the number of data segments exceeds the maximum allowed number,then display an error message.

IF V_NBSEG GT V_OCCMAX.

WRITE:/ 'ERROR'.

ENDIF.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = WA_EDIDC

  • OBJ_TYPE = ''

  • CHNUM = ''

tables

communication_idoc_control = IT_EDIDC

master_idoc_data = IT_EDIDD

EXCEPTIONS

ERROR_IN_IDOC_CONTROL = 1

ERROR_WRITING_IDOC_STATUS = 2

ERROR_IN_IDOC_DATA = 3

SENDING_LOGICAL_SYSTEM_UNKNOWN = 4

OTHERS = 5

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

It will populate your idoc, once u execute the prog and run<b> bd87</b>

<b>reward points for useful ans</b>

Regards

Aarti

former_member582701
Contributor
0 Kudos
122

See next transactions:

WE57: link inbound idoc with your function

WE42: create process code

BD51: define the function

I think you only need this three transactions to define the inbound process

0 Kudos
122

everythinhg is standard...

HOw the process code ll trigger