IDOC instance, IDOC for message mode

Source: Internet
Author: User
In the system, we often see the EDI output, which is similar to the print output. Next we will briefly explain the IDOC output based on the article "IDOC instance, outbound IDOC. 1. Create a function: y_idoc_po_send. This is our outbound funtion module used to create the IDOC content. Similarly, the interfaces of this function are standard. In the tcode we41 that will be introduced below, you can view the existing similar functions of the system. You can refer to setting our function interfaces. Then write the following code: Data: ls_pohead type ypohead,
Ls_poitem type ypoitem,
Ls_ekko type Ekko,
Lt_ekpo type table of Ekpo with header line. * control_record_out
Clear control_record_out.
Move control_record_in to control_record_out.
* Control_record_out-mestyp = 'ypo'. "Message Type
* Control_record_out-idoctp = 'policdoc '. "IDOC type
Control_record_out-direct = '1 '.
Control_record_out-serial = sy-datum.
Control_record_out-serial + 8 = sy-uzeit. * read from Ekko/Ekpo
Clear ls_ekko.
Select single *
Into ls_ekko
From Ekko
Where ebeln = Object-objky (10) "purchase order No.
And loekz = space.
If sy-subrc <> 0.
Raise error_message_received.
Endif. Refresh lt_ekpo.
Select *
Into Table lt_ekpo
From Ekpo
Where ebeln = ls_ekko-ebeln
And loekz = space. * int_edidd
Clear int_edidd.
Int_edidd-docnum = control_record_out-docnum.
Int_edidd-segnam = 'ypohead'. "node name
Int_edidd-dtint2 = 0.
Clear ls_pohead.
Ls_pohead-ebeln = ls_ekko-ebeln.
Ls_pohead-bukrs = ls_ekko-bukrs.
Ls_pohead-bedat = ls_ekko-bedat.
Int_edidd-sdata = ls_pohead. "node content
Append int_edidd. Loop at lt_ekpo.
Clear int_edidd.
Int_edidd-docnum = control_record_out-docnum.
Int_edidd-segnam = 'ypoitem '.
Int_edidd-dtint2 = 0.
Clear ls_poitem.
Ls_poitem-ebeln = lt_ekpo-ebeln.
Ls_poitem-ebelp = lt_ekpo-ebelp.
Ls_poitem-matnr = lt_ekpo-matnr.
Ls_poitem-menge = lt_ekpo-menge.
Ls_poitem-meins = lt_ekpo-meins.
Int_edidd-sdata = ls_poitem.
Append int_edidd.
Endloop. 2, we41, create outbound process code to enter the editing status, select the "Add new entry" button to create yposend, which corresponds to the newly created y_idoc_po_send. Select the following process with ale service, which means that outbound IDOC is automatically sent to the receiver after being created. 3. NACE/NACO: Create an EDI output for the output type. Set "program" to "rsnasted" and "form routine" to "edi_processing. Of course, we can also find an existing EDI output type here for testing, such as xx01 under application EF. 4. we20 sets the partner profile. In the first two articles, we did not require the partner function, but this time it is required. The partner function is subordinate to the partner type. This logical relationship is embodied in the TPAR table. Suppose we select partner type = LS and partner function = ls. Its maintenance is similar to the previous one. Click the plus sign to add an outbound parameter. The procedure is similar to the previous one. However, you must remember to add a line in message control, application = EF, message type = xx01, the Process Code is yposend. Here EF and xx01 correspond to the definition in NACO above. 5. Send IDOC. In fact, we have defined it. You can maintain the output type of a purchase order to send IDOC. For better understanding, we will imitate this output process. Create a new program and write: tables: Nast.
Data: RCODE type I. Clear Nast.
Nast-kappl = 'ef '.
Nast-objky = '000000'. "purchase order No.
Nast-kschl = 'xx01 '.
Nast-parnr = 'i02ls'. "partner number
Nast-parvw = 'LS'. "partner Function
Perform edi_processing (rsnasted) using RCODE 'x'. If RCODE is initial.
Commit work. "The method used to send IDOC to the receiver endif. Does not leave output records in Nast. If you want to keep a record in Nast, you should: tables: Nast.
Data: RCODE type I. Clear Nast.
Nast-kappl = 'ef '.
Nast-objky = '000000 '.
Nast-kschl = 'xx01 '.
Nast-parnr = 'i02ls '.
Nast-parvw = 'LS '.
Nast-spras = sy-Langu.
Nast-erdat = sy-datum.
Nast-eruhr = sy-uzeit.
Nast-Nacha = '6'. "EDI
Nast-AnZal = 0.
Nast-usnam = sy-uname.
Perform einzelnachricht (rsnast00) using RCODE. If RCODE is initial.
Commit work. "Send IDOC to the receiver endif. This method can also be used to trigger other types of output, such as print output.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.