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: 

Standard IDOC Generation

Former Member
0 Kudos
227

Dear All,

I want to generate the standard IDOCS TCURC_01 ( Currency Codes) and TCURR_01 (Exchange rates). These IDOCs must contain all the change data from TCURC and TCURR Tables.

How can I generate these standard IDOCs?

How can I send these standard IDOCs via ALE for outbound processing?

( For eg. to send material we use BD10, what can we use to send these IDOCs)

Thanks and Regards

Ashwin

1 ACCEPTED SOLUTION

Former Member
0 Kudos
72

HI

you have to write the following code:

REPORT ZALE_USR.

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

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01', segment type

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.

<b>execute the program, run bd87 after that.</b>

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

Regards

Aarti

4 REPLIES 4

Former Member
0 Kudos
72

hi

just refer to the link below

http://www.sapmaterial.com/?gclid=CN322K28t4sCFQ-WbgodSGbK2g

regards

ravish

<b>plz reward if useful</b>

0 Kudos
72

Thanks for your replies everyone,

Ravish, I an unable to open the link from myb office..the url is blocked :(..I'll chk it out frm home

Aarti, Kiran, Is there a standard functionality available in SAP? The client is reluctant to allow any custom developments for this system.

Thanks and Regards.

Ashwin

Former Member
0 Kudos
73

HI

you have to write the following code:

REPORT ZALE_USR.

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

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01', segment type

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.

<b>execute the program, run bd87 after that.</b>

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

Regards

Aarti

Former Member
0 Kudos
72

Hi, I added an example of how to distribute IDoc's with abap. Make sure you fill the Idoc in the same order you created your segments.

*Constants

c_action type edidd-segnam value 'Z1ACTION',

c_objects type edidd-segnam value 'Z1OBJECTS',

c_skills_idoc_type type edidc-idoctp value 'ZSKILLS'.

data: control_record_out type edidc,

action type Z1ACTION,

objects type Z1OBJECTS,

int_edidd type table of edidd,

ls_edidd like line of int_edidd,

it_comm_idocs type table of edidc.

control_record_out-mestyp = 'ZPDOTYPE_Q'.

control_record_out-idoctp = c_skills_idoc_type.

control_record_out-rcvprt = 'LS'.

control_record_out-rcvprn = 'SQ1CLNT100'.

action-action = 'UPD'.

ls_edidd-segnam = c_action.

ls_edidd-sdata = action.

append ls_edidd to int_edidd.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = control_record_out

  • OBJ_TYPE = ''

  • CHNUM = ''

tables

communication_idoc_control = it_comm_idocs

master_idoc_data = int_edidd

  • EXCEPTIONS

  • ERROR_IN_IDOC_CONTROL = 1

  • ERROR_WRITING_IDOC_STATUS = 2

  • ERROR_IN_IDOC_DATA = 3

  • SENDING_LOGICAL_SYSTEM_UNKNOWN = 4

  • OTHERS = 5

<b>Reward points</b>

Regards