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

Creating IDOC

former_member313782
Active Participant
0 Likes
790

Hi all,

I have a requirement where i have to send an SD IDOC from one sap to another sap system using EDI. Could you tell me what are the settings and configurations i would have to do (like setting up partner profile etc) for sending it successfully.

Any pointers would be highly appreciated.

Thanks in advance.

Regards,

Jose

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
668
4 REPLIES 4
Read only

Former Member
0 Likes
669
Read only

0 Likes
668

Hi Naveen,

Thanks for replying so soon,

i have gone through the links sent by you,

they are good but they give information about how to create an IDOC using ALE, but i need to create it using EDI.

so could you help me on that.

Regards,

Jose

Read only

dhruv_shah3
Active Contributor
0 Likes
668

Hi Jose,

You may use the Following for IDOC.

SEND DATA THROUGH ALE-IDOC

We will create data in 100 client and send to 200 client. So out sender system is 100

client and receiver system is 200 client. So create tables and records in 100 client and we

will send these data to 200 client.

NOTE – Here we are not using SAP standard Message type. So we have to create each and

every things, like tables, segments, basic idoc, message type, function module,

executable program, but when we will send through SAP standard message type, we don’t

need to create all above things.

1. CREATE TABLES

1. ZCUSTHEAD – Customer master

a. mandt - client

b. kunnr – customer no(PK)

c. name1 – name of customer

d. add1 – address

e. regio – country

2. ZSALHEAD

a. mandt – client

b. vbeln – sales document (PK)

c. kunnr – cust no (FK of ZCUSTHEAD)

3. ZSALITEM

a. mandt – client

b. vbeln – sales doc no. (FK of ZSALHEAD AND PK)

c. posnr – item no. (PK)

d. matnr – material no.

e. netwr – value of material

f. zmeng – quantity of material

2. CREATE RECORDS

Create records in above tables. Go to SE16, give table name and click on create icon

to create records.

(Signature invalid, data error) Signed by kinnari Time: 2002.11.14 16:02:59 +05'30' Reason: <none> Location:

(Signature invalid, data error) Signed by kinnari Time: 2003.01.03 09:39:41 +05'30' Reason: <none> Location:

(Signature invalid, data error) Signed by kinnari Time: 2003.01.03 09:38:46 +05'30' Reason: <none> Location:

STEPS OF SENDING DATA THROUGH IDOC

A. Create a basic Idoc type.

B. An Outbound (Selection) program for generating Idocs

C. ALE Configuration in sending System

D. An Inbound (Posting) program for Posting Idocs

E. Settings in receiving system

F. Send and Receiving Idoc.

OUTBOUND PROCESS

A. Create a basic Idoc type

1. To create Basic Idoc Type first we have to create segment.

To create Segments go to WE31

2. Give segment name as Z1SEGMENT1

(CREATE ICON)

3. Click on CREATE Icon.

4. It shows you above screen.

5. Just give field names and data element for this field, Be sure that the data element should be

the same which you have given in table.

6. Give all the fields of ZCUSTHEAD table.

7. After defining it, save it as request.

NOTE : You can save it as local object but , if you save it as local object you have to define all

segments again in receiving system. So create it as request and transport it.

8. After saving Segment release it. Write segment name in segment type field (we31).

Go to Edit in Menu bar, Set Release. It will add in Definitios, and will take 46C as Release.

9. Create Z1SEGMENT2 same as Z1SEGMENT1 for ZSALHEAD table and Z1SEGMENT3 for

ZSALITEM table.

Release them same as Z1SEGMENT1.

10. Creating Basic Idoc Type goto WE31.

11. Type name of Basic Idoc Type as ZSALIDOC in obj. name field.

12. Choose Basic type Development object.

13. Click on Create Icon.

14. It will jump you to below screen.

15. Select Create new and enter description in Description field.

16. Press enter.

17. It jumps to below screen.

18. And if you click on Create Icon, It will pop up Maintain Attributes window.

19. In this pop up window write segment name Z1SEGMENT1, click it as mandatory segment. Min

no 1 and max no 10. Press enter.

20. Same way attach Z1SEGMENT2 as child level.

And give same attributes like Z1SEGMENT1. But don’t give as mandatory segment.

21. Same way attach Z1SEGMENT3 as child level of Z1SEGMENT2. Give segm type Z1SEGMENT3,

don’t give mandatory seg. , min no 1 and max no 50. Press enter.

22. It looks like now below picture.

23. Save it and press F3 to go back. And release this Idoc also. Write Idoc name in Obj.

field(we30).

Go to Edit and Set Release.

24. To Create Message Type go to WE81. Click on Change Icon, from App. bar.

25. Displays below screen, Click on New entries.

(New entries)

26. Jump you to next screen. Give Message Type “ZSALMES” and description. Save it or create

request for it.

27. Idoc is attached with Segments and now attach Idoc with message type.

28. To attach it go to WE82. Click on change icon.

29. Click on New entries.

(New entries)

30. Write Message type ZSALMES , Basic type ZSALIDOC and Release 46C(version of your basis

component).

31. Save it or create request of it.

32. Now send your request in 1 shot in your receiving system(200 client). So you don’t need to

create all Segments, Basic idoc type and message type in another client.

B. An Outbound (Selection or Executable) program for generating Idocs

1. Write an executable program in SE38.

2. Give Program name ZKIN_SALES_IDOC, and create it.

Coding of this report is given at the end of the document.

3. Provide the selection screen for

i. Key for Application Document.

- Select option for Customer Number

- Select option for Sales document Number

ii. Message type

- Parameter for Message Type (EDIDC-MESTYP)

iii. Logical system name (Destination System)

-Parameter for Logical System name (EDIDC-RCVPRT)

iv. Destination(Receiving) System

- Parameters for Destination system (EDIDC-RCVPRN)

Note : Code of program is given at the end of document.

.

C. ALE Configuration in sending System

1. SET GLOBAL PARAMETERS

1. To set global parameters in sending system go to WE46.

2. Click on Change icon

3. Select the recipient type for the user (The user to be notified when an

IDOC error occurs.)

4. Select the identification of the user as user id.

5. Enter maximum numbers of syntax errors

6. Click on Save.

7. But once you have configured it, don’t need to do it again.

2. COMMUNICATION SETTINGS

NOTE – Consult your BASIS ADMIN to do these settings.

Go to T-Code SALE.

1. Maintain logical system

1. Click on the node ‘Sending and receiving system’

2. Click on ‘Logical system’ node

3. Double click on ‘Define logical system’.

4. It will display below screen.

5. Click on ‘New Entries’.

6. Enter ‘Logical System’ and its name

7. Click on ‘Save’

2. Assigning Client to the Logical System

1. Click on the node ‘Sending and receiving system’. (SALE)

2. Click on ‘Logical system’ node

3. Double click on ‘Assign client to the logical system’.

4. It shows below screen.

5. Click on ‘New Entries’.

6. Enter the values of client for Logical system

7. Click on ‘Save’.

3. Setting RFC destination

1. Go to SM59.

(Double click on 200 client)

2. Click on ‘Create’

3. Enter Value for ‘RFC Destination’ . It is advised to give the logical name of the

remote system.

4. Select ‘Connection type’ - 3-R/3 connection

5. Target host , Enter the system number, Description , User Id, Client, Password,

Language.

6. Click on ‘Save’ and ‘Test the connection’.

7. Create RFC destination for Each remote system.

8. But if your receiving system is already created, and if you find it in your connect

type so just double click on it.

9. Here double click on our receiving system which is 200 client.

10. Every fields are already filled up.

11. Just click on Remote Logon, and test , does it log in as 200 client.

12. If yes means it works properly.

4. Port definition

1. To define port go to WE21.

2. Select ‘Transactional RFC’ node

3. Click on ‘Create’ and ‘Generate Port number Automatically’

4. Enter Short Text and ‘RFC Destination’

5. Click on ‘Save’

6. If port for 200 is already Generated then don’t need to create it again.

5. Maintain Customer Model

1. To maintain customer model go to BD64.

2. Click on ‘Change’ .

3. Click on ‘Create Model view’.

4. Enter the Short Text and Technical Name for the Model View

5. Click ‘Continue’

6. Select the Model view created and click on ‘Add Message type’.

7. Select the Logical name for sender and receiver.

8. Type message type ZSALMES.

9. Click on ‘Continue’ and ‘Save’.

6. Generating Partner Profile

1. Select the Model View ‘CUST MODEL FOR SALES’ in BD64. (Either go to BD82.)

2. Go to Environment in menu bar and click on Generate partner profiles.

3. In the next screen enter partner system name 200.

4. Execute it.

5. It will display below screen. And shows your message type as outbound

parameters.

(Shows message type)

6. To check your profile is generated or not, go to WE20.

7. Open partner type LS, double click on receiving system number (200).

8. You can check in outbound parameters table that ZSALMESS is already added there.

7. Distributing the Customer Model

1. To distribute customer model again go to BD64.

2. Select the Model View

3. Go to Edit -> Model View -> Distribute.

4. It opens Distribute Model View window, click continue.

INBOUND PROCESS

Inbound process has been done in receiving system. In our scenario we will do in 200

client.

D. An Inbound (Posting) program for Posting IDOCS

1. The posting program is Function Module.

2. Create a function module in SE37 for your posting program.

Include in the source code include type ‘MBDCONWF’ .

3. Maintain the naming convention of the function module as

Z_IDOC_INPUT_<MESSAGE TYPE>

So, we will create function module with the name,

Z_IDOC_INPUT_ZSELMES

Note : Code of FUNCTION MODULE is given at the end of document.

.

E. Settings in receiving system

Note : The basic IDOC type, Message type should be transported from the sending system

to the receiving system else create the same in the sending system also.

This is not necessary for SAP Standard message type.

1. Basic Settings for Global parameters

2. Communication Settings

3. Generate Partner Profile

(Follow the same procedure as described in Sending System)

4. Allocate the Function Module (Posting Program) to logical message

1. To allocate function module go to WE57.

2. Click on change icon, click on New entries.

3. Enter the Function Module name, Type F, Basic Type as Basic IDOC type and

Message type. give Direction as 2.

4. Save it. Go back and again save it.

5. Check your function module is there is the list of allocated function modules.

5. Define the settings for inbound function mode

1. To define input method for function module, go to BD51.

2. Click on New entries.

3. Give Function module name ‘Z_IDOC_INPUT_ZSALMES’.

4. Give Input method as value 2.

5. Save it. Go back. Again save it.

6. Create a process code

1. To create process code, go to WE42.

2. Click on change icon.

3. Click on New Entries.

4. Write Process code name ZPCSAL in process code.

5. Give description.

6. Select Processing type as Processing by function module.

7. Now give function module name and click on save button.

8. It will jump you to below screen.

9. Select your function module from function module list.

10. Save it.

11. Now double click on Logical message. It will jump you to screen.

12. In the Assignment of logical message, give Message type name ZSALMES.

13. Click on ‘Save’

.

F. Send Idoc

1. Go to sender system(100 Client), run ZKIN_SALES_IDOC (selection program). Give

Proper value in parameters. If it shows message IDOC GENERATED NO XXXXXXX .

Means your IDOC has been and sent to receiving system.

It shows message like below. Note this No.

2. Go to BD75 and just press F8, it will show you that 1 IDOC has been sent.

3. Go to WE19, give No. of your IDOC generated in first IDOC no field, press F8.

4. It will show you below screen.

5. Click on ‘standard outbound processing’ tab and again press enter, it will show

you IDOC sent through tRFC.

6. It shows all records in segments, in above figure.

7. Go to WE02 T-Code. Press F8 and check your IDOC has been sent or not, if your

IDOC shows red light, so there is some error. If you get yellow light so there is

some warning and if you get green light means your IDOC has been sent.

Otherwise, it will give you status 12 and green light , that your idoc has been

dispached ok.

8. Receive Idoc

1. Go to receiving system (200), go to WE02 T-Code and check your IDOC is there

or not. Again the same status for for this IDOCs. Green for successfully received,

yellow for warning and red shows error.

2. If it shows error click on status it displays what error is there. Read it and solve

it.

3. Or it it shows green light means, your data has been saved in your database.

Go to SE11 and check new records are there?

EXECUTABLE / SELECTION PROGRAM (SENDING SYSTEM)

1. Go to SE38 and create program with name ZKIN_SALES_IDOC.

2. Create an executable program.

3. Code.

REPORT ZKIN_SALES_IDOC MESSAGE-ID YM.

  • PURPOSE OF REPORT *

  • Generating an Idoc through this report for Customer Master, Sales *

  • Master and Sales item table. *

  • This Idoc contains all data of these three tables *

  • Start of Program *

************************TABLE-DECLARATION****************************

TABLES : ZCUSTHEAD, "Cutomer Header

ZSALHEAD, "Sales Header

ZSALITEM. "Sales Item

************************STRUCTURE-DECLARATION************************

DATA : S_CONTROL_RECORD LIKE EDIDC, "Idoc Control Record

S_Z1SEGMENT1 LIKE Z1SEGMENT1, "CUSTOMER Header Data

S_Z1SEGMENT2 LIKE Z1SEGMENT2, "SALES HEADER Data

S_Z1SEGMENT3 LIKE Z1SEGMENT3. "SALES Detail Data

**********************ITAB-DECLARATION*******************************

DATA : T_ZCUSTHEAD LIKE ZCUSTHEAD OCCURS 0 WITH HEADER LINE.

DATA : T_ZSALHEAD LIKE ZSALHEAD OCCURS 0 WITH HEADER LINE.

DATA : T_ZSALITEM LIKE ZSALITEM OCCURS 0 WITH HEADER LINE.

DATA : T_EDIDD LIKE EDIDD OCCURS 0 WITH HEADER LINE.

"Data Records

DATA : T_COMM_IDOC LIKE EDIDC OCCURS 0 WITH HEADER LINE.

"Generated Communication IDOc

*********************VARIABLE-DECLARATION****************************

  • ---------> Segment Name <----------

CONSTANTS :

C_Z1SEGMENT1 LIKE EDIDD-SEGNAM VALUE 'Z1SEGMENT1',

C_Z1SEGMENT2 LIKE EDIDD-SEGNAM VALUE 'Z1SEGMENT2',

C_Z1SEGMENT3 LIKE EDIDD-SEGNAM VALUE 'Z1SEGMENT3'.

  • ---------> Idoc Type <----------

CONSTANTS: C_ZMINTEST_IDOC_TYPE LIKE EDIDC-IDOCTP VALUE 'ZSALIDOC'.

***************************INPUT-FIELDS******************************

SELECT-OPTIONS : S_KUNNR for zcusthead-kunnr,

S_VBELN for zsalhead-vbeln.

PARAMETERS :

C_MESTYP LIKE EDIDC-MESTYP DEFAULT 'ZSALMES',

"Message Type ( zemp )

C_RCVPRT LIKE EDIDC-RCVPRT DEFAULT 'LS',

"Partner type of receiver

C_LOGSYS LIKE EDIDC-RCVPRN DEFAULT '200'.

"Destination System

************************START-OF-SELECTION****************************

START-OF-SELECTION.

PERFORM FETCH_CUSTHEADER.

PERFORM FETCH_SALESHEADER.

PERFORM FETCH_SALESITEM.

PERFORM CONTROL_REC.

PERFORM MASTER_IDOC_DISTRIBUTE.

END-OF-SELECTION.

  • FORMS-OF-ALL-PERFORMS *

--


FETCH_CUSTHEADER--

FORM FETCH_CUSTHEADER.

SELECT *

FROM ZCUSTHEAD

INTO TABLE T_ZCUSTHEAD

WHERE KUNNR IN S_KUNNR.

IF SY-SUBRC NE 0.

MESSAGE I000.

ENDIF.

LOOP AT T_ZCUSTHEAD.

S_Z1SEGMENT1-KUNNR = T_ZCUSTHEAD-KUNNR.

S_Z1SEGMENT1-NAME1 = T_ZCUSTHEAD-NAME1.

S_Z1SEGMENT1-ADD1 = T_ZCUSTHEAD-ADD1.

S_Z1SEGMENT1-REGIO = T_ZCUSTHEAD-REGIO.

T_EDIDD-SEGNAM = C_Z1SEGMENT1.

T_EDIDD-SDATA = S_Z1SEGMENT1.

APPEND T_EDIDD.

CLEAR T_EDIDD.

ENDLOOP.

ENDFORM. " FETCH_CUSTHEADER

*----


--


FETCH_SALESHEADER--

FORM FETCH_SALESHEADER.

SELECT *

FROM ZSALHEAD

INTO TABLE T_ZSALHEAD

WHERE VBELN IN S_VBELN.

IF SY-SUBRC NE 0.

MESSAGE I001.

ENDIF.

LOOP AT T_ZSALHEAD.

S_Z1SEGMENT2-VBELN = T_ZSALHEAD-VBELN.

S_Z1SEGMENT2-KUNNR = T_ZSALHEAD-KUNNR.

T_EDIDD-SEGNAM = C_Z1SEGMENT2.

T_EDIDD-SDATA = S_Z1SEGMENT2.

APPEND T_EDIDD.

CLEAR T_EDIDD.

ENDLOOP.

ENDFORM. " FETCH_SALESHEADER

*----


--


FETCH_SALESITEM--

FORM FETCH_SALESITEM.

SELECT *

FROM ZSALITEM

INTO TABLE T_ZSALITEM

WHERE VBELN IN S_VBELN.

IF SY-SUBRC NE 0.

MESSAGE I001.

ENDIF.

LOOP AT T_ZSALITEM.

S_Z1SEGMENT3-VBELN = T_ZSALITEM-VBELN.

S_Z1SEGMENT3-POSNR = T_ZSALITEM-POSNR.

S_Z1SEGMENT3-MATNR = T_ZSALITEM-MATNR.

S_Z1SEGMENT3-ZMENG = T_ZSALITEM-ZMENG.

S_Z1SEGMENT3-NETWR = T_ZSALITEM-NETWR.

T_EDIDD-SEGNAM = C_Z1SEGMENT3.

T_EDIDD-SDATA = S_Z1SEGMENT3.

APPEND T_EDIDD.

CLEAR T_EDIDD.

ENDLOOP.

ENDFORM. " FETCH_SALESITEM

*----


--


CONTROL_REC--

FORM CONTROL_REC.

*--


> Control Record Of IDOC <--


S_CONTROL_RECORD-MESTYP = C_MESTYP. "Message type

S_CONTROL_RECORD-IDOCTP = C_ZMINTEST_IDOC_TYPE. "Basic IDOC type

S_CONTROL_RECORD-RCVPRT = C_RCVPRT. "Partner type of receiver

S_CONTROL_RECORD-RCVPRN = C_LOGSYS. "Partner number of receiver

ENDFORM. " CONTROL_REC

*----


--


MASTER_IDOC_DISTRIBUTE--

FORM MASTER_IDOC_DISTRIBUTE.

*--


> Pass Control To The ALE Layer <--


  • (Application Interface To the ALE Layer On Outbound Processing Side )

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

MASTER_IDOC_CONTROL = S_CONTROL_RECORD

TABLES

COMMUNICATION_IDOC_CONTROL = T_COMM_IDOC

MASTER_IDOC_DATA = T_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 NE 0.

MESSAGE I002.

ELSE.

LOOP AT T_COMM_IDOC.

WRITE:/ 'IDOC Generated : No ', T_COMM_IDOC-DOCNUM.

ENDLOOP.

ENDIF.

ENDFORM. " MASTER_IDOC_DISTRIBUTE

----


POSTING PROGRAM / FUNCTION MODULE (RECEIVING SYSTEM)

1. Create function module in receiving system.

2. Go to SE37 create function module named, ‘Z_IDOC_INPUT_ZSALMES’.

3. Change ATTRIBUTES, in process type make it Remote Function Call.

4. Make changes in IMPORT, and add parameters.

Parameter Type Type Spec. Reference Type Pass Value

INPUT_METHOD LIKE BDWFAP_PARINPUTMETHD

v

MASS_PROCESSING LIKE BDWFAP_PARMASS_PROC

v

5. Make changes in EXPORT, and add parameters.

Parameter Type Type Spec. Reference Type Pass Value

WORKFLOW_RESULT LIKE BDWF_PARAMRESULT

v

APPLICATION_VARIABLE LIKE BDWF_PARAMAPPL_VAR

v

IN_UPDATE_TASK LIKE BDWFAP_PARUPDATETASK

v

CALL_TRANSACTION_DONE LIKE BDWFAP_PARCALLTRANS

v

6. Make changes in Tables.

Parameter Type Type Spec. Reference Type Pass Value

IDOC_CONTRL LIKE EDIDC v

IDOC_DATA LIKE EDIDD v

IDOC_STATUS LIKE BDIDOCSTAT v

RETURN_VARIABLES LIKE BDWFRETVAR v

SERIALIZATION_INFO LIKE BDI_SER v

7. Make changes in Exception

Exception Short text

WRONG_FUNCTION_CALLED

8. Source Code

FUNCTION Z_IDOC_INPUT_ZSALMES.

*"----


""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

*"----


*FUNCTION Z_IDOC_INPUT_ZMATER .

----


  • Author : *

----


  • Include File that contains ALE constants

INCLUDE MBDCONWF.

  • DATABASE TABLE

TABLES : ZCUSTHEAD,

ZSALHEAD,

ZSALITEM.

  • DATA DECLARATION

*--


> Structure <--


DATA : W_SEGNAM1 LIKE Z1SEGMENT1,

W_SEGNAM2 LIKE Z1SEGMENT2,

W_SEGNAM3 LIKE Z1SEGMENT3.

*--


> Internal Table <--


DATA : T_ZCUSTHEAD LIKE ZCUSTHEAD OCCURS 0 WITH HEADER LINE.

DATA : T_ZSALHEAD LIKE ZSALHEAD OCCURS 0 WITH HEADER LINE.

DATA : T_ZSALITEM LIKE ZSALITEM OCCURS 0 WITH HEADER LINE.

  • PROGRAM LOGIC

*--


> Initialize Work Flow Result<--


WORKFLOW_RESULT = C_WF_RESULT_OK.

LOOP AT IDOC_CONTRL.

IF IDOC_CONTRL-MESTYP NE 'ZSALMES'.

RAISE WRONG_FUNCTION_CALLED.

ENDIF.

*Before reading a new employee clear application buffer

LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.

CASE IDOC_DATA-SEGNAM.

WHEN 'Z1SEGMENT1'.

W_SEGNAM1 = IDOC_DATA-SDATA.

MOVE-CORRESPONDING W_SEGNAM1 TO T_ZCUSTHEAD.

INSERT INTO ZCUSTHEAD VALUES T_ZCUSTHEAD.

WHEN 'Z1SEGMENT2'.

W_SEGNAM2 = IDOC_DATA-SDATA.

MOVE-CORRESPONDING W_SEGNAM2 TO T_ZSALHEAD.

INSERT INTO ZSALHEAD VALUES T_ZSALHEAD.

WHEN 'Z1SEGMENT3'.

W_SEGNAM3 = IDOC_DATA-SDATA.

MOVE-CORRESPONDING W_SEGNAM3 TO T_ZSALITEM.

INSERT INTO ZSALITEM VALUES T_ZSALITEM.

ENDCASE.

ENDLOOP.

  • CUSTOMER HEADER *

SELECT *

FROM ZCUSTHEAD.

ENDSELECT.

IF SY-SUBRC NE 0.

INSERT INTO ZCUSTHEAD VALUES T_ZCUSTHEAD.

ELSE.

UPDATE ZCUSTHEAD FROM T_ZCUSTHEAD.

ENDIF.

IF SY-SUBRC EQ 0.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '53'.

IDOC_STATUS-MSGTY = 'I'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '004'.

IDOC_STATUS-MSGV1 = T_ZCUSTHEAD-KUNNR.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

ELSE.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '51'.

IDOC_STATUS-MSGTY = 'E'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '005'.

IDOC_STATUS-MSGV1 = T_ZCUSTHEAD-KUNNR.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

WORKFLOW_RESULT = C_WF_RESULT_ERROR.

RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.

RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

APPEND RETURN_VARIABLES.

CLEAR RETURN_VARIABLES.

ENDIF.

  • SALES HEADER *

SELECT *

FROM ZSALHEAD.

ENDSELECT.

IF SY-SUBRC NE 0.

INSERT INTO ZSALHEAD VALUES T_ZSALHEAD.

ELSE.

UPDATE ZSALHEAD FROM T_ZSALHEAD.

ENDIF.

IF SY-SUBRC EQ 0.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '53'.

IDOC_STATUS-MSGTY = 'I'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '004'.

IDOC_STATUS-MSGV1 = T_ZSALHEAD-VBELN.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

ELSE.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '51'.

IDOC_STATUS-MSGTY = 'E'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '005'.

IDOC_STATUS-MSGV1 = T_ZSALHEAD-VBELN.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

WORKFLOW_RESULT = C_WF_RESULT_ERROR.

RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.

RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

APPEND RETURN_VARIABLES.

CLEAR RETURN_VARIABLES.

ENDIF.

  • SALES ITEM *

SELECT *

FROM ZSALITEM.

ENDSELECT.

IF SY-SUBRC NE 0.

INSERT INTO ZSALITEM VALUES T_ZSALITEM.

ELSE.

UPDATE ZSALITEM FROM T_ZSALITEM.

ENDIF.

IF SY-SUBRC EQ 0.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '53'.

IDOC_STATUS-MSGTY = 'I'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '004'.

IDOC_STATUS-MSGV1 = T_ZSALITEM-VBELN.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

ELSE.

IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

IDOC_STATUS-STATUS = '51'.

IDOC_STATUS-MSGTY = 'E'.

IDOC_STATUS-MSGID = 'YM'.

IDOC_STATUS-MSGNO = '005'.

IDOC_STATUS-MSGV1 = T_ZSALITEM-VBELN.

APPEND IDOC_STATUS.

CLEAR IDOC_STATUS.

WORKFLOW_RESULT = C_WF_RESULT_ERROR.

RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.

RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

APPEND RETURN_VARIABLES.

CLEAR RETURN_VARIABLES.

ENDIF.

ENDLOOP.

ENDFUNCTION. " IDOC_STATUS_INPUT_ZEMP

This will surely help you out.

Regards,

DS

Read only

0 Likes
668

Hi DS,

Thanks for replying. it was informative for sure. but i have specified that i need to create IDoc using ALE and not EDI.

Hope u could help me in that regard.

Regards,

Jose