SERVICE PO CREATION (ME21N) USING BAPI




*&---------------------------------------------------------------------*

*& Report ZMM_REP_MS_PO_CREATE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm_rep_ms_po_create.

INCLUDE ZMM_INC_PO_CREATE_TOP.

INCLUDE ZMM_INC_PO_CREATE_SCREEN.

INCLUDE ZMM_INC_PO_CREATE_GET.

*&---------------------------------------------------------------------*
*& Include          ZMM_INC_PO_CREATE_TOP
*&---------------------------------------------------------------------*

*----------------------------------------------------------------*
**LOCAL vairable Declaration
*----------------------------------------------------------------*
*Excel Declaration
DATAlvh_excel TYPE ole2_object,            "Excel object
      lvh_mapl  TYPE ole2_object,            "list of workbooks
      lvh_map   TYPE ole2_object,            "workbook
      lvh_zl    TYPE ole2_object,            "cell
      lvh_f     TYPE ole2_object.            "font

DATAit_head      TYPE TABLE OF bapimepoheader,
      wa_head      TYPE bapimepoheader,
      it_headx     TYPE TABLE OF bapimepoheaderx,
      wa_headx     TYPE bapimepoheaderx,
      it_poitem    TYPE TABLE OF bapimepoitem,
      wa_poitem    TYPE bapimepoitem,
      it_poitemx   TYPE TABLE OF bapimepoitemx,
      wa_poitemx   TYPE bapimepoitemx,
      it_poshdl    TYPE TABLE OF bapimeposchedule,
      it_poshdlx   TYPE TABLE OF bapimeposchedulx,
      wa_poshdl    TYPE bapimeposchedule,
      wa_poshdlx   TYPE bapimeposchedulx,
      it_acct      TYPE TABLE OF bapimepoaccount,
      wa_acct      TYPE bapimepoaccount,
      it_acctx     TYPE TABLE OF bapimepoaccountx,
      wa_acctx     TYPE bapimepoaccountx,
      it_servc     TYPE TABLE OF bapiesllc,
      wa_servc     TYPE bapiesllc,
      it_servc_val TYPE TABLE OF bapiesklc,
      wa_servc_val TYPE bapiesklc,
      gv_line      TYPE etenr,
      gv_FNAME     LIKE  thead-tdname,
      it_FLINES    TYPE TABLE OF  tline,
      wa_FLINES     TYPE tline,
      gv_po        TYPE bapimepoheader-po_number,
      git_fieldcat TYPE slis_t_fieldcat_alv,
      gs_fieldcat  TYPE slis_fieldcat_alv,
      gs_layout    TYPE slis_layout_alv,
      it_HEADERtxt TYPE TABLE OF  bapimepotextheader,
      wa_HEADERtxt TYPE   bapimepotextheader,
      it_ITEMtxt   TYPE TABLE OF  bapimepotext,
      wa_ITEMtxt   TYPE  bapimepotext,
      gv_PCKGNO     TYPE  packno VALUE '0000000000',
      gv_SUBPCKG   TYPE sub_packno VALUE '0000000001'.



TYPESBEGIN OF ty_data,
         sr_no          TYPE int4,
         comp_code      TYPE bapimepoheader-comp_code,
         doc_type       TYPE bapimepoheader-doc_type,
         vendor         TYPE bapimepoheader-vendor,
         purch_org      TYPE bapimepoheader-purch_org,
         pur_group      TYPE bapimepoheader-pur_group,
         doc_date       TYPE bapimepoheader-doc_date,
         pmnttrms       TYPE bapimepoheader-pmnttrms,
         doc_curr       TYPE bapimepoheader-currency_iso,
         incoterms      TYPE bapimepoheader-incoterms2l,
         incoterm_loc   TYPE bapimepoheader-incoterms3l,
         sales_pers     TYPE bapimepoheader-sales_pers,
         ref_1          TYPE bapimepoheader-ref_1,
         our_ref        TYPE bapimepoheader-our_ref,
         head_txt       TYPE tline,
         head_note_txt  TYPE tline,
         head_dln_txt   TYPE tline,
         po_item        TYPE bapimepoitem-po_item,
         acctasscat     TYPE bapimepoitem-acctasscat,
         item_cat       TYPE bapimepoitem-item_cat,
         material       TYPE bapimepoitem-material,
         short_text     TYPE bapimepoitem-short_text,
         matl_group     TYPE bapimepoitem-matl_group,
         qty_item       TYPE bapimepoitem-quantity,
         net_price      TYPE bapimepoitem-net_price,
         delivery_date  TYPE bapimeposchedule-delivery_date,
         po_unit        TYPE bapimepoitem-po_unit,
         plant          TYPE bapimepoitem-plant,
         stge_loc       TYPE bapimepoitem-stge_loc,
         tax_code       TYPE bapimepoitem-tax_code,
         inv_recp       TYPE bapimepoitem-ir_ind,
         gr_basediv     TYPE bapimepoitem-gr_basediv,
         srv_based_iv   TYPE bapimepoitem-srv_based_iv,
         serv_line      TYPE bapiesllc-ext_line,
         ser_no         TYPE bapiesllc-service,
         serv_quant     TYPE bapiesllc-quantity,
         serv_uom       TYPE bapiesllc-base_uom,
         gr_price       TYPE bapiesllc-gr_price,
         tax_code_srv   TYPE bapiesllc-tax_code,
         gl_account     TYPE bapimepoaccount-gl_account,
         costcenter     TYPE  bapimepoaccount-costcenter,
         wbs_element    TYPE  bapimepoaccount-wbs_element,
         item_txt       TYPE tline,
         item_matpo_txt TYPE tline,
         item_dlvr_txt  TYPE tline,
       END OF ty_data.

DATAit_data    TYPE TABLE OF ty_data,
      it_service TYPE TABLE OF ty_data,
      wa_data    TYPE ty_data,
      wa_service TYPE ty_data,
      it_rawdata TYPE truxs_t_text_data,
      it_return  TYPE TABLE OF bapiret2,
      wa_return  TYPE bapiret2.

TYPESBEGIN OF ty_sr,
         sr_no TYPE int4,
       END OF ty_sr.

DATAit_ser TYPE TABLE OF ty_sr,
      wa_ser TYPE ty_sr.


TYPESBEGIN OF ty_final,
         sr_no   TYPE int4,
         po      TYPE ekko-ebeln,
         remarks TYPE string,
       END OF ty_final.

DATAit_final TYPE TABLE OF ty_final,
      wa_final TYPE ty_final.



*&---------------------------------------------------------------------*
*& Include         ZMM_INC_PO_CREATE_SCREEN
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------------------
** Table Declaration
*----------------------------------------------------------------------------------
TABLESsscrfields.
TYPE-POOLS:slis,truxs.

SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
  PARAMETERSp_file TYPE rlgrap-filename.
  SELECTION-SCREEN SKIP.
  PARAMETERS p_test AS CHECKBOX USER-COMMAND p1.
SELECTION-SCREEN:END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
  SELECTION-SCREEN PUSHBUTTON 1(70cmdgen USER-COMMAND a_gen VISIBLE LENGTH 30.
SELECTION-SCREEN END OF BLOCK b2.

*----------------------------------------------------------------*
** INITIALIZATION
*----------------------------------------------------------------*
INITIALIZATION.

  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name   icon_xxl
      text   'Generate Template'
      info   'Generate Excel File Template'
    IMPORTING
      result cmdgen
    EXCEPTIONS
      OTHERS 0.

*----------------------------------------------------------------*
** AT SELECTION-SCREEN
*----------------------------------------------------------------*
AT SELECTION-SCREEN.

*Transaction Code Check at Transaction Start
  AUTHORITY-CHECK OBJECT 'S_TCODE'
          ID 'TCD' FIELD 'ME21N'.
  IF sy-subrc <> 0.
    MESSAGE TEXT-008 TYPE 'E'.
  ENDIF.

  AUTHORITY-CHECK OBJECT 'S_TCODE'
          ID 'TCD' FIELD 'ZSED_MM_PO_UPLOAD'.
  IF sy-subrc <> 0.
    MESSAGE TEXT-009 TYPE 'E'.
  ENDIF.

  IF sscrfields 'A_GEN'.
    PERFORM generate_template.
  ENDIF.

*&---------------------------------------------------------------------*
*& Form generate_template
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM generate_template .

* start Excel
  CREATE OBJECT lvh_excel 'EXCEL.APPLICATION'.
  SET PROPERTY OF lvh_excel 'Visible' 1.

* get list of workbooks, initially empty
  CALL METHOD OF
    lvh_excel
      'Workbooks' lvh_mapl.
  PERFORM err_hdl.

* add a new workbook
  CALL METHOD OF
    lvh_mapl
      'Add' lvh_map.

  PERFORM err_hdl.
  PERFORM fill_cell USING'Serial No',
                           'Company code ',
                           'Po Document Type',
                           'Supplier Number',
                           'Purchase organization',
                           'Purchasing Group',
                           'Purchasing document date',
                           'Terms of Payment',
                           'Doc Currency',
                           10 'Inco Terms',
                           11 'Inco terms location 1',
                           12 'Sales Person',
                           13 'Your reference',
                           14 'Our Reference',
                           15 'Header Text',
                           16 'Hedaer Note Text',
                           17 'Deadlines Text',
                           18 'Item number of document',
                           19 'Account Assignment',
                           20 'Item Category',
                           21 'Material Number',
                           22 'Short text',
                           23 'Material group',
                           24 'Quantity',
                           25 'NetPrice',
                           26 'Delivery Date',
                           27 'Order Unit',
                           28 'Plant',
                           29 'Storage location',
                           30 'Tax code',
                           31 'Invoice receipt',
                           32 'GR-Based',
                           33 'S-Based',
                           34 'Serial Number',
                           35 'Service Number',
                           36 'Quantity',
                           37 'UOM',
                           38 'Gross Price',
                           39 'Tax Code_service',
                           40 'G/L Account Number',
                           41 'Cost Center',
                           42 'WBS Element',
                           43 'ITEM TEXT',
                           44 'Material Po Text',
                           45 'Delivery Text'.

  MESSAGE TEXT-007 TYPE 'S'.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form err_hdl -
*&---------------------------------------------------------------------*
*& text FORM - ERR_HDL used for error handling when generating excel file
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM err_hdl .
  IF sy-subrc <> 0.
    CALL METHOD OF
      lvh_excel
      'QUIT'.
    FREE OBJECT lvh_excel.
    lvh_excel-handle -1.
    MESSAGE'Failed to generate template.' TYPE 'E'.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form fill_cell
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
FORM fill_cell  USING j bold val.
  CALL METHOD OF
      lvh_excel
      'Cells' lvh_zl
    EXPORTING
      #1      i
      #2      j.
  PERFORM err_hdl.
  SET PROPERTY OF lvh_zl 'Value' val .
  PERFORM err_hdl.
  GET PROPERTY OF lvh_zl 'Font' lvh_f.
  PERFORM err_hdl.
  SET PROPERTY OF lvh_f 'Bold' bold .
  PERFORM err_hdl.
ENDFORM.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  syst-cprog
      dynpro_number syst-dynnr
      field_name    ''
    IMPORTING
      file_name     p_file.

START-OF-SELECTION.
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR    =
      i_line_header        'X'
      i_tab_raw_data       it_rawdata
      i_filename           p_file
    TABLES
      i_tab_converted_data it_data[]
    EXCEPTIONS
      conversion_failed    1
      OTHERS               2.
  IF sy-subrc <> 0.
    MESSAGE TEXT-001 TYPE 'E'.
  ENDIF.

*&---------------------------------------------------------------------*
*& Include          ZMM_INC_PO_CREATE_GET
*&---------------------------------------------------------------------*

MOVE-CORRESPONDING it_data[] TO it_ser[].
MOVE-CORRESPONDING it_data[] TO it_service[].

SORT it_ser.
DELETE ADJACENT DUPLICATES FROM it_ser COMPARING ALL FIELDS.

LOOP AT it_ser INTO wa_ser.

  LOOP AT it_data INTO wa_data WHERE sr_no EQ wa_ser-sr_no.

    IF wa_head IS INITIAL.
      wa_head-comp_code wa_data-comp_code.
      wa_head-doc_type  wa_data-doc_type.
      wa_head-vendor    wa_data-vendor.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  wa_head-vendor
        IMPORTING
          output wa_head-vendor.

      wa_head-purch_org    wa_data-purch_org.
      wa_head-pur_group    wa_data-pur_group.
      wa_head-doc_date     wa_data-doc_date.
      wa_head-pmnttrms     wa_data-pmnttrms.
      wa_head-currency_iso =  wa_data-doc_curr.
      wa_head-incoterms2l  =  wa_data-incoterms.
      wa_head-incoterms3l  =  wa_data-incoterm_loc.
      wa_head-sales_pers   =  wa_data-sales_pers.
      wa_head-ref_1        wa_data-ref_1.
      wa_head-our_ref      =  wa_data-our_ref.

      wa_headx-comp_code 'X'.
      wa_headx-doc_type  'X'.
      wa_headx-vendor    'X'.
      wa_headx-purch_org 'X'.
      wa_headx-pur_group 'X'.
      wa_headx-doc_date  'X'.
      IF wa_head-pmnttrms IS NOT INITIAL.
        wa_headx-pmnttrms  'X'.
      ENDIF.
      wa_headx-currency_iso =  'X'.
      wa_headx-incoterms2l  =  'X'.
      wa_headx-incoterms3l  =  'X'.
      wa_headx-sales_pers   =  'X'.
      wa_headx-ref_1        'X'.
      wa_headx-our_ref      =  'X'.

      CLEARwa_headertxt.
      wa_headertxt-text_id    'F01'.
      wa_headertxt-text_form  '*'.
      wa_headertxt-text_line  wa_data-head_txt.
      APPEND wa_headertxt TO it_headertxt.

      CLEARwa_headertxt.
      wa_headertxt-text_id     'F02'.
      wa_headertxt-text_form   '*'.
      wa_headertxt-text_line   wa_data-head_note_txt.
      APPEND wa_headertxt TO it_headertxt.

      CLEARwa_headertxt.
      wa_headertxt-text_id     'F04'.
      wa_headertxt-text_form   '*'.
      wa_headertxt-text_line   wa_data-head_dln_txt.
      APPEND wa_headertxt TO it_headertxt.

    ENDIF.

    READ TABLE it_poitem INTO wa_poitem WITH KEY po_item wa_data-po_item.
    IF sy-subrc <> 0.
      wa_poitem-po_item    wa_data-po_item.
      wa_poitem-acctasscat wa_data-acctasscat.
      wa_poitem-item_cat   wa_data-item_cat.
      wa_poitem-material   wa_data-material.
      wa_poitem-short_text wa_data-short_text.
      wa_poitem-matl_group wa_data-matl_group.
      IF wa_data-qty_item IS NOT INITIAL.
        wa_poitem-quantity wa_data-qty_item.
      ENDIF.

      IF wa_data-net_price IS NOT INITIAL.
        wa_poitem-net_price wa_data-net_price.
      ENDIF.

      wa_poitem-price_date   wa_data-delivery_date.
      wa_poitem-po_unit      wa_data-po_unit.
      wa_poitem-plant        =  wa_data-plant.
      wa_poitem-stge_loc     wa_data-stge_loc.
      wa_poitem-tax_code     wa_data-tax_code.
      wa_poitem-ir_ind       wa_data-inv_recp.
      wa_poitem-gr_basediv   wa_data-gr_basediv.
      wa_poitem-srv_based_iv wa_data-srv_based_iv.
      wa_poitem-period_ind_expiration_date  'D'.

      gv_PCKGNO gv_PCKGNO + 1.
      wa_poitem-pckg_no gv_PCKGNO"'0000000001'.
      APPEND wa_poitem TO it_poitem.

      wa_poitemx-po_item     wa_data-po_item.
      wa_poitemx-po_itemx    'X'.
      wa_poitemx-acctasscat  'X'.
      wa_poitemx-item_cat    'X'.
      wa_poitemx-material    'X'.
      wa_poitemx-short_text  'X'.
      wa_poitemx-matl_group  'X'.
      IF wa_data-qty_item IS NOT INITIAL.
        wa_poitemx-quantity  'X'.
      ENDIF.

      IF wa_data-net_price IS NOT INITIAL.
        wa_poitemx-net_price 'X'.
      ENDIF.

      wa_poitemx-price_date   'X'.
      wa_poitemx-po_unit      'X'.
      wa_poitemx-plant        'X'.
      wa_poitemx-stge_loc     'X'.
      wa_poitemx-tax_code     'X'.
      wa_poitemx-ir_ind       'X'.
      wa_poitemx-gr_basediv   'X'.
      wa_poitemx-srv_based_iv 'X'.
      wa_poitemx-period_ind_expiration_date  'X'.
      wa_poitemx-pckg_no      'X'.
      APPEND wa_poitemx TO it_poitemx.

      wa_acct-po_item  wa_data-po_item.
      wa_acct-serial_no '01'.
      wa_acct-gl_account wa_data-gl_account.
      wa_acct-costcenter  wa_data-costcenter.
      wa_acct-wbs_element wa_data-wbs_element.
      APPEND wa_acct TO it_acct.

      wa_acctx-po_item  wa_data-po_item.
      wa_acctx-serial_no '01'.
      wa_acctx-gl_account 'X'.
      wa_acctx-costcenter  'X'.
      wa_acctx-wbs_element 'X'.
      APPEND wa_acctx TO it_acctx.

      wa_poshdl-po_item wa_data-po_item.
      wa_poshdl-delivery_date wa_data-delivery_date.
      APPEND wa_poshdl TO it_poshdl.

      wa_poshdlx-po_item wa_data-po_item.
      wa_poshdlx-po_itemx 'X'.
      wa_poshdlx-delivery_date 'X'.
      APPEND wa_poshdlx TO it_poshdlx.

      CLEARwa_itemtxt.
      wa_itemtxt-po_item       wa_data-po_item.
      wa_itemtxt-text_id       'F01'.
      wa_itemtxt-text_form       '*'.
      wa_itemtxt-text_line      wa_data-item_txt.
      APPEND wa_itemtxt TO it_itemtxt.

      CLEARwa_itemtxt.
      wa_itemtxt-po_item       wa_data-po_item.
      wa_itemtxt-text_id       'F03'.
      wa_itemtxt-text_form       '*'.
      wa_itemtxt-text_line      wa_data-item_matpo_txt.
      APPEND wa_itemtxt TO it_itemtxt.

      CLEARwa_itemtxt.
      wa_itemtxt-po_item       wa_data-po_item.
      wa_itemtxt-text_id       'F04'.
      wa_itemtxt-text_form       '*'.
      wa_itemtxt-text_line      wa_data-item_dlvr_txt.
      APPEND wa_itemtxt TO it_itemtxt.

      gv_SUBPCKG =  gv_SUBPCKG + 1.
      wa_servc-pckg_no gv_PCKGNO" '0000000001'.
      wa_servc-line_no '0000000001'.
      wa_servc-outl_ind 'X'.
      wa_servc-subpckg_no gv_SUBPCKG.
      APPEND wa_servc TO it_servc.

      gv_line '0000000001'.
      LOOP AT it_service INTO wa_service WHERE sr_no wa_data-sr_no AND po_item wa_data-po_item.

        wa_servc-pckg_no gv_SUBPCKG"'0000000002'.
        gv_line gv_line + 1.
        wa_servc-line_no gv_line.
        WA_servc-ext_line wa_service-serv_line.
        WA_servc-service wa_service-ser_no.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  WA_servc-service
          IMPORTING
            output WA_servc-service.

        WA_servc-quantity wa_service-serv_quant.
        WA_servc-base_uom wa_service-serv_uom.
        WA_servc-gr_price wa_service-gr_price.
        WA_servc-tax_code wa_service-tax_code_srv.

        wa_servc_val-pckg_no gv_SUBPCKG"'0000000002'.
        wa_servc_val-line_no wa_servc-line_no.
        wa_servc_val-serno_line '01'.
        wa_servc_val-percentage '100.0'.
        wa_servc_val-serial_no  '01'.

        APPEND  wa_servc_val TO  it_servc_val.
        APPEND   WA_servc TO  it_servc.

        CLEARwa_servc,wa_servc_val.
      ENDLOOP.

      CLEARwa_itemtxtwa_poitemwa_poitemx,wa_acct,wa_acctx,wa_poshdl,wa_poshdlx,gv_line,wa_itemtxt.
    ENDIF.

    CLEARwa_data,wa_headertxt.
  ENDLOOP.


  CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
      poheader          wa_head
      poheaderx         wa_headx
    IMPORTING
      exppurchaseorder  gv_po
    TABLES
      return            it_return
      poitem            it_poitem
      poitemx           it_poitemx
      poschedule        it_poshdl
      poschedulex       it_poshdlx
      poaccount         it_acct
      poaccountx        it_acctx
      poservices        it_servc
      posrvaccessvalues it_servc_val
      potextheader      it_headertxt
      potextitem        it_itemtxt.

  IF p_test IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait 'X'.
  ENDIF.

  READ TABLE it_return INTO wa_return WITH KEY Type 'E'.
  IF sy-subrc EQ 0.
    wa_final-sr_no wa_ser-sr_no.
    wa_final-remarks wa_return-message.
    APPEND wa_final TO it_final.
    CLEAR:wa_final.
  ENDIF.

  IF gv_po IS NOT INITIAL.
    wa_final-sr_no wa_ser-sr_no.
    wa_final-remarks TEXT-006.
    wa_final-po gv_po.
    APPEND wa_final TO it_final.
  ENDIF.

  CLEARwa_headwa_headx,wa_data,wa_ser,gv_po,wa_final,gv_fname,gv_SUBPCKG,gv_PCKGNO.
  REFRESHit_poshdl,it_poshdlx,it_acct,it_acctx,it_servc,it_servc_val,it_poitem,it_poitemx,it_return,it_flines,it_itemtxt,it_headertxt.
ENDLOOP.



gs_fieldcat-col_pos '1'.
gs_fieldcat-fieldname 'SR_NO' .
gs_fieldcat-tabname TEXT-005.
gs_fieldcat-seltext_l TEXT-002.
APPEND gs_fieldcat TO git_fieldcat.
CLEAR gs_fieldcat.

gs_fieldcat-col_pos '2'.
gs_fieldcat-fieldname 'PO' .
gs_fieldcat-tabname TEXT-005.
gs_fieldcat-seltext_l TEXT-003.
APPEND gs_fieldcat TO git_fieldcat.
CLEAR gs_fieldcat.

gs_fieldcat-col_pos '3'.
gs_fieldcat-fieldname 'REMARKS' .
gs_fieldcat-tabname TEXT-005.
gs_fieldcat-seltext_l TEXT-004.
APPEND gs_fieldcat TO git_fieldcat.
CLEAR gs_fieldcat.

gs_layout-no_input 'X'.
gs_layout-colwidth_optimize 'X'.
gs_layout-zebra 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program sy-repid
    is_layout          gs_layout
    it_fieldcat        git_fieldcat
    i_save             'A'
  TABLES
    t_outtab           it_final
  EXCEPTIONS
    program_error      1
    OTHERS             2.
IF sy-subrc <> 0.
* Implement suitable error handling here
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Comments

Popular posts from this blog

PO rejection notification & rejection comments for Fiori

FB60 Vendor Invoice Post using BAPI

Service Invoice Upload For FB70 (BAPI)