Application Development and Automation 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: 
Read only

Custom IDoc program to send PO ?

Former Member
0 Likes
773

Hai,

Can any one send the complete program, on how to send PO (Purchase Oeder) through custom IDoc .

Please send code for both outbound and inbound process ?

1 ACCEPTED SOLUTION
Read only

Former Member

Hai,

Can any one send the complete program, on how to send PO (Purchase Oeder) through custom IDoc .

Please send code for both outbound and inbound process ?

4 REPLIES 4
Read only

Former Member
Read only

0 Likes
723

hi kiran,

cud u plz tell me to how to create custom idoc used in LSMW for transferring the data from ecc to crm..plz sugest me ,,its very urgent

Read only

Former Member
0 Likes
723

Hi kiran ,

Thanks for the response and it is helpful. But , i need the program for outbound and function module for inbound process?

If you can get that it is very helpful to me.

Regards

Vamshi

Edited by: VAMSHI KRISHNA on May 25, 2008 4:11 PM

Read only

Former Member
0 Likes
723

Hi Vamsi,

Here i am sending sample codes for Inbound and Outbound Processes..

IN OUTBOUND SIDE :

REPORT ZSTAND_PROGRAM.

*1. Create parameters/select-options for input data. i.e., empno, message type, logical system.

PARAMETERS : P_SNO LIKE ZSAMP1-SNO OBLIGATORY,

P_MESTYP LIKE EDMSG-MSGTYP DEFAULT 'ZMSG1',

P_LOGSYS LIKE TBDLST-LOGSYS OBLIGATORY.

*2. Create Data objects for control record, data record and database table.

DATA : C_SEGMENT LIKE EDIDD-SEGNAM VALUE 'ZSEG1',

C_IDOCTP LIKE EDIDC-IDOCTP VALUE 'ZIDOC1'.

DATA : BEGIN OF IT_ZSAMP1,

SNO LIKE ZSAMP1-SNO,

SNAME LIKE ZSAMP1-SNAME,

END OF IT_ZSAMP1.

DATA : INT_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE.

DATA : INT_CONTROL_RECORD LIKE EDIDC.

DATA : INT_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE.

*3. Select the data from corresponding tables into internal table for a defined condition.

SELECT SINGLE SNO SNAME FROM ZSAMP1 INTO CORRESPONDING FIELDS OF IT_ZSAMP1 WHERE SNO = P_SNO.

*4. create control record into internal table.

INT_CONTROL_RECORD-MESTYP = P_MESTYP.

INT_CONTROL_RECORD-IDOCTP = C_IDOCTP.

INT_CONTROL_RECORD-RCVPRT = 'LS'.

INT_CONTROL_RECORD-RCVPRN = P_LOGSYS.

*5. create data record into internal table.

INT_EDIDD-SEGNAM = C_SEGMENT.

INT_EDIDD-SDATA = IT_ZSAMP1.

APPEND INT_EDIDD.

*6. Process ALE Service Layer using the function module MASTER_IDOC_DISTRIBUTE.

    • It returns the corresponding IDoc No.s.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = INT_CONTROL_RECORD

tables

communication_idoc_control = INT_COMM_IDOC

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.

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

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

ENDIF.

*7. Display Communication IDocs.

LOOP AT INT_COMM_IDOC.

WRITE : / 'Communication IDoc No. is : ', INT_COMM_IDOC-DOCNUM.

ENDLOOP.

*8. Commit Work.

COMMIT WORK.

IN INBOUND SIDE :

FUNCTION ZL_IDOC_INPUT_MATMAS_MDM.

*"----


""Local interface:

*" IMPORTING

*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD

*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC

*" EXPORTING

*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT

*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-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

*" EXCEPTIONS

*" WRONG_FUNCTION_CALLED

*" OTHER_EXC

*"----


*1. Call workflow include program MBDCONWF.

INCLUDE MBDCONWF.

*2. Create Data Objects for segment(s) and DB Table.

TABLES : ZSAMP1.

DATA : FS_SHDR_DATA LIKE ZSEG1.

DATA : FS_APP_SDET LIKE ZSAMP1.

*3. Raise the exception if the message type is not ZMSG1.

IF IDOC_CONTRL-MESTYP NE 'ZMSG1'.

RAISE WRONG_FUNCTION_CALLED.

CLEAR FS_APP_SDET.

ENDIF.

*4. Process Each segment in the IDoc.

LOOP AT IDOC_CONTRL.

LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.

CASE IDOC_DATA-SEGNAM.

WHEN 'ZSEG1'.

FS_SHDR_DATA = IDOC_DATA-SDATA.

  • MOVE-CORRESPONDING FS_SHDR_DATA TO FS_APP_SDET.

FS_APP_SDET-mandt = '000'.

FS_APP_SDET-sno = FS_SHDR_DATA-zsno.

FS_APP_SDET-sname = FS_SHDR_DATA-zsname.

ENDCASE.

ENDLOOP.

  • 5. If the data already exists update the data or else insert the data.

SELECT SINGLE * FROM ZSAMP1 WHERE SNO EQ FS_APP_SDET-SNO.

IF SY-SUBRC NE 0.

INSERT INTO ZSAMP1 VALUES FS_APP_SDET.

ELSE.

UPDATE ZSAMP1 FROM FS_APP_SDET.

ENDIF.

*6. If the data successfully posted maintain status as 53 or if unsuccessful give status as 51.

IF SY-SUBRC EQ 0 .

  • POPULATE RETURN VARIABLES FOR SUCCESS.

RETURN_VARIABLES-WF_PARAM = 'PROCESSED_IDOCS'.

RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

APPEND RETURN_VARIABLES.

  • ADD STATUS RECORD INDICATES SUCCESS.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '53'.

IDOC_STATUS-MSGTY = 'I'.

IDOC_STATUS-MSGID = 'ZM'.

IDOC_STATUS-MSGNO = '006'.

IDOC_STATUS-MSGV1 = FS_APP_SDET-SNO.

APPEND IDOC_STATUS.

ELSE.

  • POPULATE RETURN VARIABLES FOR ERROR.

RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'.

RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

APPEND RETURN_VARIABLES.

  • ADD STATUS RECORD INDICATES ERROR.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '51'.

IDOC_STATUS-MSGTY = 'E'.

IDOC_STATUS-MSGID = 'ZM'.

IDOC_STATUS-MSGNO = '007'.

IDOC_STATUS-MSGV1 = FS_APP_SDET-SNO.

APPEND IDOC_STATUS.

ENDIF.

ENDLOOP.

ENDFUNCTION.

These are sample code for custom idoc...i did this for customized tables..change this according to your requirement.

Reward if it useful..

Lakshmi.

Edited by: lakshmi matti on May 26, 2008 11:05 AM