JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
22 days ago10 views
💻Technology
METHOD if_ex_cl_nfe_print~fill_header.

************************************************************************
*  Program Title       : Nota Fiscal Electronica - XML                 *
*  Author              : Shuktara Banerjee                             *
*  Date                : 22nd Dec 2017                                 *
*  SAP Change Request #: DE9K900800                                    *
*----------------------------------------------------------------------*
*  Description         : Nota Fiscal Electronica - XML                 *
*  Type:               : Report / Program                              *
*  Run Frequency       :                                               *
*  Development Class:  : ZV7744_NOTA_FISCAL_XML                        *
*  Requirement Ref.    :                                               *
*----------------------------------------------------------------------*
*  INPUTS              : Screen                                        *
*  Variants            :                                               *
*  Input file name     : N/A                                           *
*  Other               :                                               *
*----------------------------------------------------------------------*
*  OUTPUTS             :                                               *
*  Files               : N/A                                           *
*  Errors              :                                               *
*  Other               :                                               *
*----------------------------------------------------------------------*
* MODIFICATION HISTORY                                                 *
* SAP Change Request #:  DE9K909063                                    *
* Change Driver       :  CHG0070778                                    *
* Author              :  Shuktara Banerjee                             *
* Modification Date   :  18-Sep-2018                                   *
* Description         :  Pass the state tax number for the STO process *
* Search String       :  CHG0070778                                    *
************************************************************************
* MODIFICATION HISTORY                                                 *
* SAP Change Request #:  DE9K909696                                    *
* Change Driver       :  CHG0071806                                    *
* Author              :  Shuktara Banerjee                             *
* Modification Date   :  09-Sep-2018                                   *
* Description         :  Changes for the values text and volume for STO*
* Search String       :  CHG0071806                                    *
************************************************************************
* SAP Change Request #:  DE9K912468                                    *
* Change Driver       :  CHG0075774                                    *
* Author              :  Neela Shirisha                                *
* Modification Date   :  12-Feb-2019                                   *
* Description         :  Add Extra header fields in XML sent           *
* Search String       :  CR#CHG0075774                                 *
************************************************************************
* SAP Change Request #:  DE9K914152                                    *
* Change Driver       :  CHG0077990                                    *
* Author              :  Neela Shirisha                                *
* Modification Date   :  16/04/2019                                    *
* Description         :  Net Due date change logic                     *
* Search String       :  CR#CHG0077990                                 *
************************************************************************
* SAP Change Request #:  DEYK916702                                    *
* Change Driver       :  OM_BR_NT2020.006                              *
* Author              :  Joao Christianini                             *
* Modification Date   :  23/03/2021                                    *
* Description         :  Fill new fields: ind_pres & indintermed       *
* Search String       :  OM_BR_NT2020.006                              *
************************************************************************
*  SAP Change Request #:   CHG1022035                                  *
*  Service Request/Task:   DEYK922784                                  *
*  Author              :   Sanjay Sontakke                             *
*  Modification Date   :   10/06/21                                    *
*  Description         :   Verity purchase order number exhibition in  *
*                          NOTA FISCAL XML for Sales                   *
*  Search String.......:   CHG1022035                                  *
************************************************************************
*  SAP Change Request #:   CHG1035938                                  *
*  Service Request/Task:   DEYK931028                                  *
*  Author              :   Mohammed Khan                               *
*  Modification Date   :   09/06/22                                    *
*  Description         :   Populate the text in XML and PDF            *
*  Search String.......:   CHG1035938                                  *
************************************************************************
*  SAP Change Request #:   CHG1048714                                  *
*  Service Request/Task:   DEYK937814,DEYK938403,DEYK938995,DEYK939254,*
*                          DEYK940004                                  *
*  Author              :   Ambrish C                                   *
*  Modification Date   :   05/04/23                                    *
*  Description         :   To fulfill field Espécie in the Nota Fiscal *
*  Search String.......:   CHG1048714                                  *
************************************************************************
*  SAP Change Request #:   CHG105746                                   *
*  Service Request/Task:   DEYK941881                                  *
*  Author              :   Ramakanta                                   *
*  Modification Date   :   10/19/23                                    *
*  Description         :   Revert DEYK941602 changes                   *
*  Search String.......:   CHG105746                                   *
************************************************************************
*   Include for the data declarations
    INCLUDE zvgti7744_nfxml_top. " Include ZVGTI7744_NFXML_TOP

*   Include for the Nota fiscal table updates.
    INCLUDE zvgti7744_nfxml_tab. " Include ZVGTI7744_NFXML_TAB

** Start of Changes for CR#CHG0075774
* Internal table and structure for the BSEG data
    TYPES: BEGIN OF l_ty_bseg,
             buzei TYPE buzei,
             bschl TYPE bschl,
** Start of Changes for CR#CHG0077990
             shkzg TYPE shkzg,
             dmbtr TYPE dmbtr,
             zfbdt TYPE dzfbdt,
             zbd1t TYPE dzbd1t,
             zbd2t TYPE dzbd2t,
             zbd3t TYPE dzbd3t,
             rebzg TYPE rebzg,
*          fdtag TYPE fdtag,
** End of Changes for CR#CHG0077990
           END OF l_ty_bseg,
           l_tt_bseg TYPE TABLE OF l_ty_bseg.

    DATA: l_it_bseg   TYPE l_tt_bseg,
          l_it_bseg1  TYPE l_tt_bseg,
          l_st_bseg   TYPE l_ty_bseg,
          l_out_bseg  TYPE j1b_nf_xml_u3,
          l_belnr     TYPE belnr_d,
          lv_item_num TYPE char3,
          lv_faedt    TYPE faedt_fpos.             "CR#CHG0077990

    CONSTANTS: l_c_nftype_z1 TYPE zd_exec_key VALUE 'Z_7744_FAT_NFTYPE',
*Begin of CHG1048714 | INSERT.
               lc_vbtyp_n    TYPE vbfa-vbtyp_n VALUE '7',
               lc_vbtyp_v    TYPE vbfa-vbtyp_v VALUE 'J',
               lc_carton     TYPE char18  VALUE 'CARTON',
               lc_p_carton   TYPE char18  VALUE 'CAIXA',
               lc_pallet     TYPE char18  VALUE 'PALLET',
               lc_p_pallet   TYPE char18  VALUE 'PALETE'.
*End of CHG1048714 | INSERT
** End of Changes for CR#CHG0075774

*   --- Begin of Change - OM_BR_NT2020.006
    CONSTANTS: lc_ind_pres    TYPE j_1bnfe_indpres      VALUE '9',
               lc_indintermed TYPE j_1bnfe_ind_intermed VALUE '0'.
*   --- End of Change - OM_BR_NT2020.006

*   ---------------------   PROCESSING LOGIC --------------------------*
*   --- Begin of Change - Def 501
    MOVE-CORRESPONDING in_xml_header TO out_header.
    MOVE-CORRESPONDING in_doc TO out_header.
    it_item1[] = it_item[].
    DELETE it_item1 WHERE refkey IS INITIAL.
    it_item[] = it_item1[].
    READ TABLE it_item INTO st_item
    INDEX 1.
    IF sy-subrc = 0.
*     ----  Begin of Change - Def 2717
      CLEAR st_control.
*     Retrieve the Reference types from the control table
      SELECT *
        UP TO 1 ROWS
        FROM ztvgt_control
        INTO st_control
        WHERE exec_key = c_reftyp.
      ENDSELECT.
      IF sy-subrc = 0.
*       Check for the type 'BI'
        IF st_item-reftyp = st_control-value1.
*         ----  End of Change - Def 2717
*         Get the delivery number from the first line for the
*         Invoice reference key
          SELECT vgbel " Document number of the reference document
                 aubel " Sales Document
            UP TO 1 ROWS
            FROM vbrp  " Billing Document: Item Data
            INTO (w_vgbel, w_aubel)
            WHERE vbeln = st_item-refkey.
          ENDSELECT.
          IF sy-subrc = 0.
            w_vbeln_vol = w_vgbel.
*           Get the billing document type
            SELECT SINGLE fkart    " Billing Type
                          bstnk_vf " Customer purchase order number
            FROM vbrk              " Billing Document: Header Data
            INTO ( w_fkart, w_bstnk )
            WHERE vbeln = st_item-refkey.
            IF sy-subrc = 0.
*               Sy-subrc check is not required.
            ENDIF. " IF sy-subrc = 0
*           --- Begin of Change - Def 2842
*           Retrieve the branch value from the control table
            SELECT *
              UP TO 1 ROWS
              FROM ztvgt_control
              INTO st_control1
              WHERE exec_key = c_xped.
            ENDSELECT.
            IF sy-subrc = 0 AND
               in_doc-branch = st_control1-value2 AND
               in_doc-nftype = st_control1-value3.  "Addition for CHG1022035
              out_header-xped = w_aubel.
            ENDIF. " IF sy-subrc = 0 AND
*           --- End of Change - Def 2842
          ENDIF. " IF sy-subrc = 0
** Start of Changes for CR#CHG0075774
          CLEAR st_control1.
          SELECT *
            UP TO 1 ROWS
            FROM ztvgt_control
            INTO st_control1
            WHERE exec_key = l_c_nftype_z1.
          ENDSELECT.
          IF sy-subrc EQ 0.
            IF in_doc-nftype EQ st_control1-value1.
              out_header-nfat  = st_item-refkey.
              out_header-vorig = in_doc-nftot.
              out_header-vdesc = st_item-nfdis.
              out_header-vliq  = in_doc-nftot - st_item-nfdis.

              CLEAR l_belnr.
              CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
                EXPORTING
                  input  = st_item-refkey
                IMPORTING
                  output = l_belnr.

              REFRESH l_it_bseg.
*            SELECT buzei bschl dmbtr fdtag                                  "CR#CHG0077990
              SELECT buzei bschl shkzg dmbtr zfbdt  zbd1t zbd2t zbd3t rebzg    "CR#CHG0077990
                INTO TABLE l_it_bseg
                FROM bseg
                WHERE bukrs = st_control1-vkorg
                  AND belnr = l_belnr.
              IF sy-subrc EQ 0.
                REFRESH l_it_bseg1.
                l_it_bseg1[] = l_it_bseg[].
                DELETE l_it_bseg1 WHERE bschl <> st_control1-value2.
                l_it_bseg[] = l_it_bseg1[].
                LOOP AT l_it_bseg INTO l_st_bseg.

                  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                    EXPORTING
                      input  = l_st_bseg-buzei
                    IMPORTING
                      output = lv_item_num.

                  l_out_bseg-ndup_new  = lv_item_num.
*                l_out_bseg-dvenc     = l_st_bseg-fdtag.     "CR#CHG0077990
                  l_out_bseg-vdup      = l_st_bseg-dmbtr.
** Start of changes for CR#CHG0077990
                  CALL FUNCTION 'NET_DUE_DATE_GET'
                    EXPORTING
                      i_zfbdt = l_st_bseg-zfbdt
                      i_zbd1t = l_st_bseg-zbd1t
                      i_zbd2t = l_st_bseg-zbd2t
                      i_zbd3t = l_st_bseg-zbd3t
                      i_shkzg = l_st_bseg-shkzg
                      i_rebzg = l_st_bseg-rebzg
                    IMPORTING
                      e_faedt = lv_faedt.

                  l_out_bseg-dvenc     = lv_faedt.
** End of changes for CR#CHG0077990
                  APPEND l_out_bseg TO out_cobranca.
                  CLEAR: l_out_bseg, l_st_bseg, lv_item_num, lv_faedt.
                ENDLOOP.
              ENDIF.
            ENDIF.
          ENDIF.
** End of Changes for CR#CHG0075774
*       ----  Begin of Change - Def 2717
*       Get the delivery from the material document
        ELSEIF st_item-reftyp = st_control-value2. "MD
*         --- Begin of Change - CHG0071806
*          SELECT vbelv  " Preceding sales and distribution document
*            UP TO 1 ROWS
*            FROM vbfa                             " Sales Document Flow
*            INTO w_vgbel
*            WHERE vbeln   = st_item-refkey+0(10) AND
*                  vbtyp_n = st_control-value3 AND "R
*                  vbtyp_v = st_control-value4 AND "J
*                  mjahr   = st_item-refkey+10(4).
*          ENDSELECT.
*          IF sy-subrc = 0.
**            Sy-subrc check if not required.
*          ENDIF. " IF sy-subrc = 0
          SELECT SINGLE xblnr le_vbeln " Reference Document Number & Delivery Number
            FROM mkpf         " Header: Material Document
            INTO (w_xblnr, v_vbeln)  "INC10746554
            WHERE mblnr = st_item-refkey.
          IF sy-subrc = 0.
            SELECT vgbel " Document number of the reference document
              UP TO 1 ROWS
              FROM lips  " SD document: Delivery: Item data
              INTO w_vgbel
              WHERE vbeln = v_vbeln."w_xblnr . "Delivery number "INC10746554
            ENDSELECT.
            IF sy-subrc = 0.
              w_vbeln_vol = v_vbeln. "w_xblnr. "INC10746554
            ENDIF. " IF sy-subrc = 0
          ENDIF. " IF sy-subrc = 0
*         --- End of Change - CHG0071806
        ENDIF. " IF st_item-reftyp = st_control-value1
        CLEAR st_control.
        IF w_vgbel IS NOT INITIAL.
*         ----  End of Change - Def 2717
          SELECT adrnr " Address number
                 lifnr " Vendor
            UP TO 1 ROWS
            FROM vbpa  " Sales Document: Partner
            INTO (w_adrnr, w_lifnr)
            WHERE vbeln = w_vgbel AND
                  parvw = c_sp.
          ENDSELECT.
          IF sy-subrc = 0.
*           Select the vendor data
            SELECT SINGLE name1 " Name1
                          stcd1 " Tax 1
                          stcd3 " Tax 3
                          regio " Region
                          stras " Street
                          ort01 " City
              FROM lfa1         " Vendor Master (General Section)
              INTO st_lfa1
              WHERE lifnr = w_lifnr.
            IF sy-subrc = 0.
*             Populate the transport fields for the vendor
              out_header-t1_cnpj  = st_lfa1-stcd1.
              out_header-t1_xnome = st_lfa1-name1.
              out_header-t1_ie    = st_lfa1-stcd3.
              out_header-t1_uf    = st_lfa1-regio.
              out_header-t1_xend  = st_lfa1-stras.
              out_header-t1_xmun  = st_lfa1-ort01.
            ENDIF. " IF sy-subrc = 0
          ENDIF. " IF sy-subrc = 0
*             ---- Begin of Change - Def 806
*      *       Get the delivery data
*              SELECT SINGLE anzpk
*                            berot
*                FROM likp
*                INTO (w_anzpk, w_berot)
*                WHERE vbeln = w_vgbel.
*              IF sy-subrc = 0.
*                st_volume-t4_qvol = w_anzpk.
*                st_volume-t4_esp = w_berot.
*              ENDIF.
*             Get the delivery data
          SELECT SINGLE anzpk " Total number of packages in delivery
                        lifex
            FROM likp         " SD Document: Delivery Header Data
            INTO (w_anzpk, w_lifex)
            WHERE vbeln = w_vbeln_vol.
          IF sy-subrc = 0.
            st_volume-t4_qvol = w_anzpk.
*Begin of CHG1048714 | DELETE
***           If there is a value for LIKP-LIFEX, pass teh value.
**            IF NOT w_lifex IS INITIAL.
**              st_volume-t4_esp = w_lifex.
**            ELSE. " ELSE -> IF NOT w_lifex IS INITIAL
***             Else populate the value CAIXA
**              SELECT SINGLE low
**                FROM tvarvc
**                INTO st_volume-t4_esp
**                WHERE name = c_esp AND
**                      type = c_type AND
**                      numb = c_numb.
**              IF sy-subrc = 0.
***                Sy-subrc check is not required.
**              ENDIF. " IF sy-subrc = 0
**            ENDIF. " IF NOT w_lifex IS INITIAL
*End of CHG1048714 | DELETE
          ENDIF. " IF sy-subrc = 0
*Begin of CHG1048714 | INSERT
          SELECT SINGLE venum FROM vepo INTO @DATA(w_venum) WHERE vbeln = @w_vbeln_vol.
          IF sy-subrc = 0.
            SELECT SINGLE vhilm FROM vekp INTO @DATA(w_vhilm) WHERE venum = @w_venum.
            IF sy-subrc = 0.
              IF w_vhilm = lc_carton.
                st_volume-t4_esp = lc_p_carton.
              ELSEIF w_vhilm = lc_pallet.
                st_volume-t4_esp = lc_p_pallet.
              ENDIF.
            ENDIF.
          ELSE.
            SELECT SINGLE xped FROM j_1bnflin INTO @DATA(w_xped) WHERE docnum = @st_item-docnum.
            IF sy-subrc = 0.
              SELECT SINGLE vbeln FROM ekes INTO @DATA(w_vbeln_in) WHERE ebeln = @w_xped.
              IF sy-subrc = 0.
                SELECT SINGLE venum FROM vepo INTO @DATA(w_venum1) WHERE vbeln = @w_vbeln_in.
                IF sy-subrc = 0.
                  SELECT SINGLE vhilm FROM vekp INTO @DATA(w_vhilm1) WHERE venum = @w_venum1.
                  IF sy-subrc = 0.
                    IF w_vhilm1 = lc_carton.
                      st_volume-t4_esp = lc_p_carton.
                    ELSEIF w_vhilm1 = lc_pallet.
                      st_volume-t4_esp = lc_p_pallet.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
          IF st_volume-t4_esp IS INITIAL.
            SELECT SINGLE refkey FROM j_1bnflin INTO @DATA(w_refkey) WHERE docnum = @st_item-docnum.
            IF sy-subrc = 0.
              SELECT SINGLE vbelv FROM vbfa INTO @DATA(w_vbelv) WHERE vbeln = @w_refkey(10) AND vbtyp_v = @lc_vbtyp_v.
              IF sy-subrc = 0.
                SELECT SINGLE vbeln FROM vbfa INTO @DATA(w_vbeln1) WHERE vbelv = @w_vbelv AND vbtyp_n = @lc_vbtyp_n.
                IF sy-subrc = 0.
                  SELECT SINGLE venum FROM vepo INTO @DATA(w_venum2) WHERE vbeln = @w_vbeln1.
                  IF sy-subrc = 0.
                    SELECT SINGLE vhilm FROM vekp INTO @DATA(w_vhilm2) WHERE venum = @w_venum2.
                    IF sy-subrc = 0.
                      IF w_vhilm2 = lc_carton.
                        st_volume-t4_esp = lc_p_carton.
                      ELSEIF w_vhilm2 = lc_pallet.
                        st_volume-t4_esp = lc_p_pallet.
                      ENDIF.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
*End of CHG1048714 | INSERT
*         ---- End of Change - Def 806
        ENDIF. " IF w_vgbel IS NOT INITIAL
      ENDIF. " IF sy-subrc = 0

*     ---- Begin of Change - Def 806
*     Include for the Nota fiscal table updates.
      INCLUDE zvgti7744_nfxml_texts. " Include ZVGTI7744_NFXML_TEXTS
*   ---- End of Change - Def 806
*-----Begin of insert Brasil spotlight
      INCLUDE  zvgti7744_nfxml_add_info.
*-----End of insert Brasil Sportlight
*   --- Begin of Change - CHG0070778
*   This is in the case that the REFKEY is blank.
    ELSE. " ELSE -> IF sy-subrc = 0
*     Retrieve the NF Types from the control table for blank
*     reference type
      SELECT *
        UP TO 1 ROWS
        FROM ztvgt_control
        INTO st_control
        WHERE exec_key = c_nfwriter.
      ENDSELECT.
      IF sy-subrc = 0.
*       Check for the NF type for blank reference types
        IF ( in_doc-nftype = st_control-value1 OR
             in_doc-nftype = st_control-value2 OR
             in_doc-nftype = st_control-value3 ) AND
           in_doc-parvw = st_control-value4. "BR

*         Get the branch value from the partner id. field
          w_len = strlen( in_doc-parid ).
          w_len = w_len - 4.
          w_branch = in_doc-parid+w_len(4).

*         Call FM to read the Branch data
          CALL FUNCTION 'J_1BREAD_BRANCH_DATA'
            EXPORTING
              branch            = w_branch
              bukrs             = in_doc-bukrs
            IMPORTING
              address           = st_address
              branch_data       = st_branch_data
              cgc_number        = w_cnpj_branch
            EXCEPTIONS
              branch_not_found  = 1
              address_not_found = 2
              company_not_found = 3
              OTHERS            = 4.
          IF sy-subrc = 0.
            out_header-t1_cnpj  = w_cnpj_branch.
            out_header-t1_xnome = st_address-name1.
            out_header-t1_ie    = st_branch_data-state_insc.
            out_header-t1_uf    = st_address-regio.
            out_header-t1_xend  = st_address-stras.
            out_header-t1_xmun  = st_address-ort01.
          ENDIF. " IF sy-subrc = 0
        ENDIF. " IF ( in_doc-nftype = st_control-value1 OR
      ENDIF. " IF sy-subrc = 0
      CLEAR st_control.
*   --- End of Change - CHG0070778
    ENDIF. " IF sy-subrc = 0
*   Get the value of MOD FRETE
    SELECT SINGLE low " Selection Variants: Field Content (LOW/HIGH)
      FROM tvarvc     " Table of Variant Variables (Client-Specific)
      INTO w_modfrete
      WHERE name = c_name AND
            type = c_type AND
            numb = c_numb.
    IF sy-subrc = 0.
      out_header-t_modfrete = w_modfrete.
    ENDIF. " IF sy-subrc = 0
*   --- Begin of Change - CHG0071806
*    IF in_doc-gewei = c_gram.
*      st_volume-t4_pesol = in_doc-brgew / 1000.
*      st_volume-t4_pesob = in_doc-ntgew / 1000.
*    ELSE. " ELSE -> IF in_doc-gewei = c_gram
*      st_volume-t4_pesol = in_doc-brgew.
*      st_volume-t4_pesob = in_doc-ntgew.
*    ENDIF. " IF in_doc-gewei = c_gram
    IF in_doc-gewei = c_gram.
      st_volume-t4_pesol = in_doc-ntgew / 1000.
      st_volume-t4_pesob = in_doc-brgew / 1000.
    ELSE. " ELSE -> IF in_doc-gewei = c_gram
      st_volume-t4_pesol = in_doc-ntgew.
      st_volume-t4_pesob = in_doc-brgew.
    ENDIF. " IF in_doc-gewei = c_gram
*   --- End of Change - CHG0071806
*{   INSERT         ECDK931814                                        1
*  begin of change INC10746554
  IF st_volume-T4_QVOL is INITIAL.
    st_volume-T4_QVOL = in_xml_header-T4_QVOL.
  ENDIF.
  IF st_volume-T4_ESP is INITIAL.
    st_volume-T4_ESP = in_xml_header-T4_ESP.
  ENDIF.
*---end of change----INC10746554
*}   INSERT
    IF NOT st_volume IS INITIAL.
      APPEND st_volume TO out_volume.
    ENDIF. " IF NOT st_volume IS INITIAL
*   --- End of Change - Def 501

*   --- Begin of Change - Def 723
*   Check if the payment data is already populated or not
    IF ch_payment IS INITIAL.
*     Get the control data
      SELECT *
        FROM ztvgt_control
        INTO TABLE it_control
        WHERE exec_key = c_nftype OR
              exec_key = c_paymet OR
              exec_key = c_refkey OR
              exec_key = c_nftobd OR
              exec_key = c_nfdoc  OR
              exec_key = c_nfdnm.
      IF sy-subrc = 0.
*       --- Begin of Change - Def 2857
*       Get the value when the billing type does not match
        READ TABLE it_control
        INTO st_control_nm
        WITH KEY exec_key = c_nfdnm.
        IF sy-subrc = 0.
*         Sy-subrc check is not required.
        ENDIF. " IF sy-subrc = 0
*       --- End of Change - Def 2857
*       Check of the Nota fiscal is for the outbound process.
        READ TABLE it_control
        INTO st_control
        WITH KEY exec_key = c_nftobd
                 value1   = in_doc-nftype.
        IF sy-subrc = 0.
          CLEAR st_control.
*          --- Begin of Change - Def 2857
**         Get the value when the billing type does not match
*          READ TABLE it_control
*          INTO st_control_nm
*          WITH KEY exec_key = c_nfdnm.
*          IF sy-subrc = 0.
**           Sy-subrc check is not required.
*          ENDIF.
*         --- End of Change - Def 2857
          IF NOT st_item-refkey IS INITIAL.
            IF w_fkart IS NOT INITIAL.
              CLEAR st_control.
*             Read the billing type from the control table.
              READ TABLE it_control
              INTO st_control
              WITH KEY exec_key = c_nfdoc
                       value1   = w_fkart.
              IF sy-subrc = 0.
                st_payment-t_pag = st_control-value2. "15
              ELSE. " ELSE -> IF sy-subrc = 0
                st_payment-t_pag = st_control_nm-value1. "90
              ENDIF. " IF sy-subrc = 0
            ELSE. " ELSE -> IF w_fkart IS NOT INITIAL
              st_payment-t_pag = st_control_nm-value1. "90
            ENDIF. " IF w_fkart IS NOT INITIAL
          ELSE. " ELSE -> IF NOT st_item-refkey IS INITIAL
            st_payment-t_pag = st_control_nm-value1. "90
          ENDIF. " IF NOT st_item-refkey IS INITIAL
        ELSE. " ELSE -> IF sy-subrc = 0
          CLEAR st_control.
*         Get the control data for the nota fiscal type
          READ TABLE it_control
          INTO st_control
          WITH KEY exec_key = c_nftype.
          IF sy-subrc = 0.
*           If the NF Type <> Z1
            IF in_doc-nftype <> st_control-value1. "Z1
              st_payment-t_pag = st_control-value2. "90
            ELSE. " ELSE -> IF in_doc-nftype <> st_control-value1
*             If there is a refernce key
              IF NOT st_item-refkey IS INITIAL.
*               Get the payment method from VBRK
                SELECT SINGLE zlsch " Payment Method
                  FROM vbrk         " Billing Document: Header Data
                  INTO w_zlsch
                  WHERE vbeln = st_item-refkey.
                IF sy-subrc = 0.
*                   Get the tag value for the payment method from
*                   the control data
                  CLEAR st_control.
                  READ TABLE it_control
                  INTO st_control
                  WITH KEY exec_key = c_paymet.
*                   Check for the payment method
                  IF sy-subrc = 0 AND w_zlsch = st_control-value1. "D
                    st_payment-t_pag = st_control-value2. "14
                  ENDIF.
                ENDIF. " IF sy-subrc = 0
              ELSE. " ELSE -> IF NOT st_item-refkey IS INITIAL
*               If there is no reference key.
                CLEAR st_control.
                READ TABLE it_control
                INTO st_control
                WITH KEY exec_key = c_refkey.
*               Populate the pag as 99
                IF sy-subrc = 0.
                  st_payment-t_pag = st_control-value2. "99
                ENDIF. " IF sy-subrc = 0
              ENDIF. " IF NOT st_item-refkey IS INITIAL
            ENDIF. " IF in_doc-nftype <> st_control-value1
          ENDIF. " IF sy-subrc = 0
        ENDIF. " IF sy-subrc = 0
*       Append the payment data
        IF NOT st_payment-t_pag IS INITIAL.
          st_payment-docnum  = in_doc-docnum.
          st_payment-v_pag   = in_doc-nftot.
*         --- Begin of Change - Def 2857
*         Clear the V_PAG field if the value is 90.
          IF st_payment-t_pag = st_control_nm-value1.
            CLEAR st_payment-v_pag.
          ENDIF. " IF st_payment-t_pag = st_control_nm-value1
*         --- End of Change - Def 2857
          st_payment-counter = c_counter.
          APPEND st_payment TO ch_payment.
        ENDIF. " IF NOT st_payment-t_pag IS INITIAL
      ENDIF. " IF sy-subrc = 0
    ENDIF. " IF ch_payment IS INITIAL
*         --- End of Change - Def 723

*  --- Begin of Change - CHG0070778
    CLEAR st_control.
    SELECT *
      UP TO 1 ROWS
      FROM ztvgt_control
      INTO st_control
      WHERE exec_key = c_dest_cep.
    ENDSELECT.
    IF sy-subrc = 0.
*     Check if the value of the UF tag
      IF in_xml_header-e1_uf = st_control-value1. "EX
        out_header-e1_cep = st_control-value2. "99999-999
*       Check if the partner function is for a vendor.
        IF in_doc-parvw = c_lf.
*         Get the vendor address details.
          SELECT SINGLE adrnr " Address
                        land1 " Country Key
            FROM lfa1         " Vendor Master (General Section)
            INTO (w_lf_adrnr, w_lf_land1)
            WHERE lifnr =  in_doc-parid.
*         Check if the country is CA.
          IF sy-subrc = 0 AND  w_lf_land1 = st_control-value3. "CA
            SELECT str_suppl3 " Street 4
              UP TO 1 ROWS
              INTO out_header-e1_xbairro
              FROM adrc       " Addresses (Business Address Services)
              WHERE addrnumber = w_lf_adrnr.
            ENDSELECT.
            IF sy-subrc = 0.
*              Sy-subrc check is not required.
            ENDIF. " IF sy-subrc = 0
          ENDIF. " IF sy-subrc = 0 AND w_lf_land1 = st_control-value3
        ENDIF. " IF in_doc-parvw = c_lf
      ENDIF. " IF in_xml_header-e1_uf = st_control-value1
    ENDIF. " IF sy-subrc = 0
*   --- End of Change - CHG0070778

*  --- Begin of Change - OM_BR_NT2020.006
    out_header-ind_pres    = lc_ind_pres.    " 9
    out_header-indintermed = lc_indintermed. " 0
*   --- End of Change - OM_BR_NT2020.006
*Begin of change -INC10746554- rajesh
IF out_header-infcomp is not INITIAL. "below code passes the delivery number and po number to infocomp
 clear out_header-infcomp.
SELECT SINGLE xped FROM j_1bnflin INTO w_xped WHERE docnum = st_item-docnum.
IF sy-subrc eq 0.
    SELECT vbelv  " Preceding sales and distribution document
    UP TO 1 ROWS
    FROM vbfa                             " Sales Document Flow
    INTO w_vgbel
    WHERE vbeln   = st_item-refkey+0(10) AND
          vbtyp_v = 'J' AND "J  "OUTBOUND Delivery number
          mjahr   = st_item-refkey+10(4).
   ENDSELECT.
ENDIF.
   IF w_vgbel is not INITIAL or w_xped is not INITIAL.
   CONCATENATE text-012  w_vgbel
                  text-013 w_xped  " PO Document Number
                  text-016 l_vtext                          "Insert | CHG1055815
             INTO out_header-infcomp
      SEPARATED BY space.
      CONDENSE out_header-infcomp.
      clear: w_vgbel,w_xped.
   ENDIF.
ENDIF.
*End of change -INC10746554
* Begin of Changes CHG1035938
    CONSTANTS: lc_comma TYPE char01 VALUE ';'.
    LOOP AT in_text ASSIGNING FIELD-SYMBOL(<lfs_text>).
      IF out_header-infcomp IS NOT INITIAL.
        CONCATENATE out_header-infcomp <lfs_text>-message INTO out_header-infcomp SEPARATED BY lc_comma.
      ELSE.
        out_header-infcomp = <lfs_text>-message .
      ENDIF.
    ENDLOOP.
* End of Changes CHG1035938

  ENDMETHOD.
← Back to timeline