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: 

Problem with FM 'MASTER_IDOC_DISTRIBUTE'

Former Member
0 Kudos

Hello,

I am wirtting a FM that will create IDoc of type OILORD (Sales Order).

I am using 'MASTER_IDOC_DISCTRIBUTE' fm to do so.

Now my problem is the IDoc gets created but is in status '30'.

In my partner profile i have ticked on trigger imm.

also when i create a sales order through VA01 it is creating the IDoc and the status of that idoc is '03'. mind you its the same idoc. of type OILORD and even they have used same FM i.e. MASTER_IDOC_DITRIBUTE'

also after calling FM MASTER_IDOC_DITRIBUTE' in my FM i am checking for sy-subrc and when sy-subrc is 0 i call commit work.

I need to create the IDoc ( with status '03') through my FM only..

I am aware that by executing program RSEOUT00 or via Tcode we14 or BD87 I can process the IDoc with status 30 and change the status to 03 .. i did try using submit stmt and submit the idoc number that is returned by the 'communication_idoc_control' to program RSEOUT00 but it didnt help...

in fact when i call the RSEOUT00 program externally and execute it with the idoc number it does change the status of the IDOC from 30 to 03 but if i do the same via my FM it doesnt do any thing ..

so can any one help me with this..

thank you.

7 REPLIES 7

Former Member
0 Kudos

Can you paste your code

Regards,

Atish

0 Kudos

ok this what I am doing to create the idoc

  • Check whether IDOC needs to be created.

CALL FUNCTION 'ALE_MODEL_DETERMINE_IF_TO_SEND'

EXPORTING

MESSAGE_TYPE = p_MESTYP_OILORD

IMPORTING

IDOC_MUST_BE_SENT = IDOC_MUST_BE_SENT

EXCEPTIONS

OWN_SYSTEM_NOT_DEFINED = 01.

IF SY-SUBRC <> 0.

PERFORM FILL_NAST_PROTOCOL.

EXIT.

ENDIF.

  • If IDOC needs to be transmitted, create IDOC and send it.

IF IDOC_MUST_BE_SENT = C_TRUE.

&----


CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = EDIDC

tables

communication_idoc_control = INT_COMM_CNTL

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

.

IF sy-subrc <> 0.

PERFORM FILL_NAST_PROTOCOL.

CLEAR INT_RETURN_WA.

INT_RETURN_WA-TYPE = SY-MSGTY.

INT_RETURN_WA-CODE = SY-MSGNO.

INT_RETURN_WA-MESSAGE_V1 = SY-MSGV1.

INT_RETURN_WA-MESSAGE_V2 = SY-MSGV2.

INT_RETURN_WA-MESSAGE_V3 = SY-MSGV3.

INT_RETURN_WA-MESSAGE_V4 = SY-MSGV4.

ELSE.

COMMIT WORK.

CLEAR INT_RETURN_WA.

INT_RETURN_WA-TYPE = SY-MSGTY.

INT_RETURN_WA-CODE = SY-MSGNO.

  • INT_RETURN_WA-MESSAGE_V1 = SY-MSGV1.

  • INT_RETURN_WA-MESSAGE_V2 = SY-MSGV2.

INT_RETURN_WA-MESSAGE_V3 = SY-MSGV3.

INT_RETURN_WA-MESSAGE_V4 = SY-MSGV4.

read table int_comm_cntl into int_comm_cntl_wa index 1.

INT_RETURN_WA-MESSAGE_V1 = INT_COMM_CNTL_wa-DOCNUM.

INT_RETURN_WA-MESSAGE_V2 = INT_COMM_CNTL_wa-status.

ENDIF.

&----


  • IDOC sent...........................................................

else.

INT_RETURN_WA-TYPE = 'E'.

INT_RETURN_WA-CODE = SY-MSGNO.

INT_RETURN_WA-MESSAGE_V1 = 'IDoc Can not be sent'.

endif.

&----


**submit stmt

  • read table int_comm_cntl into int_comm_cntl_wa index 1.

  • if sy-subrc = 0.

  • submit RSEOUT00 with DOCNUM = int_comm_cntl_wa-docnum and return.

  • endif.

&----


Former Member
0 Kudos

Hello,

Try to schedule the program RBDAGAIN in the background.

Reward if helps.

Thanks,

Krishnakumar

Former Member
0 Kudos

Hi

Just go through the following code for creating idoc:

REPORT ZALE_USR.

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

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01',

C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZUSRDET'.

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.

execute the program, then run bd87. i think it will solve your problem

<b>Reward points for helpful ans</b>

Regards

Aarti

Former Member
0 Kudos

Is there any work around for my problem?? see i am not supposed to schedule the job niether i am supposed to process teh idco externaly via we14 or bd87...

0 Kudos

try setting OUTMOD parameter in Control record.

Former Member
0 Kudos

Well my problem got solved!!!

You need to call FM : 'EDI_DOCUMENT_DEQUEUE_LATER' after calling 'MASTER_IDOC_DISTRIBUTE'.

and call COMITT WORK after that.

so the idoc that is created with status 30 gets processed and the status of the idoc get changed to 03.

Regards Ashwinee Mali