Javascript required
Skip to content Skip to sidebar Skip to footer

How to Upload Css File to Idoc

Step by step guide for File to IDOC Scenario by using custom plan

Business Scenario:   Warehouse management is maintained in 3rd political party system where picking, packing & dispatching happens and later delivery details will be sent through file for which PGI needs to be washed in SAP. This document explains the file to IDOC scenario. Through custom program by reading file from application server & perform the PGI with the assistance of standard ALE/IDOC settings.

IDOC Procedure: By using custom program, we will read the text file on application server and so by preparing control record, data tape pass details to std. procedure by using some std. part modules. Cheque the attached code for item agreement. Standard FM then calls the process code DELV which contains FM IDOC_INPUT_DELVRY which process the IDOC.

ALE Configuration details are as follows:

1.        1. Defining Logical System ( T-Code – Auction)

/wp-content/uploads/2014/03/1_414152.png

/wp-content/uploads/2014/03/2_414153.png

Notation: Mostly the logical systems are bachelor for customer of SAP system in which yous are working. Please do non create logical systems unnecessarily. Use the existing logical system fastened to the client in which yous intend to work.

ii. Assigning Client to Logical System ( T-Code – Auction)

Note: Do not follow this step if logical system is already created and assigned to the client.

/wp-content/uploads/2014/03/3_414164.png

/wp-content/uploads/2014/03/4_414166.png

three. Standard Message type (Transaction WE81) (Client Independent)

In our scenario we are using standard message type, so no need to maintain any settings.

Note:   For custom message type an entry need to be maintained in WE81.

/wp-content/uploads/2014/03/5_414172.png

four. Assign IDOC blazon to the message type (Transaction WE82) (Client Contained)

In our scenario we are using standard bulletin type & basic type, so no need to maintain whatsoever settings.

Notation:   For custom message type, basic type or in case of extension to standard basic type an entry need to exist maintained in WE82.

/wp-content/uploads/2014/03/6_414185.png

five. Distribution Model (Tcode – BD64)

Distribution Model should already be present in the receiving organization every bit it was distributed from the sending system to the receiving arrangement.

6. Link Message Blazon to Office Module (WE57) (Customer independent)

In our scenario nosotros are using standard message type, basic blazon & FM, so no demand to maintain whatsoever settings.

Note:   For custom message type, bones blazon or in case of extension to standard basic type an entry demand to be maintained in WE57.

/wp-content/uploads/2014/03/7_414186.png

7. Maintain partner profile (Transaction code WE20) for the message type you divers in WE81:

/wp-content/uploads/2014/03/8_414187.png

Double click on Entering parameter SHPCON.

/wp-content/uploads/2014/03/9_414188.png

Double click on procedure code DELV .

/wp-content/uploads/2014/03/10_414189.png

8.  8. Custom Plan details

Selection screen:

/wp-content/uploads/2014/03/11_414190.png

Output:

/wp-content/uploads/2014/03/12_414197.png

Field Mapping:

Seq No Offset Position Length Format Segment Field Field Blazon Length Field Values
i i 20 Character E2EDL20 VBELN CHAR 10 SAP Delivery No.
2 21 9 Character Field value sent by tertiary party system not required in SAP
3 30 nine Character E2EDL20 LIFEX CHAR xvi External Identification of Delivery Note (Invoice Number)
iv 39 x Date Field value sent by third party organisation not required in SAP
5 Character E2EDL20 TRATY CHAR four Ways of Trasport Id (default '0004')
6 49 20 Graphic symbol E2EDL20 TRAID CHAR 20 Tracking Id (Means of Transport Id)
7 69 34 Character E2EDL20 BOLNR CHAR 35 Neb of Lading (Shipment Tracking Id)

Code:

                      *&---------------------------------------------------------------------* *& Report  YTEST_FILE_TO_IDOC *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* Study  ytest_file_to_idoc NO STANDARD Folio HEADING. *********************************************************************** * Types Declaration *********************************************************************** TYPES : BEGIN OF ty_final1,           vbeln   Blazon char20,           mfst_id TYPE char9,           lifex   TYPE char9,           mfst_dt Type char10,           traid   Type char20,           bolnr   Type char34,         Cease OF ty_final1,         Brainstorm OF ty_final,           vbeln   Blazon char10,           mfst_id TYPE char9,           lifex   TYPE char35,           mfst_dt Blazon char10,           traid   Blazon char20,           bolnr   Blazon char34,           mistake   TYPE char1,         Stop OF ty_final,         BEGIN OF ty_lips,           vbeln Type vbeln_vl,           posnr Blazon posnr_vl,           matnr TYPE matnr,           lfimg TYPE lfimg,         END OF ty_lips,         BEGIN OF ty_alv,           docnum  TYPE edi_docnum,           status  Blazon edi_status,           msg_txt Type char100,         Cease OF ty_alv. DATA : gt_final TYPE STANDARD TABLE OF ty_final,        gs_final1 TYPE ty_final1,        gs_final TYPE ty_final,        gt_lips  Blazon STANDARD TABLE OF ty_lips,        gs_lips  Blazon ty_lips,        gs_edidc Type edidc,        gs_idoc_control Blazon edi_dc,        gs_edk21 Blazon edk21,        gs_edd21 TYPE edd21,        gt_data TYPE STANDARD Tabular array OF edi_dd,        gt_alv  TYPE STANDARD TABLE OF ty_alv,        gs_alv  Type ty_alv,        gv_input_file Blazon rlgrap-filename,        gt_dir_list   Type STANDARD TABLE OF epsfili,        gs_dir_list   TYPE epsfili. *********************************************************************** * CONSTANTS *********************************************************************** CONSTANTS : g_c_e1edl20 TYPE e1edl20 VALUE 'E1EDL20',             g_c_e1edl18 Type e1edl18 VALUE 'E1EDL18',             g_c_e1edl24 Type e1edl24 VALUE 'E1EDL24',             g_c_traty   Type char4   VALUE '0004',             g_c_pgi     TYPE char3   VALUE 'PGI',             g_c_pic     TYPE char3   VALUE 'PIC',             g_c_chg     Type char3   VALUE 'CHG',             g_c_in      Blazon edi_direc3 VALUE 'ii',             g_c_sndpor  Type edi_sndpo3 VALUE 'A000000026',             g_c_mestyp  TYPE edi_mestp3 VALUE 'SHPCON',             g_c_doctyp  Blazon edi_doctp3 VALUE 'DELVRY03',             g_c_sndprt  Type edi_sndpt3 VALUE 'LS',             g_c_rcvprt  Type edi_rcvpt3 VALUE 'LS',             g_c_slash TYPE char1 VALUE '/'. *********************************************************************** * Choice Screen *********************************************************************** Choice-SCREEN BEGIN OF Block blk1 WITH FRAME Title text-001. PARAMETERS: p_import  Type rlgrap-filename OBLIGATORY MODIF ID arc,             p_prefix  TYPE rlgrap-filename OBLIGATORY DEFAULT                            'PGI_test*'. Pick-SCREEN SKIP 1. PARAMETERS : p_part Type edi_rcvprn OBLIGATORY. Choice-SCREEN Stop OF BLOCK blk1. *********************************************************************** * Start of Selection *********************************************************************** Get-go-OF-Option.   PERFORM get_files_from_dir. * Make full command record of idoc   PERFORM fill_control_record.   LOOP AT gt_dir_list INTO gs_dir_list. * Read data from awarding server     PERFORM read_data_from_file. * Validate the file data     PERFORM validate_data. * Fix command data,     PERFORM prepare_data.   ENDLOOP. *********************************************************************** * End of Selection *********************************************************************** END-OF-Choice. * Display ALV for Succes & Mistake   PERFORM display_log. *&---------------------------------------------------------------------* *&      Form  fill_control_record *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM fill_control_record . * Make full in the details of sending arrangement * Client no   gs_idoc_control-mandt = sy-mandt. * Management of IDOC (Inbound)   gs_idoc_control-direct = g_c_in. * Sender port   gs_idoc_control-sndpor = g_c_sndpor. * Sender message type   gs_idoc_control-mestyp = g_c_mestyp. * Sender certificate/basic type   gs_idoc_control-doctyp = g_c_doctyp. * Partner number   gs_idoc_control-sndprn = p_part. * Partner type   gs_idoc_control-sndprt = g_c_sndprt. * Check if partner contour exists for sending system   Articulate gs_edk21.   gs_edk21-sndprn = gs_idoc_control-sndprn.   gs_edk21-sndprt = gs_idoc_control-sndprt.   gs_edk21-sndpfc = gs_idoc_control-sndpfc.   gs_edk21-mestyp = gs_idoc_control-mestyp.   gs_edk21-mescod = gs_idoc_control-mescod.   gs_edk21-mesfct = gs_idoc_control-mesfct.   gs_edk21-test   = gs_idoc_control-exam.   CALL FUNCTION 'EDI_AGREE_IN_MESSTYPE_READ'     EXPORTING       rec_edk21       = gs_edk21     IMPORTING       rec_edd21       = gs_edd21     EXCEPTIONS       db_error        = 1       entry_not_exist = 2       OTHERS          = 3.   IF sy-subrc <> 0.     WRITE: / 'Check the control record'(002).     STOP.   ENDIF. * Partner type   gs_idoc_control-rcvprt = g_c_rcvprt. * Partner no   gs_idoc_control-rcvprn = p_part. ENDFORM.                    " fill_control_record *&---------------------------------------------------------------------* *&      Course  read_data_from_file *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM read_data_from_file .   DATA : lv_string Type string,          lv_err_msg(100) TYPE c.   Articulate : gv_input_file, gt_final.   CONCATENATE p_import g_c_slash gs_dir_list-name               INTO gv_input_file.   IF gv_input_file IS Non INITIAL. * Open file to read information     Open up DATASET gv_input_file FOR INPUT IN TEXT Fashion ENCODING DEFAULT          Message lv_err_msg. * Check for return value.     IF sy-subrc =  0.                  "Fault in opening the file * Read data from file       DO.         READ DATASET gv_input_file INTO lv_string.         IF sy-subrc = 0.           CLEAR: gs_final, gs_final1. * Motility file data in to internal table format           gs_final1 = lv_string.           CONDENSE gs_final1-vbeln.           gs_final-vbeln = gs_final1-vbeln. * Catechumen the Commitment no from external format to internal format           CALL Part 'CONVERSION_EXIT_ALPHA_INPUT'             EXPORTING               input  = gs_final-vbeln             IMPORTING               output = gs_final-vbeln.           gs_final-lifex = gs_final1-lifex.           gs_final-traid = gs_final1-traid.           gs_final-bolnr = gs_final1-bolnr.           APPEND gs_final TO gt_final.           Articulate : gs_final,gs_final1.         ELSE.           EXIT.         ENDIF.       ENDDO.     ELSE.       WRITE: / 'Error opening the file'(005),  gv_input_file.       EXIT.     ENDIF. * Close the file later reading     Shut DATASET gv_input_file.   ENDIF. ENDFORM.                    " read_data_from_file *&---------------------------------------------------------------------* *&      Form  validate_data *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM validate_data .   TYPES : Begin OF lty_likp,           vbeln TYPE vbeln_vl,           End OF lty_likp.   DATA : lt_likp TYPE STANDARD Tabular array OF lty_likp,          ls_likp TYPE lty_likp.   IF gt_final[] IS NOT INITIAL. * Get the delivery no     SELECT vbeln       FROM likp       INTO Table lt_likp        FOR ALL ENTRIES IN gt_final       WHERE vbeln = gt_final-vbeln.     IF sy-subrc = 0.       SORT lt_likp BY vbeln.     ENDIF. * Validate the delivery no     LOOP AT gt_final INTO gs_final.       READ Tabular array lt_likp INTO ls_likp            WITH Key vbeln = gs_final-vbeln BINARY SEARCH.       IF sy-subrc <> 0.         WRITE :/ gs_final-vbeln, 'Delivery does not exists'(008).         gs_final-error = 'X'.         Alter gt_final FROM gs_final TRANSPORTING mistake.       ENDIF.     ENDLOOP.     Clear gt_lips. * Become the commitment item information     IF lt_likp[] IS Not INITIAL.       SELECT vbeln              posnr              matnr              lfimg         FROM lips         INTO Tabular array gt_lips          FOR ALL ENTRIES IN lt_likp        WHERE vbeln = lt_likp-vbeln          AND komkz NE space.       IF sy-subrc = 0.         SORT gt_lips BY vbeln.       ENDIF.     ENDIF.   ENDIF. ENDFORM.                    " validate_data *&---------------------------------------------------------------------* *&      Form  prepare_data *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* Course prepare_data .   LOOP AT gt_final INTO gs_final WHERE mistake = space. * Fill the data record of the IDOC     PERFORM fill_data_records USING gs_final. * Showtime the IDOC procedure     PERFORM start_idoc_process.   ENDLOOP. ENDFORM.                    " prepare_data *&---------------------------------------------------------------------* *&      Form  fill_data_records *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *      -->P_GS_FINAL  text *----------------------------------------------------------------------* FORM fill_data_records  USING i_gs_final TYPE ty_final.   DATA : ls_data TYPE edi_dd,          ls_e1edl20 Blazon e1edl20,          ls_e1edl18 Blazon e1edl18,          ls_e1edl24 Blazon e1edl24.   CLEAR gt_data. * Segment name : E1EDL2   ls_data-segnam   = g_c_e1edl20. * Fields to be pass to IDOC   ls_e1edl20-vbeln = i_gs_final-vbeln.   ls_e1edl20-lifex = i_gs_final-lifex.   ls_e1edl20-traty = g_c_traty.   ls_e1edl20-traid = i_gs_final-traid.   ls_e1edl20-bolnr = i_gs_final-bolnr.   ls_data-sdata    = ls_e1edl20.   APPEND ls_data TO gt_data.   CLEAR ls_data. * For adding the values of fields in file * Segment Name : 'E1EDL18'   ls_data-segnam = g_c_e1edl18. * Fields to be pass to IDOC   ls_e1edl18-qualf = g_c_chg. " For changing delivery.   ls_data-sdata  = ls_e1edl18.   Suspend ls_data TO gt_data.   Clear ls_data. * For picking the quantity * Segment Name : 'E1EDL18'   ls_data-segnam = g_c_e1edl18. * Fields to be pass to IDOC   ls_e1edl18-qualf = g_c_pic. " For picking the qty.   ls_data-sdata  = ls_e1edl18.   Suspend ls_data TO gt_data.   Clear ls_data. * For PGI processing * Segment Proper name : 'E1EDL18'   ls_data-segnam = g_c_e1edl18. * Fields to be pass to IDOC   ls_e1edl18-qualf = g_c_pgi. " For posting appurtenances issue   ls_data-sdata  = ls_e1edl18.   APPEND ls_data TO gt_data.   CLEAR ls_data.   CLEAR gs_lips.   LOOP AT gt_lips INTO gs_lips WHERE vbeln = i_gs_final-vbeln. * Segment Name : 'E1EDL24'     ls_data-segnam = g_c_e1edl24. * Fields to be pass to IDOC     ls_e1edl24-posnr = gs_lips-posnr.     ls_e1edl24-matnr = gs_lips-matnr.     ls_e1edl24-lfimg = gs_lips-lfimg.     ls_data-sdata  = ls_e1edl24.     APPEND ls_data TO gt_data.     Articulate ls_data.   ENDLOOP. ENDFORM.                    " fill_data_records *&---------------------------------------------------------------------* *&      Course  start_idoc_process *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM start_idoc_process .   DATA : lv_idoc_num   Blazon edidc-docnum,          lv_app_err    TYPE edi_help-error_flag,          lv_status     TYPE edids,          lv_msg_id     TYPE t100-arbgb,          lv_msg_no     TYPE t100-msgnr,          lv_msg1       TYPE lotion-msgv1,          lv_msg2       Type balm-msgv2,          lv_msg3       TYPE balm-msgv3,          lv_msg4       TYPE balm-msgv4. * Phone call entering processing for transferred IDoc   Phone call FUNCTION 'IDOC_INBOUND_SYNCHRONOUS'     EXPORTING       int_edidc                     = gs_idoc_control       online                        = 'B'     IMPORTING       docnum                        = lv_idoc_num       error_before_call_application = lv_app_err     TABLES       int_edidd                     = gt_data     EXCEPTIONS       idoc_not_saved                = 1       OTHERS                        = 2.   IF sy-subrc <> 0 AND      sy-msgid IS NOT INITIAL AND      sy-msgno IS Not INITIAL.     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.   ENDIF.   IF lv_idoc_num IS NOT INITIAL. * Open IDoc for reading     Call FUNCTION 'EDI_DOCUMENT_OPEN_FOR_READ'       EXPORTING         document_number         = lv_idoc_num       IMPORTING         idoc_control            = gs_edidc       EXCEPTIONS         document_foreign_lock   = i         document_not_exist      = 2         document_number_invalid = 3         OTHERS                  = 4.     IF sy-subrc <> 0 AND        sy-msgid IS NOT INITIAL AND        sy-msgno IS Not INITIAL.       Message ID sy-msgid TYPE sy-msgty NUMBER sy-msgno               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.     ENDIF. * Read last/current status record for IDoc     Telephone call Role 'EDI_DOCUMENT_READ_LAST_STATUS'       EXPORTING         document_number        = lv_idoc_num       IMPORTING         status                 = lv_status       EXCEPTIONS         document_not_open      = 1         no_status_record_found = 2         OTHERS                 = 3.     IF sy-subrc <> 0 AND        sy-msgid IS Non INITIAL AND        sy-msgno IS NOT INITIAL.       Bulletin ID sy-msgid Blazon sy-msgty NUMBER sy-msgno              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.     ELSE.       gs_alv-docnum = lv_idoc_num.       gs_alv-status = lv_status-status.       lv_msg_id = lv_status-stamid.       lv_msg_no = lv_status-stamno.       lv_msg1   = lv_status-stapa1.       lv_msg2   = lv_status-stapa2.       lv_msg3   = lv_status-stapa3.       lv_msg4   = lv_status-stapa4.       Telephone call Role 'MESSAGE_PREPARE'         EXPORTING           linguistic communication               = sy-langu           msg_id                 = lv_msg_id           msg_no                 = lv_msg_no           msg_var1               = lv_msg1           msg_var2               = lv_msg2           msg_var3               = lv_msg3           msg_var4               = lv_msg4         IMPORTING           msg_text               = gs_alv-msg_txt         EXCEPTIONS           function_not_completed = 1           message_not_found      = ii           OTHERS                 = 3.       IF sy-subrc <> 0 AND              sy-msgid IS Non INITIAL AND              sy-msgno IS Non INITIAL.         Message ID sy-msgid TYPE sy-msgty NUMBER sy-msgno                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.       ENDIF.       APPEND gs_alv TO gt_alv.       Articulate gs_alv.     ENDIF.   ENDIF. ENDFORM.                    " start_idoc_process *&---------------------------------------------------------------------* *&      Form  get_files_from_dir *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* Form get_files_from_dir .   DATA: lv_dir_name  TYPE epsf-epsdirnam,              lv_file_mask TYPE epsf-epsfilnam,              lv_msg_id     Blazon t100-arbgb,              lv_msg_no     Type t100-msgnr,              lv_msg1       Type balm-msgv1,              lv_msg2       TYPE balm-msgv2,              lv_msg3       Type balm-msgv3,              lv_msg4       TYPE balm-msgv4,              lv_error(75)  Blazon c. * To read all the files related   lv_dir_name = p_import.   lv_file_mask = p_prefix.   CALL Function 'EPS_GET_DIRECTORY_LISTING'     EXPORTING       dir_name               = lv_dir_name       file_mask              = lv_file_mask     TABLES       dir_list               = gt_dir_list     EXCEPTIONS       invalid_eps_subdir     = 1       sapgparam_failed       = ii       build_directory_failed = 3       no_authorization       = 4       read_directory_failed  = five       too_many_read_errors   = 6       empty_directory_list   = 7       OTHERS                 = 8.   IF sy-subrc <> 0.     lv_msg_id = sy-msgid.     lv_msg_no = sy-msgno.     lv_msg1   = sy-msgv1.     lv_msg2   = sy-msgv2.     lv_msg3   = sy-msgv3.     lv_msg4   = sy-msgv4.     CALL Office 'MESSAGE_PREPARE'       EXPORTING         language               = sy-langu         msg_id                 = lv_msg_id         msg_no                 = lv_msg_no         msg_var1               = lv_msg1         msg_var2               = lv_msg2         msg_var3               = lv_msg3         msg_var4               = lv_msg4       IMPORTING         msg_text               = lv_error       EXCEPTIONS         function_not_completed = 1         message_not_found      = two         OTHERS                 = iii.     IF sy-subrc <> 0 AND      sy-msgid IS NOT INITIAL AND      sy-msgno IS NOT INITIAL.       Bulletin ID sy-msgid TYPE sy-msgty NUMBER sy-msgno               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.     ENDIF.     WRITE:/ lv_error.   ENDIF.   IF gt_dir_list IS INITIAL.     WRITE: / 'No files constitute in the Application server Path'(101).     STOP.   ENDIF. ENDFORM.                    " get_files_from_dir *&---------------------------------------------------------------------* *&      Form  display_log *&---------------------------------------------------------------------* *       text *----------------------------------------------------------------------* *  -->  p1        text *  <--  p2        text *----------------------------------------------------------------------* FORM display_log .   NEW-LINE.   FORMAT Color COL_HEADING INTENSIFIED.   IF gt_alv[] IS Not INITIAL.     ULINE AT 1(100).     WRITE: /1 '|', 'IDOC Number'(011),            25 '|', 'Status'(012),            35 '|', 'IDOC Message'(013),            100 '|'.     FORMAT Colour INTENSIFIED OFF.     NEW-LINE.     ULINE AT 1(100).   ENDIF.   LOOP AT gt_alv INTO gs_alv.     WRITE :/i '|', gs_alv-docnum,            25 '|', gs_alv-status,            35 '|', gs_alv-msg_txt,            100 '|'.   ENDLOOP.   NEW-LINE.   IF gt_alv[] IS Non INITIAL.     ULINE AT one(100).   ENDIF. ENDFORM.                    " display_log                  

Sample Test record :

10001067            0003205670123456782013-05-08SORTE               4200233093055200934079000123456780

threlkeldpless1969.blogspot.com

Source: https://blogs.sap.com/2014/03/20/step-by-step-guide-for-file-to-idoc-scenario-by-using-custom-program/