SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

ELECTRONIC DATA INTERCHANGE (EDI)



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Thu Jun 26, 2008 12:01 pm    Post subject: ELECTRONIC DATA INTERCHANGE (EDI) Reply with quote

ELECTRONIC DATA INTERCHANGE (EDI)
Author: ANANTH GOWRI SANKAR PATURU

EDI: It is the electronic exchange of documents between the computer systems of partners, using a standard format over a communication network.

BENEFITS OF THE EDI PROCESS:

The implementation of EDI benefits both the sender and the receiver. The following things can be minimized with this process:

Reduced data entry errors: EDI does not involve data entry at multiple points. In a regular process, a sender creates an document on the system, prints the document, and then faxes or mails it to the receiver. The receiver then re keys the same information on their computer. With this procedure, data goes directly from one computer to the another without any involvement.

Reduced process cycle time: The biggest advantage is the reduced processing time of the complete cycle. As soon as documents are entered into the system, they can be processed on the receiving side in seconds. There is a considerable savings in the processing time of document transfer.

Availability of data in electronic form. Data from EDI is a electronic form, which makes it easy to share across the organization. For example, a purchasing department can use the data to evaluate vendors, or a marketing department can use the data to analyze the trends and demands of customers.

Reduced cost : The initial cost of an EDI setup is certainly higher compared to the paper process, but over a long period it is very cost effective. In the long term, the overall cost of exchanging business documents in paper form can cost less per transaction.

Standard means of communication: Because EDI enforces standards on the contents of data, uniform naming standards and field sizes have emerged. Such consistency leads to clearer communication and less ambiguity.

IMPLEMENTATION:

EDI can be implemented in two process:
1) Outbound Process.
2) Inbound process.

Outbound process : In this process, we create the document, and the document is transmitted to the Operating system layer and it is transmitted over a TCP/IP network.

The outbound process has some specifications and standards which has to be done before transmitting the document.

The outbound process uses:
1) IDOC types
2) selection programs.
3) Message control.
4) Partner profiles.
5) Port Definitions
6) Service Programs.
7) Tables to generate an IDOC.

1) IDOC types: The EDI document to be generated has an equivalent message type defined in the SAP system. The message type is based on an IDOC structure. As an example, if an EDI transaction of 850, which is a purchase order, is to be generated, the message type ORDERS is assigned to it. This message is based on IDOC type ORDERS01 and ORDERS02. The IDOC type is the most important component in the EDI process.

2) Selection programs: These are typically implemented as function modules, which are designed to extract application data and create an IDOC. A selection program exists for each message type. The programs are generally named with the following naming convention:
IDOC_OUTPUT_<message type>

In my project, the selection program for message type ORDERS is IDOC_OUTPUT_ORDERS. A four character process code, ME10, has been assigned to this function module. The list of outbound process codes and their corresponding function modules can find with the transaction :

T-code : WE41.

3) Message control: It is used in pricing, account determination, material determination, and output determination. The message control component enables to encapsulate business rules without having to write programs. In the EDI process, Message control determines and processes the various outputs associated with an application document.

4) Port Definition : A port is used in the outbound process to determine the name of the EDI subsystem program, the directory path where the IDOC file will be created at the operating system level, the IDOC file names, and the RFC destination.

5) Partner profiles: The partner profiles specifies the various components used in the outbound process, the mode in which it communicates with the subsystem and the person to be notified in case of errors.

6) Service programs and Configuration tables: The asynchronous outbound process can be seen as a sequence of several processes that work together. In this service programs and configuration tables are used to link the process. The process flow for the outbound process describes the role played by each service program and configuration table.

INBOUND PROCESS: The inbound process uses the following components to post and application document from the IDOC:

1) IDOC type.
2) Port Definition.
3) Posting programs
4) Service programs.
5) configuration tables.

All the things described above are the same except for the posting programs.

Posting programs: These are implemented in the system as function modules. A posting program exists for each message type. The posting programs are named with the following naming convention.

IDOC_INPUT<message type>

In my project, the posting program for the message type ORDERS I have taken is IDOC_INPUT_ORDERS. A four- character process code, ORDE, has been assigned to this function module. The list of inbound process codes and their corresponding function modules by executing the following transaction.

T-CODE : WE42.

With the above specifications, I have configured the following things before actually start working on the interchange process :

1) Configuration of Port Definition.
2) Configuration of Partner Profiles.
3) Assigning number range and selection of IDOC.
4) Assigning organization and user.
5) Setting up RFC destination.
6) Creation of Purchasing document.
7) Creation of receiving fields information.

1.Configuration of Port Definition:

In this section, we provide the complete details about the subsystem, the outbund file and the function module we are using, the status file, which tells about the status of the IDOC.

Transaction Code: WE21.


For EDI process, the port that is used is the FILE port.

Transaction RFC’s are used for ALE applications.
Internet port is used for internet applications.
XML port is used for XML applications.

This is a very important step in the whole process, because all the outbound, inbound and status files are stored in the port definitions.

2. Configuration of Partner Profiles:

It is important to maintain the profiles of each partner in the business scenario with whom we exchange our business documents.


TRANSACTION : WE20.

There are three views of a partner profile in which different parameters can be entered as a partner :

General Parameters view : These values are stored in table EDPP1.

In this view, it contains very basic information about the partner, such as partner number, partner type, and default individual to notify in case an error occurs. These partner attributes appear at the top of the main partner profiles screen and under the post processing : permitted agent and classification tabs.



Partner number: In EDI, the partner number is a customer number or bank ID. In this case, I have taken my student number(573097) as my partner number.

Partner type: The partner type represents the type of our business partner. In this case, I have taken type as customer(KU).

Assigning number range and selection of IDOC: This is done by the following transaction. This is very important in every EDI applications because it will be a big problem if two IDOC’s are assigned a same value.

T- Code : WE46.


Setting up RFC destination : Every transaction that is transmitted over a network must know the destination point before it is transmitted. This is done by using the Remote Function Call called as RFC. The program called SERVER_EXEC is selected for TCP/IP connections.

The transaction code used for this process is : SM59.

This program starts an application on the server and establishes a network between the two systems.



Creation of application document:

T-code : ME11.

In my project, I have taken a purchasing order as the application document and created all the required fields in the document and saved. As soon as the application document is saved, it fills all the details in the database tables.



The yellow state in the output screen tells that the document is saved without any errors.

Creation of receiving fields information:

For every transaction, the receiver information must be entered for every transaction.

This can be done with the following transaction.

T-code : XD02.

The receiver fields are the most critical in the EDI transaction. If there is something wrong in the information, the application document is transmitted and the acknowledge is given to the sender. But before the transmission, the receiver is notified that the information is available and waits for the permission whether it is ready to share.

In this way, all the fields in the receiver section should be filled before actually sending the document.

THE FOLLOWING STEPS ARE DONE FOR THE SUCCESSFUL TRANSMISSION OF EDI DOCUMENT:

STEP 1:

DEFINING THE GLOBAL PARAMETERS FOR IDOC:

Transaction Code: WE47.

In order an Idoc to be transmitted, it should be first assigned so that all application components can identify the type of Idoc.

This can be done by giving the administrator name and it’s type.

CONFIGURING THE PARTNER PROFILES:

Transaction code : WE20.

I have created a partner profiles with

Partner number : 123 (ANANTH GOWRI SANKAR PATURU)

Partner type : Customer.

OUTBOUND PARAMETERS:

Message type : ORDRSP.

Receiver port : SUBSYSTEM (because all my transactions are residing in my R/3).

Idoc type : ORDERS05

Application : EF (which is the message type supported for this application ).

Process code : SD10 ( Every transaction of this message type for outbound process needs a process code SD10).

INBOUND PARAMETERS:

Message type : ORDERS.

Receiver port : SUBSYSTEM (because all my transactions are residing in my R/3).

Idoc type : ORDERS05

Application : EF (which is the message type supported for this application ).

Process code : ORDE ( Every transaction of this message type for inbound transaction needs a process code ORDE).

In the same way for the receiving end,

Partner number : 3030 (AIR PARTS)

Partner type : vendor.

OUTBOUND PARAMETERS:

Message type : ORDRSP.

Receiver port : SUBSYSTEM (because all my transactions are residing in my R/3).

Idoc type : ORDERS05

Application : EF (which is the message type supported for this application ).

Process code : ME10 ( Every transaction of this message type for outbound process needs a process code ME10).

INBOUND PARAMETERS:

Message type : ORDRSP.

Receiver port : SUBSYSTEM (because all my transactions are residing in my R/3).

Idoc type : ORDERS05

Application : EF (which is the message type supported for this application ).

Process code : ORDR ( Every transaction of this message type for inbound transaction needs a process code ORDE).

CONFIGURING THE RFC DESTINATION :

Transaction Code : SM59.

In the settings of the RFC destination being used in the process, I have taken the destination type as SERVER_EXEC because it is the only one that supports the R/3 system for the version.

CONFIGURING THE PORT DEFINITION :

Transaction Code : WE21.

In the port definition I have taken FILE as the port because it is the only port that supports this EDI transaction. In the port definition, all the outbound process and inbound process are stored in a specific location.

CREATION OF APPLICATION DOCUMENT:

Transaction Code : MK01.

This is the most typical part in the program :

I have created an application document with the above profiles of the sending and the receiver information.

The details are as follows:

Vendor : 3030 (Air parts)

Purchasing organization : 3000. (IDES USA)

Customer : 123 (Ananth gowri sankar paturu).

Material Description : R300.

As soon as the document is saved the Idoc is generated from the NAST table by storing the application document.

CONFIRMATION NUMBER FOR THE APPLICATION DOCUMENT : 4500008604.

CHECKING FOR THE SUCCESSFUL CREATION OF APPLICATION DOCUMENT:

Transaction Code : MK23.

By giving the confirmation number of the application document, the purchase order transaction can be confirmed.

CONFIRMING THE APPLICATION DOUMENT ENTRIES IN THE DATABASE:

Transaction Code : SE16.

By typing the table name NAST in the table entry we can view all the details of the application document.

WRITING A PROGRAM FOR THE VALIDITY OF SENDING AND RECEIVING PROFILES AND GENERATION OF Idoc FOR THE DATA THAT IS SAVED IN THE APPLICATION DOCUMENT :

Transaction Code : SE38.

Program Name :

Database Tables I have used in my program : edpp1, edkp1, eddp1,edk12, edk13, edk21,tede1, tede2, edmat, edmsg, edimsg.

Outbound Parameters Tables : EDPP1

Inbound Parameters Tables : EDP12,EDP13,EDP21.

By retrieving the data from the above tables which are storing the values of the application document and receiving , sending profiles by using SELECT statements, SUBROUTINES , FUNCTION MODUELES , the following things are executed.

VALIDITY OF THE PARTNER PROFILES.
GENERATION OF IDOC.
CORRECT PORT ASSIGNMENT.
GIVING A PROPER ERROR MESSAGE.

VERIFICATION OF IDOC:
Transaction Code : WE02.

VERIFICATION OF STATUS:

Transaction Code : WE05.

INBOUND PROCESS:

UNPACKING THE IDOC:

Transaction Code : WE19.

I have selected the same idoc which I have used for the outbound process and created a text file called in123.dat and saved the idoc in the current file.

Next, by selecting the function module IDOC_INPUT_MATMAS01, the inbound process flow is started and an incoming Idoc is created in the system.

VERIFICATION OF POSTING OF APPLICATION DOCUMENTS:

Transaction Code: BD87.

With this transaction , the application document is restored.

The final application document is viewed from the current location of the purchase order.

After all the settings are done, the successful posting of an EDI document in the outbound process is done by getting all the details from the data stored in the tables.

Program that I have written to get the details of the partner profiles, port definitions, is ZEFSKFLSDJ.

The flow chart for the complete execution of the process is shown below:

<INSERT DIAGRAMM HIRE>

The following program reads the values of the tables,edpp1, edkp1, eddp1,edk12, edk13, edk21,tede1, tede2, edmat, edmsg, edimsg, where the details of the application document, partner profiles, port definitions, sender and receiver fields and integrates them as a process.

By executing the program, we can tell whether all the fields are correct and any incorrect values should be corrected before executing the next step.

The program is shown as follows
Code:

REPORT zefskflsdj.

* database tables and structures
tables: edpp1, edkp1, eddp1,edk12, edk13, edk21,tede1, tede2, edmat,
edmsg, edimsg.
 
* internal tables and data
data: i_edpp1 like edpp1 occurs 30 with header line,
      i_edp12 like edp12 occurs 50 with header line,
      i_edp13 like edp13 occurs 50 with header line,
      i_edp21 like edp21 occurs 50 with header line.
 
* This is the idoc structure
data: pt_protocol like protstru occurs 30 with header line.
 
DATA: BEGIN OF EDP12_KEY,
        RCVPRN LIKE EDP12-RCVPRN,
        S2     VALUE '/',
         RCVPRT LIKE EDP12-RCVPRT,
         S3     VALUE '/',
        RCVPFC LIKE EDP12-RCVPFC,
         S4     VALUE '/',
        KAPPL  LIKE EDP12-KAPPL,
         S5     VALUE '/',
          KSCHL  LIKE EDP12-KSCHL,
             S6     VALUE '/',
        AENDE  LIKE EDP12-AENDE.
DATA: END OF EDP12_KEY.
 
DATA:  BEGIN OF EDP13_KEY,
        RCVPRN LIKE EDP13-RCVPRN,
          S2     VALUE '/',
         RCVPRT LIKE EDP13-RCVPRT,
        S3     VALUE '/',
        RCVPFC LIKE EDP13-RCVPFC,
        S4     VALUE '/',
        MESTYP LIKE EDP13-MESTYP,
        S5     VALUE '/',
        MESCOD LIKE EDP13-MESCOD,
        S6     VALUE '/',
        MESFCT LIKE EDP13-MESFCT,
        S7     VALUE '/',
        TEST   LIKE EDP13-TEST.
DATA: END OF EDP13_KEY.
 
DATA: BEGIN OF EDP21_KEY,
        SNDPRN LIKE EDP21-SNDPRN,
        S2     VALUE '/',
           SNDPRT LIKE EDP21-SNDPRT,
        S3     VALUE '/',
        SNDPFC LIKE EDP21-SNDPFC,
          S4     VALUE '/',
        MESTYP LIKE EDP21-MESTYP,
        S5     VALUE '/',
        MESCOD LIKE EDP21-MESCOD,
        S6     VALUE '/',
           MESFCT LIKE EDP21-MESFCT,
        S7     VALUE '/',
        TEST   LIKE EDP21-TEST.
DATA: END OF EDP21_KEY.
 
DATA: BEGIN OF EDPP1_KEY,
         PARNUM LIKE EDPP1-PARNUM,
        S2     VALUE '/',
                 PARTYP LIKE EDPP1-PARTYP.
DATA: END OF EDPP1_KEY.
 
data: percentage       type i,
      last_percentage  type i,
      lines            type i,
      rc               like sy-subrc,
      g_name           like sprwr-name.
 
constants: p_error           like protstru-msgty    value 'E',
           p_warning         like protstru-msgty    value 'W',
           p_success         like protstru-msgty    value 'S',
           c_message_id      like protstru-msgid    value 'E1',
           C_TYPE_SEPARATOR  LIKE PROTSTRU-LINETYPE VALUE 'N',
           C_TYPE_MESSAGE    LIKE PROTSTRU-LINETYPE VALUE 'M'.
 
DEFINE ADD_SEPARATOR.
  CLEAR PT_PROTOCOL.
  PT_PROTOCOL-LINETYPE = C_TYPE_SEPARATOR.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
* no variables
DEFINE ADD_MESSAGE_0.
   CLEAR PT_PROTOCOL.
  PT_PROTOCOL-LINETYPE = C_TYPE_MESSAGE.
     PT_PROTOCOL-MSGID = C_MESSAGE_ID.
   PT_PROTOCOL-MSGTY = &1.
   PT_PROTOCOL-MSGNO = &2.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
* one variable
DEFINE ADD_MESSAGE_1.
  CLEAR PT_PROTOCOL.
    PT_PROTOCOL-LINETYPE = C_TYPE_MESSAGE.
   PT_PROTOCOL-MSGID = C_MESSAGE_ID.
    PT_PROTOCOL-MSGTY = &1.
  PT_PROTOCOL-MSGNO = &2.
  PT_PROTOCOL-MSGV1 = &3.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
* two variables
DEFINE ADD_MESSAGE_2.
  CLEAR PT_PROTOCOL.
   PT_PROTOCOL-LINETYPE = C_TYPE_MESSAGE.
  PT_PROTOCOL-MSGID = C_MESSAGE_ID.
  PT_PROTOCOL-MSGTY = &1.
  PT_PROTOCOL-MSGNO = &2.
    PT_PROTOCOL-MSGV1 = &3.
  PT_PROTOCOL-MSGV2 = &4.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
* three variables
DEFINE ADD_MESSAGE_3.
  CLEAR PT_PROTOCOL.
   PT_PROTOCOL-LINETYPE = C_TYPE_MESSAGE.
  PT_PROTOCOL-MSGID = C_MESSAGE_ID.
    PT_PROTOCOL-MSGTY = &1.
   PT_PROTOCOL-MSGNO = &2.
  PT_PROTOCOL-MSGV1 = &3.
   PT_PROTOCOL-MSGV2 = &4.
   PT_PROTOCOL-MSGV3 = &5.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
* four variables
DEFINE ADD_MESSAGE_4.
   CLEAR PT_PROTOCOL.
  PT_PROTOCOL-LINETYPE = C_TYPE_MESSAGE.
     PT_PROTOCOL-MSGID = C_MESSAGE_ID.
   PT_PROTOCOL-MSGTY = &1.
    PT_PROTOCOL-MSGNO = &2.
  PT_PROTOCOL-MSGV1 = &3.
    PT_PROTOCOL-MSGV2 = &4.
  PT_PROTOCOL-MSGV3 = &5.
     PT_PROTOCOL-MSGV4 = &6.
  APPEND PT_PROTOCOL.
END-OF-DEFINITION.
 
select-options: s_parnum for edpp1-parnum,
                s_partyp for edpp1-partyp.
 
parameters:     p_mode(1) type c no-display.
 
* collect all relevant entries from EDPP1 in table I_EDPP1
case p_mode.
  when 'L'.
* select from EDPP1 for every single combination of PARNUM/PARTYP
    loop at s_parnum.
      read table s_partyp index sy-tabix.
      check sy-subrc eq 0.
      select * from edpp1 appending table i_edpp1
                          where parnum eq s_parnum-low
                          and   partyp eq s_partyp-low.
    endloop.
  when others.
* use standard logic to select partners
    select * from edpp1 into table i_edpp1 where parnum in s_parnum
                                           and   partyp in s_partyp.
endcase.
 
if i_edpp1[] is initial.
* no entries found for these select criteria
  perform no_entries.
else.
 
  describe table i_edpp1 lines lines.
 
  loop at i_edpp1.
 
    percentage = 100 * sy-tabix / lines.
    if last_percentage ne percentage.
      perform progress using percentage.
      last_percentage = percentage.
    endif.
 
    refresh: i_edp12,
             i_edp13,
             i_edp21.
 
    move-corresponding i_edpp1 to edkp1.
 
* get all entries for the current partner
    CALL FUNCTION 'EDI_PARTNER_READ_COMPLETE'
         EXPORTING
              REC_EDKP1       = edkp1
         IMPORTING
              REC_EDDP1       = eddp1
         TABLES
              TAB_EDP12       = i_edp12
              TAB_EDP13       = i_edp13
              TAB_EDP21       = i_edp21
         EXCEPTIONS
              DB_ERROR        = 01
              ENTRY_NOT_EXIST = 02.
 
    check sy-subrc eq 0.
 
    add_separator.
    move-corresponding i_edpp1 to edpp1_key.
    add_message_1 P_SUCCESS '105' edpp1_key.
    add_separator.
 
* test EDPP1
    perform test_edpp1.
    add_separator.
* test EDP12
    perform test_edp12.
    add_separator.
* test EDP13
    perform test_edp13.
    add_separator.
* test EDP21
    perform test_edp21.
    add_separator.
 
  endloop.
 
endif.
 
g_name = sy-uzeit.
 
CALL FUNCTION 'DISPLAY_PROTOCOL'
     EXPORTING
          NAME = g_name
     TABLES
          IN   = pt_protocol.
 
 
* Form  NO_ENTRIES
 
*no entries found
 
FORM NO_ENTRIES.
  add_separator.
 
  add_message_0 p_error '101'.
 
  add_separator.
ENDFORM.                               " NO_ENTRIES
 
 
*Form  TEST_EDPP1
 
*test data in EDDP1
* PARNUM    partner number
*  PARTYP    partner type
FORM TEST_EDPP1.
 
  add_message_0 P_SUCCESS '106'.
 
* execute test routine for number and type
  DATA: L_TEDSTSTRUC LIKE TEDSTSTRUC,
        L_RC         LIKE SY-SUBRC,
        L_REPID      LIKE TEDST-REPID,
        L_FORM       LIKE TEDST-ROUTIDREAD.
 
* get access routine from table TEDST
  SELECT SINGLE REPID ROUTIDREAD FROM TEDST
                                 INTO (L_REPID, L_FORM)
                                 WHERE RCVPRT EQ edkp1-partyp.
 
  IF SY-SUBRC EQ 0.
* use external perform to validate PARNUM
* form-routine and report-id are found in TEDST
    CLEAR L_TEDSTSTRUC.
    L_TEDSTSTRUC-PARNUM = EDkP1-PARNUM.
    PERFORM (L_FORM) IN PROGRAM (L_REPID)
            USING L_TEDSTSTRUC
                  L_RC.
    IF L_RC EQ 8.
* PARNUM not found
      add_message_2 p_error '137' edkp1-parnum edkp1-partyp.
    ENDIF.
  ENDIF.
 
* test EDMAT entry (EDPP1-MATLVL)
  select single * from edmat where matlvl eq eddp1-matlvl
                             and   langua eq sy-langu.
 
  if sy-subrc eq 0.
    add_message_0 P_SUCCESS '109'.
  else.
    add_message_1 P_ERROR '110' eddp1-matlvl.
  endif.
 
* test receiver of notifications
  perform test_receiver using eddp1-usrtyp
                              eddp1-usrkey
                              rc.
 
  if rc eq 0.
    add_message_0 P_SUCCESS '107'.
  else.
    add_message_2 P_ERROR '108' eddp1-usrtyp eddp1-usrkey.
  endif.
 
ENDFORM.                               " TEST_EDPP1
 
 
*Form  TEST_RECEIVER
* USRTYP    type of receiver
* USRKEY    receiver's ID
*  RC        returncode
 
FORM TEST_RECEIVER using usrtyp like edpp1-usrtyp
                         usrkey like edpp1-usrkey
                         rc     like sy-subrc.
 
  data: rhobject like rhobjects-object.
  move usrtyp to rhobject.
  move usrkey to rhobject+2.
 
  CALL FUNCTION 'RH_CHECK_ORG_OBJECT_EXISTS'
       EXPORTING
            ACT_OBJECT_EXT       = rhobject
            AUTHORITY_CHECK      = ' '
       EXCEPTIONS
            NO_ACTIVE_PLVAR      = 01
            NO_ORG_OBJECT        = 02
            ORG_OBJECT_NOT_FOUND = 03.
 
  rc = sy-subrc.
 
ENDFORM.                               " TEST_RECEIVER
 
 
*Form  TEST_EDP12
 
*  PARNUM    partner number
*  PARTYP    partner type
 
FORM TEST_EDP12.
 
  if not i_edp12[] is initial.
    add_message_0 p_success '112'.
  endif.
 
  loop at i_edp12.
    move-corresponding i_edp12 to edk12.
    move-corresponding i_edp12 to edp12_key.
 
    add_separator.
    add_message_1 p_success '111' edp12_key.
 
* test if an EDP13 entry exists for the current EDP12 entry
    loop at i_edp13 where            rcvprn eq i_edp12-rcvprn
                               and   rcvprt eq i_edp12-rcvprt
                               and   rcvpfc eq i_edp12-rcvpfc
                               and   mestyp eq i_edp12-mestyp
                               and   mescod eq i_edp12-mescod
                               and   mesfct eq i_edp12-mesfct
                               and   test   eq i_edp12-test.
    endloop.
 
    if sy-subrc eq 0.
      add_message_0 p_success '132'.
    else.
      add_message_0 p_error '133'.
    endif.
 
* test message type
    select single * from edmsg where msgtyp eq i_edp12-mestyp.
 
    if sy-subrc eq 0.
      add_message_0 p_success '113'.
    else.
      add_message_1 p_error '114' i_edp12-mestyp.
    endif.
 
* test outgoing process code
    select single * from tede1 where evcode eq i_edp12-evcoda.
 
    if sy-subrc eq 0.
      add_message_0 p_success '115'.
    else.
      add_message_1 p_error '116' i_edp12-evcoda.
    endif.
 
  endloop.
ENDFORM.                               " TEST_EDP12
 
*Form  TEST_EDP13
* PARNUM    partner number
*  PARTYP    partner type
 
FORM TEST_EDP13.
 
  data: port_type like edipo-porttyp.
 
  if not i_edp13[] is initial.
    add_message_0 p_success '117'.
  endif.
 
  loop at i_edp13.
    move-corresponding i_edp13 to edk13.
    move-corresponding i_edp13 to edp13_key.
 
    add_separator.
    add_message_1 p_success '111' edp13_key.
 
* test if an EDP12 entry exists for the current EDP13 entry
    loop at i_edp12 where            rcvprn eq i_edp13-rcvprn
                               and   rcvprt eq i_edp13-rcvprt
                               and   rcvpfc eq i_edp13-rcvpfc
                               and   mestyp eq i_edp13-mestyp
                               and   mescod eq i_edp13-mescod
                               and   mesfct eq i_edp13-mesfct
                               and   test   eq i_edp13-test.
    endloop.
 
    if sy-subrc eq 0.
      add_message_0 p_success '134'.
    else.
      add_message_0 p_warning '135'.
    endif.
 
* test port
    CALL FUNCTION 'EDI_PORT_READ'
         EXPORTING
              PORTNAME       = i_edp13-rcvpor
         IMPORTING
              TYP            = port_type
         EXCEPTIONS
              PORT_NOT_EXIST = 1
              OTHERS         = 2.
 
    if sy-subrc eq 0.
      add_message_0 p_success '118'.
    else.
* no port found
      clear port_type.
      add_message_1 p_error '119' i_edp13-rcvpor.
    endif.
 
* test package size for the current port
    if port_type eq '1' and i_edp13-pcksiz le 0.
 
      if i_edp13-pcksiz is initial.
        add_message_1 p_error '120' '0'.
      else.
        add_message_1 p_error '120' i_edp13-pcksiz.
      endif.
 
    endif.
 
* test OUTMOD for the current entry (if port_type = 1 (aRFC))
    if port_type eq '1' and
       ( i_edp13-outmod eq 1   or   i_edp13-outmod eq 3 ).
 
      add_message_1 p_error '121' i_edp13-outmod.
 
    endif.
 
* test basis type
    CALL FUNCTION 'IDOCTYPE_EXISTENCE_CHECK'
         EXPORTING
              PI_IDOCTYP       = i_edp13-idoctyp
*        IMPORTING
*             PE_ATTRIBUTES    =
         EXCEPTIONS
              OBJECT_NOT_FOUND = 1
              DB_ERROR         = 2
              OTHERS           = 3.
 
    if sy-subrc eq 0.
      add_message_0 p_success '122'.
    else.
      add_message_1 p_error   '123' i_edp13-idoctyp.
    endif.
 
* test extension
    if i_edp13-cimtyp ne space.
      CALL FUNCTION 'EXTTYPE_EXISTENCE_CHECK'
           EXPORTING
                PI_CIMTYP        = i_edp13-cimtyp
*       IMPORTING
*            PE_ATTRIBUTES    =
           EXCEPTIONS
                OBJECT_NOT_FOUND = 1
                DB_ERROR         = 2
                OTHERS           = 3.
 
      if sy-subrc eq 0.
        add_message_0 p_success '124'.
      else.
        add_message_1 p_error   '125' i_edp13-cimtyp.
      endif.
 
* if there is an extension: test their combination
 
      CALL FUNCTION 'CHECK_STRUCTURES_MATCH'
           EXPORTING
                PI_IDOCTYP                 = i_edp13-idoctyp
                PI_CIMTYP                  = i_edp13-cimtyp
*    TABLES
*         PT_IDOCSYN                 =
*         PT_CIMSYN                  =
           EXCEPTIONS
                SEGMENT_IN_BOTH_STRUCTURES = 1
                NO_REFERENCE_SEGMENT_FOUND = 2
                COMPONENT_NOT_FOUND        = 3
                OTHERS                     = 4.
 
      if sy-subrc eq 0.
        add_message_0 p_success '150'.
      else.
        add_message_2 p_error   '151' i_edp13-idoctyp i_edp13-cimtyp.
      endif.
 
    endif.
 
* test assignment between message type and IDoc
    select single * from edimsg where idoctyp eq i_edp13-idoctyp
                                and   cimtyp  eq i_edp13-cimtyp
                                and   mestyp  eq i_edp13-mestyp.
 
    if sy-subrc eq 0.
      add_message_0 p_success '126'.
    else.
      add_message_0 p_error '127'.
    endif.
 
* test view (if applicable)
    if i_edp13-ediview ne space.
      perform test_ediview using i_edp13-idoctyp
                                 i_edp13-cimtyp
                                 i_edp13-mestyp
                                 i_edp13-ediview
                                 rc.
 
      if rc eq 0.
        add_message_0 p_success '136'.
      else.
        add_message_4 p_error '201' i_edp13-ediview
                                    i_edp13-idoctyp
                                    i_edp13-cimtyp
                                    i_edp13-mestyp.
      endif.
 
    endif.
 
* test if receiver of notifications exists
    if i_edp13-usrtyp ne space   or   i_edp13-usrkey ne space.
      perform test_receiver using i_edp13-usrtyp
                                  i_edp13-usrkey
                                  rc.
 
      if rc eq 0.
        add_message_0 p_success '107'.
      else.
        add_message_2 p_error '108' i_edp13-usrtyp i_edp13-usrkey.
      endif.
    endif.
 
  endloop.
 
ENDFORM.                               " TEST_EDP13
 
*Form  TEST_EDP21
* PARNUM    partner number
*  PARTYP    partner type
 
FORM TEST_EDP21.
 
  if not i_edp21[] is initial.
    add_message_0 p_success '128'.
  endif.
 
  loop at i_edp21.
    move-corresponding i_edp21 to edk21.
    move-corresponding i_edp21 to edp21_key.
 
    add_separator.
    add_message_1 p_success '111' edp21_key.
 
* test incoming process code
    select single * from tede2 where evcode eq i_edp21-evcode.
 
    if sy-subrc eq 0.
      add_message_0 p_success '129'.
    else.
      add_message_1 p_error   '130' i_edp21-evcode.
    endif.
 
* test if receiver of notifications exists
    if i_edp21-usrtyp ne space   or   i_edp21-usrkey ne space.
      perform test_receiver using i_edp21-usrtyp
                                  i_edp21-usrkey
                                  rc.
 
      if rc eq 0.
        add_message_0 p_success '107'.
      else.
        add_message_2 p_error   '108' i_edp21-usrtyp i_edp21-usrkey.
      endif.
    endif.
 
  endloop.
 
ENDFORM.                               " TEST_EDP21
 
 
*FORM progress
form progress using percentage type i.
 
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            PERCENTAGE = percentage
       EXCEPTIONS
            OTHERS     = 1.
 
endform.
 
FORM test_ediview USING    PI_iDOCTYP   like edp13-idoctyp
                           PI_CIMTYP    like edp13-cimtyp
                           PI_MESTYP    like edp13-mestyp
                           PI_EDIVIEW   like edp13-ediview
                           Pe_RC.
 
  CALL FUNCTION 'EDI_CHECK_PARTNER_EDIVIEW'
       EXPORTING
            PI_IDOCTYP = pi_idoctyp
            PI_CIMTYP  = pi_cimtyp
            PI_MESTYP  = pi_mestyp
            PI_EDIVIEW = pi_ediview
       EXCEPTIONS
            OTHERS     = 2.
 
  pe_rc = sy-subrc.
 
ENDFORM.                               " test_ediview


The output of the above program is shown below:




After executing this program, the program for the generation of intermediate document(IDOC) is executed. This Idoc contains all the details about the application document, RFC applications in the form of three layers.

1. Control record: This contains the details of the sender and the receiver, the mode of the process, the document type .
2. Data record: This contains the details of the document in the form of separate segments.
3. Status record: This contains the status of the IDOC at all intermediate levels.
By executing the following program, an IDOC is generated and it is saved. The saved IDOC is ready for transmission. The program for the generation of IDOC is below:

Code:
PROGRAM RSNAST00 MESSAGE-ID VN.
TABLES:  NAST, nase,           
                T681B.                       
TABLES: ALARC_PAR1,
        ARC_PARAMS,                    "#EC NEEDED
        TOA_DARA,                      "#EC NEEDED
        NAST00.
TABLES:  TNAPR,                       
        *TNAPR,
         T681Z,
         T685B.
 
INCLUDE RSEF4HLP.
CONSTANTS: KVEWE_NAST   LIKE T681Z-KVEWE    VALUE 'B',
           ON(1)        TYPE C              VALUE 'X'.
FIELD-GROUPS: HEADER,
              STATUS.
 
 
SELECTION-SCREEN BEGIN OF BLOCK BLK_SEL WITH FRAME
                                             TITLE TEXT-001.
SELECT-OPTIONS: S_KAPPL FOR nase-KAPPL,
                S_OBJKY FOR NAST-OBJKY,
                S_KSCHL FOR nase-KSCHL,
                S_NACHA FOR NAST-NACHA.
SELECTION-SCREEN SKIP 1.
PARAMETERS:     P_AGAIN  LIKE NAST00-REPEAT,
                P_SORT   LIKE NAST00-SORT.
SELECTION-SCREEN END OF BLOCK BLK_SEL.
 
SELECTION-SCREEN BEGIN OF BLOCK BLK_PAR WITH FRAME
                                             TITLE TEXT-002.
PARAMETERS:     P_PRINT  LIKE NAST-LDEST,
                P_SUFF2  LIKE NAST-DSUF2.
SELECTION-SCREEN END OF BLOCK BLK_PAR.
 
DATA:    RETURNCODE   LIKE SY-SUBRC,   "Returncode aus Druckprogramm
         RETCODE      LIKE SY-SUBRC,   "Returncode
         COUNT        LIKE SY-INDEX,   "Counter: verarbeitete Belege
         COUNT_1      LIKE SY-INDEX,   "Counter: erfolgreich verarbeitet
         COUNT_2      LIKE SY-INDEX,   "Counter: fehlerhaft verarbeitet
         XSCREEN(1)   TYPE C.
 
DATA: BEGIN OF PARTNER,
        ROLLE         LIKE NAST-PARVW,
        NUMMER        LIKE NAST-PARNR,
      END OF PARTNER.
 
DATA: P_VSTAT LIKE NAST-VSTAT.
INSERT NAST INTO STATUS.
 
CASE P_SORT.
  WHEN '01'.
    INSERT NAST-PARNR NAST-KAPPL NAST-KSCHL NAST-OBJKY INTO HEADER.
  WHEN '02'.
    INSERT NAST-KAPPL NAST-OBJKY INTO HEADER.
  WHEN '03'.
    INSERT NAST-KSCHL NAST-PARNR INTO HEADER.
  WHEN '10'.
    INSERT NAST-SORT1 NAST-SORT2 NAST-SORT3 INTO HEADER.
  WHEN '11'.
    INSERT NAST-KAPPL NAST-SORT1 NAST-SORT2 NAST-SORT3 INTO HEADER.
  WHEN '12'.
    INSERT NAST-KSCHL NAST-SORT1 NAST-SORT2 NAST-SORT3 INTO HEADER.
    INCLUDE RSNASTZZ.
  WHEN OTHERS.
    INSERT NAST-PARNR NAST-KAPPL NAST-KSCHL NAST-OBJKY INTO HEADER.
ENDCASE.
 
IF P_AGAIN EQ ON.          "
  MOVE '1' TO P_VSTAT.                 ELSE.
  MOVE '0' TO P_VSTAT.                 ENDIF.
 
SELECT * FROM NAST WHERE VSTAT EQ P_VSTAT
                   AND   KAPPL IN S_KAPPL
                   AND   VSZTP BETWEEN 1 AND 2
                   AND   OBJKY IN S_OBJKY
                   AND   KSCHL IN S_KSCHL
                   AND   NACHA IN S_NACHA
                   AND   AKTIV EQ SPACE.
  PERFORM CHECK_KAPPLS_NOT_TO_PROCESS USING NAST-KAPPL
                                            RETURNCODE.
  CHECK RETURNCODE EQ 0.
  PERFORM CHECK_NAST_VSZTP USING NAST
                                 RETURNCODE.
  CHECK RETURNCODE EQ 0.
  EXTRACT STATUS.
ENDSELECT.
 
CLEAR COUNT.
SORT.
 
LOOP.
  AT STATUS.
    PERFORM OBJEKT_SPERREN USING RETCODE ' '.
    CHECK RETCODE = 0.
    PERFORM CHECK_STATUS_ON_DB USING RETCODE.
    IF RETCODE NE 0.
      PERFORM OBJEKT_ENTSPERREN.
    ENDIF.
    CHECK RETCODE = 0.
    ADD 1 TO COUNT.
    IF SY-BATCH NE SPACE.
      PARTNER-ROLLE = NAST-PARVW.
      PARTNER-NUMMER = NAST-PARNR.
      MESSAGE I035 WITH NAST-OBJKY NAST-KSCHL PARTNER.
    ENDIF.
 
    perform T685B_LESEN using nast-kappl nast-kschl.
 
    if t685b-nbear eq space.
 
      IF P_PRINT NE SPACE.
        NAST-LDEST = P_PRINT.
      ENDIF.
 
 
      IF P_SUFF2 NE SPACE.
        NAST-DSUF2 = P_SUFF2.
      ENDIF.
 
    endif.
 
    PERFORM TNAPR_LESEN  USING NAST-KSCHL
                               NAST-NACHA
                               NAST-KAPPL.
    CLEAR XSCREEN.
    PERFORM OPTISCHE_ARCHIVIERUNG.
    PERFORM PROGRAMM_AUFRUFEN USING XSCREEN.
    PERFORM SET_COUNTERS USING RETURNCODE.
    IF SY-BATCH NE SPACE.
      PARTNER-ROLLE = NAST-PARVW.
      PARTNER-NUMMER = NAST-PARNR.
      MESSAGE I034 WITH NAST-OBJKY NAST-KSCHL PARTNER RETURNCODE.
    ENDIF.
    IF P_AGAIN NE 'X'.
      PERFORM PROTOCOL_STORE USING    NAST-KAPPL
                                      NAST-KSCHL
                             CHANGING NAST-CMFPNR.
      PERFORM NAST_UPDATE USING RETCODE.
      IF RETCODE NE 0.
        MESSAGE A013 WITH NAST-KAPPL NAST-OBJKY.
      ENDIF.
    ENDIF.
    COMMIT WORK.
    PERFORM OBJEKT_ENTSPERREN.
  ENDAT.
  IF SY-BATCH = SPACE.
    IF P_AGAIN EQ ON.
      perform t685b_lesen using nast-kappl nast-kschl.
      check t685b-noprotocol eq space.
      CALL FUNCTION 'WFMC_PROTOCOL_GET_UNSTORED'
           EXCEPTIONS
                OTHERS = 0.
    ELSE.
      CALL FUNCTION 'WFMC_PROTOCOL_LOAD'
           EXPORTING
                CPS_NAST = NAST.
    ENDIF.
  ENDIF.
ENDLOOP.
IF SY-BATCH = SPACE.
  CALL FUNCTION 'WFMC_PROTOCOL_SHOW'
       EXPORTING
            CPS_KALSM = SPACE
            CPS_NAST  = NAST
            NO_HEADER = 'X'.
ENDIF.
MESSAGE I033 WITH COUNT COUNT_1 COUNT_2.
 
 
FORM EINZELNACHRICHT USING US_SUBRC LIKE SY-SUBRC.
 
  DATA: L_SUBRC LIKE SY-SUBRC.
  PERFORM TNAPR_LESEN  USING NAST-KSCHL
                             NAST-NACHA
                             NAST-KAPPL.
  CLEAR XSCREEN.
  PERFORM OPTISCHE_ARCHIVIERUNG.
  PERFORM PROGRAMM_AUFRUFEN USING XSCREEN.
  US_SUBRC = RETURNCODE.
  PERFORM PROTOCOL_STORE USING    NAST-KAPPL
                                  NAST-KSCHL
                         CHANGING NAST-CMFPNR.
  PERFORM NAST_UPDATE USING L_SUBRC.
  IF L_SUBRC NE 0.
    MESSAGE A013 WITH NAST-KAPPL NAST-OBJKY.
  ENDIF.
 
ENDFORM.
 
FORM EINZELNACHRICHT_DIALOG USING US_SUBRC LIKE SY-SUBRC.
 
  PERFORM TNAPR_LESEN  USING NAST-KSCHL
                             NAST-NACHA
                             NAST-KAPPL.
  CLEAR XSCREEN.
  PERFORM OPTISCHE_ARCHIVIERUNG.
  PERFORM PROGRAMM_AUFRUFEN USING XSCREEN.
  US_SUBRC = RETURNCODE.
  DATA TMP_SUBRC LIKE SY-SUBRC.
  PERFORM CHECK_KAPPLS_NOT_TO_PROCESS USING NAST-KAPPL "excluded records
                                            TMP_SUBRC.
  IF TMP_SUBRC EQ 0.
 
    CASE RETURNCODE.
      WHEN '0'.                        "erfolgreich versandt
        NAST-VSTAT = '1'.
      WHEN '1'.                        "fehlerhaft
        NAST-VSTAT = '2'.
      WHEN '2'.                        "uebersetzt (EDI)
        NAST-VSTAT = '1'.
      WHEN '3'.                        "Beleg noch unvollstдndig
      WHEN OTHERS.                     "fehlerhaft
        NAST-VSTAT = '2'.
    ENDCASE.
    NAST-DATVR = SY-DATUM.
    NAST-UHRVR = SY-UZEIT.
  ENDIF.
  PERFORM PROTOCOL_STORE USING    NAST-KAPPL
                                  NAST-KSCHL
                         CHANGING NAST-CMFPNR.
  CALL FUNCTION 'RV_MESSAGE_UPDATE_SINGLE' IN UPDATE TASK
       EXPORTING
            MSG_NAST = NAST.
 
ENDFORM.
 
 
FORM EINZELNACHRICHT_SCREEN USING US_SUBRC LIKE SY-SUBRC.
 
  PERFORM TNAPR_LESEN  USING NAST-KSCHL
                             NAST-NACHA
                             NAST-KAPPL.
  XSCREEN = 'X'.
  PERFORM PROGRAMM_AUFRUFEN USING XSCREEN.
  US_SUBRC = RETURNCODE.
 
ENDFORM.
 
 
FORM EINZELNACHRICHT_OHNE_UPDATE USING US_SUBRC LIKE SY-SUBRC.
 
  PERFORM TNAPR_LESEN  USING NAST-KSCHL
                             NAST-NACHA
                             NAST-KAPPL.
  CLEAR XSCREEN.
  PERFORM PROGRAMM_AUFRUFEN USING XSCREEN.
  US_SUBRC = RETURNCODE.
 
ENDFORM.
 
 
FORM NAST_UPDATE USING NAST_SUBRC LIKE SY-SUBRC.
 
  PERFORM CHECK_KAPPLS_NOT_TO_PROCESS USING NAST-KAPPL "excluded records
                                            NAST_SUBRC.
 
  check nast-snddr eq space.
 
  IF NAST_SUBRC EQ 0.
    CASE RETURNCODE.
      WHEN '0'.                                NAST-VSTAT = '1'.
      WHEN '1'.                       
        NAST-VSTAT = '2'.
      WHEN '3'.                       
      WHEN OTHERS.                     
        NAST-VSTAT = '2'.
    ENDCASE.
  ELSE.
    RETURNCODE = 0.
  ENDIF.
  IF RETURNCODE NE 3.
    IF NAST_SUBRC EQ 0.
      NAST-DATVR = SY-DATUM.
      NAST-UHRVR = SY-UZEIT.
    ENDIF.
    UPDATE NAST.
    IF SY-SUBRC NE 0.
      INSERT NAST.
      IF SY-SUBRC NE 0.
        NAST_SUBRC = SY-SUBRC.
      ENDIF.
    ENDIF.
  ENDIF.
 
ENDFORM.
 
 
FORM OBJEKT_ENTSPERREN.
  DATA: BELNR LIKE VBAK-VBELN.
  DATA: EBELN LIKE EKKO-EBELN.
  DATA: TKNUM LIKE VTTK-TKNUM.
  DATA: PABNUM LIKE PABIT-PABNUM.
  DATA: L_KNUMA TYPE KNUMA.
  DATA: L_WBELN TYPE WBELN_AG.
 
  CASE NAST-KAPPL.
    WHEN 'V1'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVVBAKE'
           EXPORTING
                VBELN = BELNR.
    WHEN 'V2'.                         
           EXPORTING
                VBELN = BELNR.
    WHEN 'V3'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVVBRKE'
           EXPORTING
                VBELN = BELNR.
    WHEN 'V4'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVVBLKE'
           EXPORTING
                VBELN = BELNR.
    WHEN 'V6'.                         
    WHEN 'V7'.                         
      TKNUM = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVVTTKE'
           EXPORTING
                MANDT = SY-MANDT
                TKNUM = TKNUM.
    WHEN 'K1'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVVBKAE'
           EXPORTING
                VBELN = BELNR.
    WHEN 'EF' OR 'EA' OR 'EV' OR 'ES' OR 'EL'. 
      EBELN = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EMEKKOE'
           EXPORTING
                EBELN  = EBELN
           EXCEPTIONS
                OTHERS = 0.
    WHEN 'NF'.                         
      DATA: NFNUM_INT LIKE J_1BNFDOC-DOCNUM.
      NFNUM_INT = NAST-OBJKY.
      CALL FUNCTION 'J_1B_NF_DOCUMENT_UNLOCK'
           EXPORTING
                DOC_NUMBER = NFNUM_INT
                LOCK_MODE  = 'E'
           EXCEPTIONS
                OTHERS     = 0.
    WHEN 'PA'.                         
      PABNUM = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_E_PABIT_E'
           EXPORTING
                PABNUM   = PABNUM
                X_PABPOS = ON
           EXCEPTIONS
                OTHERS   = 0.
    WHEN 'WN'.
      L_KNUMA = NAST-OBJKY+10(10).
      CALL FUNCTION 'DEQUEUE_EVKONAE'
           EXPORTING
                KNUMA = L_KNUMA.
    WHEN 'WR'.
      L_WBELN = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EMWBRKE'
           EXPORTING
                WBELN = L_WBELN.
    WHEN 'WS'.
      L_KNUMA = NAST-OBJKY.
      CALL FUNCTION 'DEQUEUE_EVKONAE'
           EXPORTING
                KNUMA = L_KNUMA.
 
  ENDCASE.
 
ENDFORM.
 
 
FORM OBJEKT_SPERREN USING US_SUBRC LIKE SY-SUBRC
                          US_NOMSG TYPE C.
  DATA: BELNR LIKE VBAK-VBELN.
  DATA: EBELN LIKE EKKO-EBELN.
  DATA: TKNUM LIKE VTTK-TKNUM.         
  DATA: PABNUM LIKE PABIT-PABNUM.
  DATA: L_KNUMA TYPE KNUMA.
  DATA: L_WBELN TYPE WBELN_AG.
 
  CLEAR US_SUBRC.
 
  CASE NAST-KAPPL.
    WHEN 'V1'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVBAKE'
           EXPORTING
                VBELN          = BELNR
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'V2'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVBLKE'
           EXPORTING
                VBELN          = BELNR
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'V3'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVBRKE'
           EXPORTING
                VBELN          = BELNR
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'V4'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVBLKE'
           EXPORTING
                VBELN          = BELNR
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'V6'
    WHEN 'V7'.                         
      TKNUM = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVTTKE'
           EXPORTING
                TKNUM          = TKNUM
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'K1'.                         
      BELNR = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVVBKAE'
           EXPORTING
                VBELN          = BELNR
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3.
    WHEN 'EF' OR 'EA' OR 'EV' OR 'ES' OR 'EL'. 
      EBELN = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EMEKKOE'
           EXPORTING
                EBELN          = EBELN
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
    WHEN 'NF'.                         
      DATA: NFNUM_INT LIKE J_1BNFDOC-DOCNUM.
      NFNUM_INT = NAST-OBJKY.
      CALL FUNCTION 'J_1B_NF_DOCUMENT_LOCK'
           EXPORTING
                DOC_NUMBER     = NFNUM_INT
                LOCK_MODE      = 'E'
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
 
    WHEN 'PA'.
      PABNUM = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_E_PABIT_E'
           EXPORTING
                PABNUM         = PABNUM
                X_PABPOS       = ON
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
 
    WHEN 'WN'.
 
      L_KNUMA = NAST-OBJKY+10(20).
      CALL FUNCTION 'ENQUEUE_EVKONAE'
           EXPORTING
                KNUMA          = L_KNUMA
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
 
    WHEN 'WR'.
 
      L_WBELN = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EMWBRKE'
           EXPORTING
                WBELN          = L_WBELN
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
 
    WHEN 'WS'.
 
      L_KNUMA = NAST-OBJKY.
      CALL FUNCTION 'ENQUEUE_EVKONAE'
           EXPORTING
                KNUMA          = L_KNUMA
           EXCEPTIONS
                FOREIGN_LOCK   = 2
                SYSTEM_FAILURE = 3
                OTHERS         = 3.
 
    WHEN OTHERS.
      SY-SUBRC = 0.
  ENDCASE.
 
  US_SUBRC = SY-SUBRC.
  IF US_NOMSG IS INITIAL.
    CASE SY-SUBRC.
      WHEN 2.
        MESSAGE I036 WITH NAST-OBJKY NAST-KAPPL NAST-KSCHL.
      WHEN 3.
        MESSAGE A600(MC).
    ENDCASE.
  ENDIF.
ENDFORM.
 
 
FORM OPTISCHE_ARCHIVIERUNG.
 
  DATA: BEGIN OF XOBJID,
          OBJKY  LIKE NAST-OBJKY,
          ARCNR  LIKE NAST-OPTARCNR,
        END OF XOBJID.
  DATA: XOJ_NAME LIKE TOA_DARA-SAP_OBJECT.
  DATA: XOBJKY   LIKE NAST-OBJKY.
 
  CHECK NAST-TDARMOD = '2'
    OR  NAST-TDARMOD = '3'.
  XOBJKY = NAST-OBJKY.
  CALL FUNCTION 'WFMC_GET_ARCHIVE_OBJECT_TYPE'
       EXPORTING
            PI_KAPPL       = NAST-KAPPL
       IMPORTING
            PE_OBJECT_TYPE = XOJ_NAME
       CHANGING
            PC_OBJKY       = XOBJKY.
  IF XOJ_NAME = SPACE.
    MESSAGE A049 WITH NAST-KAPPL.
  ENDIF.
  PERFORM T685B_LESEN USING NAST-KAPPL NAST-KSCHL.
 
  CALL FUNCTION 'NUMBER_GET_NEXT'
       EXPORTING
            NR_RANGE_NR = '01'
            OBJECT      = 'NA_OPT_ARC'
       IMPORTING
            NUMBER      = NAST-OPTARCNR.
  XOBJID-OBJKY = XOBJKY.
  XOBJID-ARCNR = NAST-OPTARCNR.
  TOA_DARA-MANDANT    = NAST-MANDT.
  TOA_DARA-SAP_OBJECT = XOJ_NAME.
  TOA_DARA-AR_OBJECT  = T685B-ARCOBJART.
  TOA_DARA-OBJECT_ID  = XOBJID.
 
  ARC_PARAMS-SAP_OBJECT = XOJ_NAME.
  ARC_PARAMS-AR_OBJECT  = T685B-ARCOBJART.
  ARC_PARAMS-MANDANT    = NAST-MANDT.
 
  IF NAST-TDRECEIVER NE SPACE.
    ARC_PARAMS-ARCUSER    = NAST-TDRECEIVER.
  ELSE.
    ARC_PARAMS-ARCUSER    = NAST-USNAM.
  ENDIF.
  ARC_PARAMS-PRINTER    = NAST-LDEST.
  ALARC_PAR1-SAP_OBJECT = XOJ_NAME.
  ALARC_PAR1-AR_OBJECT  = T685B-ARCOBJART.
  ALARC_PAR1-MANDANT    = NAST-MANDT.
  ALARC_PAR1-ARCUSER    = NAST-USNAM.
  ALARC_PAR1-PRINTER    = NAST-LDEST.
 
ENDFORM.
 
 
FORM PROGRAMM_AUFRUFEN USING US_SCREEN TYPE C.
 
  DATA: RONAM     LIKE TNAPR-RONAM,
        FONAM     LIKE TNAPR-FONAM,
        PGNAM     LIKE TNAPR-PGNAM,
        TEMP_NAST LIKE NAST.
 
  DATA US_SUBRC LIKE SY-SUBRC.
  PERFORM CHECK_KAPPLS_NOT_TO_PROCESS USING NAST-KAPPL "excluded records
                                            US_SUBRC.
  CHECK US_SUBRC EQ 0.
 
  if us_screen ne on.
    check nast-snddr eq space.
  endif.
 
  IF NAST-NACHA = '1' AND
     NAST-TDRECEIVER IS INITIAL.
    NAST-TDRECEIVER = NAST-USNAM.
  ENDIF.
  CALL FUNCTION 'NAST_PROTOCOL_INITIALIZE'.
   *TNAPR = TNAPR.
  DO 5 TIMES VARYING RONAM FROM *TNAPR-RONAM NEXT *TNAPR-RONAM2
             VARYING FONAM FROM *TNAPR-FONAM NEXT *TNAPR-FONAM2
             VARYING PGNAM FROM *TNAPR-PGNAM NEXT *TNAPR-PGNAM2.
    CHECK PGNAM NE SPACE.
    TNAPR-RONAM = RONAM.
    TNAPR-FONAM = FONAM.
    TNAPR-PGNAM = PGNAM.
    IF TNAPR-RONAM NE SPACE OR TNAPR-PGNAM NE SPACE.
      SY-MSGID = 'VN'.
      SY-MSGNO = '056'.
      SY-MSGTY = 'I'.
      SY-MSGV1 = TNAPR-PGNAM.
      CONDENSE SY-MSGV1 NO-GAPS.
      SY-MSGV2 = TNAPR-RONAM.
      CONDENSE SY-MSGV2 NO-GAPS.
      CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
           EXPORTING
                MSG_ARBGB = SY-MSGID
                MSG_NR    = SY-MSGNO
                MSG_TY    = SY-MSGTY
                MSG_V1    = SY-MSGV1
                MSG_V2    = SY-MSGV2
           EXCEPTIONS
                OTHERS    = 0.
 
    ENDIF.
    IF NAST-NACHA EQ '1'.
      IF NAST-PFLD5 NE SPACE.
        TNAPR-FUNCNAME = NAST-PFLD5.
      ENDIF.
    ENDIF.
    IF NAST-NACHA EQ '1' OR NAST-NACHA EQ '2'.
      IF NAST-PFLD4 NE SPACE.
        TNAPR-FONAM = NAST-PFLD4.
      ENDIF.
    ENDIF.
 
    RETURNCODE = 999.
   TEMP_NAST = NAST.
    PERFORM (TNAPR-RONAM) IN PROGRAM (TNAPR-PGNAM) USING RETURNCODE
                                                         US_SCREEN
                                                         IF FOUND.
 
    NAST = TEMP_NAST.
    IF RETURNCODE = 999.
      SYST-MSGID = 'VN'.
      SYST-MSGNO = 068.
      SYST-MSGTY = 'E'.
      SYST-MSGV1 = TNAPR-RONAM.
      SYST-MSGV2 = TNAPR-PGNAM.
      CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
           EXPORTING
                MSG_ARBGB = SYST-MSGID
                MSG_NR    = SYST-MSGNO
                MSG_TY    = SYST-MSGTY
                MSG_V1    = SYST-MSGV1
                MSG_V2    = SYST-MSGV2
           EXCEPTIONS
                OTHERS    = 0.
 
    ENDIF.
    IF RETURNCODE NE 0.
      EXIT.
    ENDIF.
  ENDDO.
  TNAPR = *TNAPR.
ENDFORM.
 
 
 
FORM PROTOCOL_STORE USING    VALUE(PI_KAPPL) LIKE NAST-KAPPL
                             VALUE(PI_KSCHL) LIKE NAST-KSCHL
                    CHANGING P_CMFPNR  LIKE NAST-CMFPNR.
 
  DATA: L_NAST_CMFPNR LIKE NAST-CMFPNR.
 
  PERFORM T685B_LESEN USING PI_KAPPL
                            PI_KSCHL.
 
  IF T685B-NOPROTOCOL EQ SPACE.
    CALL FUNCTION 'NAST_PROTOCOL_STORE'
         IMPORTING
              MSG_CMFPNR         = L_NAST_CMFPNR
         EXCEPTIONS
              NO_PROTOCOL_UPDATE = 01.
    IF SY-SUBRC EQ 0.
      P_CMFPNR = L_NAST_CMFPNR.
    ENDIF.
  ELSE.
    CLEAR P_CMFPNR.
  ENDIF.
ENDFORM.
 
 
FORM TNAPR_LESEN  USING VALUE(P_KSCHL) LIKE NAST-KSCHL
                        VALUE(P_NACHA) LIKE NAST-NACHA
                        VALUE(P_KAPPL) LIKE NAST-KAPPL.
 
  CHECK TNAPR-KSCHL NE P_KSCHL
    OR  TNAPR-NACHA NE P_NACHA
    OR  TNAPR-KAPPL NE P_KAPPL.
  SELECT SINGLE * FROM TNAPR WHERE KSCHL = P_KSCHL
                             AND   NACHA = P_NACHA
                             AND   KAPPL = P_KAPPL.
  IF SY-SUBRC NE 0.
    MESSAGE A020 WITH P_KSCHL P_NACHA P_KAPPL.
  ENDIF.
 
ENDFORM.
 
 
 
FORM T685B_LESEN USING VALUE(US_KAPPL) LIKE T685B-KAPPL
                       VALUE(US_KSCHL) LIKE T685B-KSCHL.
 
  CHECK T685B-KAPPL NE US_KAPPL
    OR  T685B-KSCHL NE US_KSCHL.
  SELECT SINGLE * FROM T685B WHERE KAPPL = US_KAPPL
                             AND   KSCHL = US_KSCHL.
  IF SY-SUBRC NE 0.
    MESSAGE A047 WITH US_KAPPL US_KSCHL.
  ENDIF.
 
ENDFORM.
 
 
FORM CHECK_NAST_VSZTP  USING P_NAST   STRUCTURE NAST
                             P_SUBRC  LIKE SY-SUBRC.
  P_SUBRC = 4.
  CHECK P_NAST-VSZTP NE '3'.           
  IF P_NAST-VSZTP = '2'.               
    IF P_NAST-VSDAT CN '0'.
      CHECK P_NAST-VSDAT LE SY-DATUM.
    ENDIF.
    IF P_NAST-VSURB IS INITIAL.
      CHECK P_NAST-VSURA LE SY-UZEIT.
    ELSE.
      CHECK P_NAST-VSURA LE SY-UZEIT AND P_NAST-VSURB GE SY-UZEIT.
    ENDIF.
  ENDIF.
  P_SUBRC = 0.
ENDFORM.
 
 
FORM CHECK_KAPPLS_NOT_TO_PROCESS USING VALUE(P_KAPPL) LIKE NAST-KAPPL
                                       P_SUBRC        LIKE SY-SUBRC.
  CASE P_KAPPL.
    WHEN 'WA'.
      P_SUBRC = 4.
    WHEN OTHERS.
      P_SUBRC = 0.
  ENDCASE.
 
ENDFORM.                               " CHECK_KAPPLS_NOT_TO_PROCESS
FORM CHECK_STATUS_ON_DB USING RC  LIKE SY-SUBRC.
  DATA: ST_NAST LIKE NAST.
 
  RC = 0.
  IF NAST-VSTAT = '0'.
    SELECT SINGLE * FROM NAST INTO ST_NAST WHERE
          KAPPL = NAST-KAPPL  AND
          OBJKY = NAST-OBJKY  AND
          KSCHL = NAST-KSCHL  AND
          SPRAS = NAST-SPRAS  AND
          PARNR = NAST-PARNR  AND
          PARVW = NAST-PARVW  AND
          ERDAT = NAST-ERDAT  AND
          ERUHR = NAST-ERUHR.
    IF SY-SUBRC <> 0 OR ST_NAST-VSTAT <> '0'.
      RC = 8.
    ENDIF.
  ENDIF.
ENDFORM.                               " CHECK_STATUS_ON_DB
 
 
FORM SET_COUNTERS USING L_SUBRC LIKE SY-SUBRC.
 
  CASE L_SUBRC.
    WHEN '0'.                          "successfully processed
      ADD 1 TO COUNT_1.
    WHEN '1'.                          "processing failure
      ADD 1 TO COUNT_2.
*   WHEN '2'.                          "translated (EDI)
*     ADD 1 TO count_1.
    WHEN '3'.                          "application document incomplete
    WHEN OTHERS.                       "processing failure
      ADD 1 TO COUNT_2.
  ENDCASE.
 
ENDFORM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.