Quantity field conversion problem in SAP script

Hi experts,
I have problem with sap script quantity field conversion.
In purchase order the actual value of field( MDPM-ERFMG) is 3,500.
But in Print preview it is showing only 3.5
Any one Please help me in this problem
thanks in advance
murali

Hello,
check this:
Number of Decimal Places
A program symbol of one of the data types DEC, QUAN, and FLTP can contain decimal place data. Use the option below to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.
Syntax
&symbol(.N)&
The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.
&EKPO-MENGE& -> 1,234.560
&EKPO-MENGE(.1) -> 1,234.6
&EKPO-MENGE&(.4) -> 1,234.5600
&EKPO-MENGE&(.0) -> 1,235
REgards,
Vasanth

Similar Messages

  • Printing problem for SAP Script

    Dear Friends,
    I am facing strange problem for SAP Script. In the billing document output the sold to party and ship to party address are displaying. When user print the billing document on laser printer it print the Country for Sold to and Ship to. But when it print the same billing document on normal printer (other than laser) the Sold to country not printing.
    The print preview of billing document in SAP  correctly display country for Sold-to and Ship-to.
    I have recently make changes in the SAP Script form (Address window) to display country for Ship-to which was never displayed before. I have added FROMCOUNTRY option after COUNTRY in address window. COUNTRY will be Ship-to and FROMCOUNTRY will be VBDKR-SLAND.
    Can any one help me to solve this problem.
    Regards
    Nilesh Shete

    Used custom address print option instead of using ADDRESS

  • Problem with SAP Script FAX output

    Hi Friends,
    I have problem with SAP Script Fax output.
    After I issued output using the messge type, the print preview format shows me correct alignments and the right data. But when I go to List display using the menu bar functions from the print preview screen, the list is showing me the right data, but all the alignments at the main window went wrong.
    How do I rectify this problem? I need correct alignments in both form display and list display.

    Hi Sasidhar,
    Have you tried with different fax machine.
    Regards,
    Atish

  • Adding Fields to New Hire SAP Script, Text ID PAMA

    Hi there,
    I have successfully created a sapscript email to be sent via Dynamic Actions for the notification of New Hires and Terminations.  This has been accomplished via feature M0001 (we have created two new features u2013 M00NH & M00TM), dynamic action (T588z), Business Workplace, distribution lists, etc.  All are working correctly, and an email is being generated and forwarded to appropriate parties.
    Now we have been asked to add extra fields to the SAP Script text for New Hire and Termination.  These are text fields for Employee Group, Employee Subgroup, among others.
    Our syntax has been set up as follows:
    &'Employee Group:             'P0001-PERSG(02)&
    &'Employee Group Text:        'T501T-PTEXT(20)&
    &'Employee Subgroup:          'P0001-PERSG(02)&
    &'Employee Subgroup Text:     'T503T-PTEXT(20)&
    For the New Hire action, we are getting the Employee group and Employee subgroup codes to display but we are NOT getting the Employee Group or Employee Subgroup texts to display.  To confuse the issue, we ARE getting these text fields to display for the Termination script.  Our ABAP'er is also having difficulty determining how to bring in these fields to the New Hire script.
    We have researched this website have tried the instructions given by one user..... which states that we needed to go to our SAPscript text and make the following changes:
    " To get other HR data into your standard text (from SO10):
    Insert > Symbols > Program symbols (now you'll see a list of print programs, and i guess this is where the ABAP grabs the data).
    Highlight the one for HR Master data, and click the DDIC button.
    Double click the table you need data from (e.g P0000, P0001 or P0002).
    Finally select the field you want."
    I have done this, but when I get to the Program symbols, I do not see a print program for HR Master Data.  I only see RPUCOB02 - Processing of Qualifying COBRA Events and Letters & SAPMSSCE - SAPscript Standard Text Maintenance. 
    I tried to use the RPUCOB02 and inserted the text for Employee Subgroup as a test.  But it did not work as the text still did not display.
    The other oddity is that for the Termination sapscript text, the Employee Group and Employee Subgroup text displays correctly.  To test our syntax, we then connect the Termination sapscript text to the 'New Hire' action and reran the New Hire action.  The Employee Group and Employee Subgroup text fields then disappeared.  So it worked when the action was a termination, but did not work when the action was New Hire.
    The difference between these two actions is that the feature for the sapscript generation for New Hires is being generated upon saving of I0002 (which is created AFTER I0001) - we needed the Employee's name in the text.  For the Termination action, the feature is set to generate the mail upon saving of I0001.  This is the only difference between the two.  But as I need the employee name to display, it seemed the best approach.  I did try to generate the New Hire sapscript after saving of I0008, but had the same problem. 
    Does anyone know how we can add text fields to our New Hire sapscript text and actually get them to display?  We would also like to display the Org Unit text (&'ORGEH_2nd_TEXT(40)&) or even  the Supervisor (from the OM relationship).  But they do not display for the New Hire sapscript either. And our ABAP'er is able to insert the Supervisor logic, but the field still does not display.
    Thanks very much for any help.
    Edited by: Cathryn Westgarth on Nov 17, 2009 6:23 PM
    Edited by: Cathryn Westgarth on Nov 17, 2009 6:24 PM

    I am going to repost this question to the HR forum as it may be more appropriately an HR forum questions.
    Thanks
    Cathryn

  • Problem with sap script table in main window

    hi all,
    i have created a sap script  for which output is in 7 pages.
    except first page all the remaining pages are giving the correct output.
    the problem with the first page is iam not not getting vertical lines in the table which is in the main window of page 1.
    iam getting the vertical lines correctly in the mainwindow table of all the remaining pages.

    Hi,
    It's simple,
    Pre- U should had declared a second page for the same window with header, main & footer.
    now
    First when u r looping the internal table provide no of rows eg Row 1 TO 10. in the Loop ( Data Tab)
    or
    when defing TEXT Go to PC Editor and mention all the fields Under  PROTECT -  ENDPROTECT.
    This would solve the issue.
    Thanks
    Ravi

  • Problem in Sap script for Check printing

    Hi all,
      I have problem in Check printing for FI Module. In Tcode f-58 i am taking the printout of checks. For my user they want to move the main window in upwards, but the sap script <b>F110_PRENUM_CHCK</b> not allowing to move upwards. how to do this, its urgent. plz
    point wil be sure.
    Gowri

    Hi
    Copy the script F110_prenum_chek to some ZCHECK and do the changes.
    Why you can't change the MAIN window towards up?
    You can changes ths ize of it by adjusting the setting of it .
    generally we use some pre printed stationary for this in which all the line item data with doc numbers is printed on top and the check will be in bottom
    and in check we just print the few fields in the right positions.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • HI, Alignment Problem in SAP Script

    Hi Friends
    I am working on SAP Script, I have the problem alignment, in the first row I need to show 8 values,
    among them all the times length is not same, so my script is not displaying in proper alignment,
    I have tried with all the ways which I known, specifying the length, and using (*), but still it is not
    coming properly, is there any method to specify the position exactly like as in reposrting.
    Please help me in this, this is very urgent.
    Thanks and Regards
    Praveeb

    Hi Nagesh
    Thanks for your reply,
    I am displaying in the first row,  here I am mentioning the filed and lenght of the field
    1) Date(10)
    2) Reference No(16), .
    3) Fiscal Year(4),
    4) Internal Reference(3),
    5) Item Text (50)
    6) Due Date (10)
    7) Original Currency(3)
    8) Amount (18).
    In the field item text length is vary from each entry, it wont be static all the times, if one customer having having 10 records, all ten line items are not coming in the proper order, after displaying the item text, remaining fields are running out from the alignment. I am using tab space as 2 characters, I kept even so many conditions on the item text lenght, but still there are problems. I tried with specifying the length in
    the script for the symbols also no use and I passed (*), this is also not working properly. Here I am sending the code of my script. Please have a look and give me a suggestion please.
    bold Heading bold
    Date,,,,  ACR Ref No,,,,  UW-  Inst- Cedant,,,,,,,,,,
         ,,,,,,,,,,,,Due Date,,,, Original-,,,,Amount
         &wa_final-date(10)&,,&wa_final-xblnr(16)&,,&w_year(4)&,,
         &wa_final-xref1(3)&,,&wa_final-sgtxt(50)&
         ,,,,,,,,&wa_final-zfbdt(10)&,,,,&wa_final-waers(6)&,,,,&w_amt3(18)&
           &wa_final-date(*)&,,&wa_final-xblnr(*)&,,&w_year(4)&,,
         &wa_final-xref1(3)&,,&wa_final-sgtxt(*)&
         ,,,,,,,,&wa_final-zfbdt(*)&,,,,&wa_final-waers(*)&,,,,&w_amt3(*)&

  • Long text problem in sap script

    Hi Experts,
    I have craeted sap script for payment print progrem.. in my sap script one window is text window... client want more then 300 char for that window. for that i use read_text function module... its working fine... but problem is it retrive only one line from long text editor. only 70 char i got.
    below is my coding......
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        ID                            = '0001'
        LANGUAGE                      = sy-langu
        NAME                          = NAME
        OBJECT                        = 'DOC_ITEM'
      TABLES
        LINES                         = LINES          .
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT LINES.
      n = 0.
      l = 132.
      text+n(l) = lines-tdline.
      n = n + 132.
      l = l + 132.
    ENDLOOP.
    in sap script i have direct pass lines-tdline
    *&lines-tdline&
    Please suggest me which point i missing?
    Thanks
    Jigar

    Hi All,
    The standard text will be stored in Name = ORDCONF_TEXT_(sales org)_(distributionchannel)_(division)
    Text ID = ZSD
    Examples: ORDCONF_TEXT_4000_01_01 , ORDCONF_TEXT_4000_01_80 , ORDCONF_TEXT_1000_01_01.
    Requirement :
    The print program /form will need to pick up the appropriate standard text based on the Sales Area (combination of Sales Org / Distribution Center / Division) of the sales order [VBAK-VKORG / VTWEG / SPART], provided a standard text has been created for that Sales Area. Itu2019s not required that every sales area have a standard text, so if one is not found, this step should be skipped and the rest of the print program executed.
    The new text should print after 2 blank lines after the Printable Notes text (which is after the line items and the Total Net Price prints).
    The font should be the same size as the Printable Notes, but bolded rather than italicized.
    The text should print in the same columns as the Printable Notes currently print in (Material Description / Scheduled Ship Date / Quantity) .
    So the logic i have used is this below code:
    I used a subroutine in the layout of the main window becoz i need to print it in the main window below after 2 blank lines of line items.
    This is logic in the layout:
    /:PERFORM GET_OBJECT IN PROGRAM ZSDRP001_ORD_CONF_IRE
    /:USING &VBDKA-VBELN&
    /:CHANGING &ORDCONF_TEXT&
    /:ENDFORM
    /:INCLUDE &ORDCONF_TEXT& OBJECT TEXT ID ZSD PARAGRAPH A1
    I called this subroutine in the print program:
    Logic in the print program:
    FORM GET_OBJECT TABLES INPUT_TAB STRUCTURE ITCSY
                                                 OUTPUT_TAB STRUCTURE ITCSY.
    DATA : TMP_VBELN LIKE vbdka-VBELN,
                TMP_VKORG LIKE VBAK-VKORG,
                TMP_VTWEG LIKE VBAK-VTWEG,
               TMP_SPART LIKE VBAK-SPART,
               TMP_TXNAM1(40) TYPE C VALUE 'ORDCONF_TEXT',
               TMP_TXNAM2(100) TYPE C.
    DATA: v_text LIKE tline-tdline.
    DATA : P_V_TEXT LIKE tline-tdline.
    CLEAR : TMP_TXNAM1, TMP_TXNAM2, TMP_VBELN, TMP_VKORG, TMP_VTWEG, TMP_SPART.
    READ TABLE INPUT_TAB WITH KEY NAME = 'vbdka-VBELN'.
    IF SY-SUBRC = 0.
    tmp_vbeln = input_tab-value.
    ENDIF.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING INPUT = TMP_VBELN
    I
    MPORTING OUTPUT = TMP_VBELN .
    CLEAR VBAK.
    SELECT SINGLE VKORG VTWEG SPART INTO (TMP_VKORG, TMP_VTWEG, TMP_SPART)
                                            FROM VBAK WHERE VBELN EQ TMP_VBELN.
    IF NOT TMP_VKORG IS INITIAL
    AND NOT TMP_VTWEG IS INITIAL
    AND NOT TMP_SPART IS INITIAL.
    CONCATENATE TMP_TXNAM1 TMP_VKORG tmp_vtweg tmp_spart into TMP_TXNAM2 SEPARATED BY '_'.
    endif.
    CONDENSE TMP_TXNAM2 NO-GAPS.
    PERFORM read_order_text USING TMP_TXNAM2 CHANGING v_text.
    READ TABLE output_tab WITH KEY NAME = 'ORDCONF_TEXT'.
    IF SY-SUBRC = 0.
    output_tab-value = P_V_TEXT.
    MODIFY output_tab index sy-tabix.
    endif.
    endform.
    FORM READ_ORDER_TEXT USING P_TMP_TXNAM2 CHANGING P_V_TEXT LIKE tline-tdline.
    DATA: ztdid LIKE thead-tdid,
              zlang LIKE thead-tdspras,
              zobj LIKE thead-tdobject,
              zname LIKE thead-tdname.
    DATA: tlines TYPE STANDARD TABLE OF tline WITH HEADER LINE
              thead LIKE thead.
    CLEAR P_V_TEXT.
    ztdid = 'ZSD'.
    zlang = 'E'.
    zobj = 'TEXT'.
    zname = P_TMP_TXNAM2.
    CLEAR tlines.
    REFRESH tlines.
    CALL FUNCTION 'READ_TEXT'
    EXPORTING
    object = zobj
    name = zname
    id = ztdid
    language = zlang
    IMPORTING
    header = thead
    TABLES
    lines = tlines
    EXCEPTIONS
    id = 1
    language = 2
    name = 3
    not_found = 4
    object = 5
    reference_check = 6
    wrong_access_to_archive = 7
    OTHERS = 8.
    LOOP AT tlines WHERE NOT tdline IS INITIAL.
    MOVE tlines-tdline TO P_V_TEXT.
    ENDLOOP.
    ENDFORM.
    But still its not getting printed .Plz tell me where i am going wrong.
    Thanks,
    Suman

  • Problem with sap script

    Hi All,
    I have a problem with a sap script (PO) everytime when an item is deleted (on me23e) it doesn't display on the on the print preview and the client wants to see on the preview with a sign indicating the deleted item.
    SELECT ebeln ebelp pstyp packno txz01 loekz
      FROM ekpo
      INTO TABLE it_ekpo
      WHERE ebeln = po_no
      AND  loekz NE 'L'
      AND  loekz NE 'S'.
    This is how it has been read from the ekpo.... Is there something that I need to change? 
    Thanks in advance.
    Regards,
    Fred.

    Hi,
    In EKPO table the field 'loekz'  indicates the Deletion status.
    So u can consider the deleted line item also.
    u change u r query like this.
    SELECT ebeln ebelp pstyp packno txz01 loekz
    FROM ekpo
    INTO TABLE it_ekpo
    WHERE ebeln = po_no.
    In it_ekpo table u can get all the line item(including deleted items).
    Then u cn print the data.
    Hope this will helps u.

  • Problem with sap script while transporting from dev to quality server

    Hi experts,
    In dev server i am getting correct output in sap script.But when it is transporting to quality server alignment is different.Printer name is same both in dev and quality.Please give an answer for this query.
    Thanks
    suresh

    Hi Suresh,
    This could be a problem with the Sapscript buffers. Try running the report RSTXDELL on the system to clear the Sapscript buffers?
    To do this you can use RSTXDELL report with default settings except it is better to have * instead of the current client number in the Client field.
    After this, create a new spool and see if the problem is resolved?
    Regards,
    Aidan

  • Problem in Sap Script while printing

    HI,
    This report calling when I print billing document .this report getting data and call some sap script form but it prints 20 pages in place of only one page. Please
    Guide me to finding the exact problem.the code is below..
    REPORT zsd_excinv LINE-SIZE 110 LINE-COUNT 100 MESSAGE-ID vn.
    TABLES: vbco3,           "Keyfelder Vertriebsbeleg: Dokumentendruck
            tvko,            "Verkaufsorganisation
            sadr,            "Adressen
            komk,            "Communicationarea for conditions
            komp,            "Communicationarea for conditions
            komvd,           "Communicationarea for conditions
            vbdkr,           "Druck Rechnung: Kopfdaten
            vbdpr,           "Druck Rechnung: Positionsdaten
            conf_out,        "Configuration data
            vbpla,           "Druck Packliste   : allgemeine Daten
            vbplk,           "Druck Packliste   : Versandelementkopfdaten
            vbplp,           "Druck Packliste   : Versandelementinhaltsdaten
            vbpls.           "Druck Packliste   : Summendaten Verpackung
    TABLES : j_1iexchdr, j_1iexcdtl, vbrk,eikp,j_1imocust,likp,
             j_1iregset, itcpp,kna1, t001w.
    *PARAMETER : p_grp LIKE j_1iexchdr-exgrp.
    *SELECT-OPTIONS : so_num FOR j_1iexchdr-exnum.
    *PARAMETERS : p_num LIKE j_1iexchdr-exnum.
    DATA : wa_j_1iexchdr TYPE j_1iexchdr,
           it_j_1iexchdr TYPE TABLE OF j_1iexchdr.
    DATA : wa_j_1iexcdtl TYPE j_1iexcdtl,
           it_j_1iexcdtl TYPE TABLE OF j_1iexcdtl.
    DATA : wa_vbrk TYPE vbrk,
           wa_vbrp TYPE vbrp,
           wa_lips TYPE lips,
           wa_j_1iregset TYPE j_1iregset,
           wa_j_1iwrkcus TYPE j_1iwrkcus,
           wa_j_cust TYPE j_1imocust,
           it_vbrp TYPE TABLE OF vbrp.
    DATA : BEGIN OF wa_header,
             exnum TYPE j_1iexchdr-exnum ,
             exdat TYPE j_1iexchdr-exdat ,
             exccd TYPE j_1iregset-j_1iexccd,
             excrg TYPE j_1iregset-j_1iexcrg,
             excd1 TYPE j_1iregset-j_1iexcdi,
             bstnk_vf TYPE vbrk-bstnk_vf,
             zterm TYPE vbrk-zterm,
             iever TYPE eikp-iever,
             btgew TYPE likp-btgew,
             chapid TYPE j_1iexcdtl-chapid,
             traid TYPE likp-traid,
             rdoc TYPE j_1iexchdr-rdoc,
             maktx TYPE j_1iexcdtl-maktx,
             meins  TYPE likp-gewei,
          END OF wa_header.
    *DATA : BEGIN OF wa_header,
            exnum TYPE j_1iexchdr-exnum ,
            exdat TYPE j_1iexchdr-exdat ,
            exccd TYPE j_1iregset-j_1iexccd,
            excrg TYPE j_1iregset-j_1iexcrg,
            excd1 TYPE j_1iregset-j_1iexcdi,
            bstnk_vf TYPE vbrk-bstnk_vf,
            zterm TYPE vbrk-zterm,
            iever TYPE eikp-iever,
            btgew TYPE likp-btgew,
            ntgew TYPE likp-ntgew,
            chapid TYPE j_1iexcdtl-chapid,
            traid TYPE likp-traid,
            rdoc TYPE j_1iexchdr-rdoc,
            maktx TYPE j_1iexcdtl-maktx,
            meins  TYPE likp-gewei,
         END OF wa_header.
    *DATA : BEGIN OF wa_detail,
           zeile TYPE j_1iexcdtl-zeile,
           matnr TYPE j_1iexcdtl-matnr,
           maktx TYPE j_1iexcdtl-maktx,
           menge TYPE j_1iexcdtl-menge,
           rate TYPE konv-kbetr,
           amount TYPE konv-kwert,
           fob TYPE konv-kwert,
            meins  TYPE j_1iexcdtl-meins,
    *END OF wa_detail.
    *DATA : BEGIN OF wa_duties,
          zpr0 TYPE konv-kbetr,
          jadc TYPE konv-kbetr,
          st1 TYPE konv-kwert,
          jexp TYPE konv-kbetr,
          jecs TYPE konv-kbetr,
          st2 TYPE konv-kwert,
          jetc TYPE konv-kbetr,
          st3 TYPE konv-kwert,
          jsad TYPE konv-kbetr,
          st4 TYPE konv-kwert,
          st5 TYPE konv-kwert,
          vat TYPE konv-kbetr,
          st6 TYPE konv-kwert,
          zint TYPE konv-kbetr,
          jead TYPE konv-kbetr,
          zect TYPE konv-kbetr,
          zsad TYPE konv-kbetr,
          vat_per TYPE konv-kbetr,
          vat_val TYPE konv-kwert,
          total TYPE konv-kwert,
          remtime TYPE j_1iexchdr-remtime,
          exdat TYPE j_1iexchdr-exdat,
    *END OF wa_duties.
    *DATA : wa_t618t TYPE t618t.
    *DATA : in_words  TYPE spell,
          word TYPE spell-word,
          decword TYPE spell-decword,
          gv_plant_adrnr TYPE t001w-adrnr,
          lv_iever TYPE eikp-iever,
          lv_btgew TYPE likp-btgew,
          lv_ntgew TYPE likp-ntgew,
          lv_traid TYPE likp-traid,
          lv_regid TYPE j_1iregset-j_1iregid,
          gv_cust_adrnr TYPE kna1-adrnr,
          gv_ecsduty TYPE konv-kbetr,
          gv_tot_cen_amt TYPE konv-kwert,
          gv_zterm TYPE tvzbt-vtext,
          gv_tot_amt TYPE konv-kwert,
          lv_ins TYPE konv-kbetr,
          lv_fre TYPE konv-kbetr.
    *CONSTANTS : c_ecs TYPE j_1iexcdtl-ecsrate VALUE '0.368'.
    *SELECT-OPTIONS : so_num FOR j_1iexchdr-exnum.
    DATA : BEGIN OF wa_detail,
            zeile TYPE j_1iexcdtl-zeile,
            matnr TYPE j_1iexcdtl-matnr,
            maktx TYPE j_1iexcdtl-maktx,
            menge TYPE j_1iexcdtl-menge,
            rate TYPE konv-kbetr,
            amount TYPE konv-kwert,
            fob TYPE konv-kwert,
            meins  TYPE j_1iexcdtl-meins,
    END OF wa_detail.
    DATA : BEGIN OF wa_duties,
           zpr0 TYPE konv-kwert,
           jadc TYPE konv-kwert,
           st1 TYPE konv-kwert,
           jexp TYPE konv-kwert,
           jecs TYPE konv-kwert,
           st2 TYPE konv-kwert,
           jetc TYPE konv-kwert,
           st3 TYPE konv-kwert,
           jsad TYPE konv-kwert,
           st4 TYPE konv-kwert,
           st5 TYPE konv-kwert,
           vat TYPE konv-kwert,
           st6 TYPE konv-kwert,
           zint TYPE konv-kwert,
           jead TYPE konv-kwert,
           jeap TYPE konv-kwert,
           jeap_per TYPE konv-kbetr,
           zect TYPE konv-kwert,
           zect_per TYPE konv-kbetr,
           zecs TYPE konv-kwert,
           zsad TYPE konv-kwert,
           vat_per TYPE konv-kwert,
           vat_val TYPE konv-kwert,
           zlst_per TYPE konv-kwert,
           zlst_val TYPE konv-kwert,
           zcst_per TYPE konv-kwert,
           zcst_val TYPE konv-kwert,
           zeap TYPE konv-kwert,
           zeap_per TYPE konv-kbetr,
           total TYPE konv-kwert,
           remtime TYPE j_1iexchdr-remtime,
           exdat TYPE j_1iexchdr-exdat,
    END OF wa_duties.
    DATA : wa_t618t TYPE t618t.
    DATA : temp    TYPE konv-kwert VALUE 0,
           cen_amt TYPE konv-kbetr VALUE 0.
    DATA : in_words  TYPE spell,
           word TYPE spell-word,
           decword TYPE spell-decword,
           gv_plant_adrnr TYPE t001w-adrnr,
           lv_iever TYPE eikp-iever,
           lv_btgew TYPE likp-btgew,
           lv_traid TYPE likp-traid,
           lv_regid TYPE j_1iregset-j_1iregid,
           gv_cust_adrnr TYPE kna1-adrnr,
           gv_ecsduty TYPE konv-kbetr,
           gv_tot_cen_amt TYPE konv-kwert,
           gv_zterm TYPE tvzbt-vtext,
           gv_tot_amt TYPE konv-kwert,
           gv_amount TYPE konv-kwert,
           lv_ins TYPE konv-kbetr,
           lv_fre TYPE konv-kbetr.
    CONSTANTS : c_ecs TYPE j_1iexcdtl-ecsrate VALUE '0.368',
                rdocyr TYPE j_1iexchdr-docyr VALUE 2006.
    DATA : wa_t685t TYPE t685t.
    DATA : gv_zint TYPE t685t-vtext,
           gv_vat TYPE t685t-vtext,
           gv_zect TYPE t685t-vtext,
           gv_jetc TYPE t685t-vtext,
           gv_jeap TYPE t685t-vtext,
           gv_jecs TYPE t685t-vtext,
           gv_zlst TYPE t685t-vtext,
           gv_zcst TYPE t685t-vtext,
           gv_zeap TYPE t685t-vtext,
           gv_jadc TYPE t685t-vtext.
    INCLUDE rvadtabl.
    DATA: BEGIN OF lvbplk OCCURS 0.
            INCLUDE STRUCTURE vbplk.   "Packlistenkopf
    DATA: END OF lvbplk.
    DATA: BEGIN OF lvbplp OCCURS 0.
            INCLUDE STRUCTURE vbplp.   "Packlistenposition
    DATA: END OF lvbplp.
    DATA: BEGIN OF lvbpls OCCURS 0.
            INCLUDE STRUCTURE vbpls.   "Packlistenstruktur
    DATA: END OF lvbpls.
    DATA: BEGIN OF tvbdpr OCCURS 0.        "Rechnungspositionen
            INCLUDE STRUCTURE vbdpr.
    DATA: END OF tvbdpr.
    DATA: BEGIN OF tvbplp OCCURS 10.       "Packlistenposition
            INCLUDE STRUCTURE vbplp.
    DATA: END OF tvbplp.
    DATA: BEGIN OF tkomv OCCURS 50.
            INCLUDE STRUCTURE komv.        "Kommunikation
    DATA: END OF tkomv.
    DATA: BEGIN OF tkomvd OCCURS 50.
            INCLUDE STRUCTURE komvd.       "Kommunikation
    DATA: END OF tkomvd.
    DATA: BEGIN OF *tkomvd OCCURS 50.
            INCLUDE STRUCTURE komvd.
    DATA: END OF *tkomvd.
    DATA: BEGIN OF hkomvd OCCURS 50.
            INCLUDE STRUCTURE komvd.
    DATA: END OF hkomvd.
    DATA: BEGIN OF tkomcon OCCURS 50.
            INCLUDE STRUCTURE conf_out.
    DATA: END   OF tkomcon.
    DATA: retcode   LIKE sy-subrc.         "Returncode
    DATA: repeat(1) TYPE c.
    DATA: xscreen(1) TYPE c.               "Output on printer or screen
    DATA: pr_kappl(01)   TYPE c VALUE 'V'. "Application für Preisfindung
    DATA: print_mwskz.                     "Mehrwertsteuer-Kz drucken
    data for access to central address maintenance
    INCLUDE sdzavdat.
          FORM ENTRY                                                    *
          Einstieg für Nachrichtensteuerung                             *
    -->  RETURN_CODE                                                   *
    -->  US_SCREEN                                                     *
    FORM entry USING return_code us_screen.
      CLEAR retcode.
      xscreen = us_screen.
    Formular öffnen, aufbereiten und schließen
      PERFORM formular_invoice USING us_screen.
      CASE retcode.
        WHEN 0.
          return_code = 0.
        WHEN 3.
          return_code = 3.
        WHEN OTHERS.
          return_code = 1.
      ENDCASE.
    ENDFORM.                    "ENTRY
          FORM FORMULAR_INVOICE                                         *
          Formular abarbeiten                                           *
    FORM formular_invoice USING proc_screen.
    Werte aufbauen
      PERFORM get_data.
    Beleg unvollständig
      IF vbdkr-uvall NE space OR
         vbdkr-uvals NE space OR
         vbdkr-uvprs NE space.
        IF proc_screen = space.
          retcode = 3.
          IF vbdkr-uvall NE space OR vbdkr-uvals NE space.
            syst-msgno = '201'.
            syst-msgid = 'VN'.
            syst-msgty = 'I'.
            PERFORM protocol_update.
          ENDIF.
          IF vbdkr-uvprs NE space.
            syst-msgno = '200'.
            syst-msgid = 'VN'.
            syst-msgty = 'I'.
            PERFORM protocol_update.
          ENDIF.
        ELSE.
          IF vbdkr-uvall NE space OR vbdkr-uvals NE space.
            MESSAGE i201.
          ENDIF.
          IF vbdkr-uvprs NE space.
            MESSAGE i200.
          ENDIF.
        ENDIF.
      ENDIF.
      CHECK retcode = 0.
    SAP-SCRIPT STEUERUNG festlegen
      PERFORM form_open USING proc_screen vbdkr-land1.
      CHECK retcode = 0.
    Formular aufbereiten
      PERFORM sd_invoice_suppl.
      CHECK retcode = 0.
    Formular schließen
      PERFORM form_close.
      CHECK retcode = 0.
    ENDFORM.                    "FORMULAR_INVOICE
          FORM GET_DATA                                                 *
          Daten besorgen                                                *
    FORM get_data.
    PERFORM vbdkr_data.    "Rechnungskopf und -liste
    PERFORM vbpla_data.    "Packliste
    ENDFORM.                    "GET_DATA
          FORM FORM_OPEN                                                *
          Formular öffnen                                               *
    -->  US_SCREEN  Output on screen                                   *
                     ' ' = printer                                      *
                     'X' = screen                                       *
    -->  US_COUNTRY County for telecommunication and SET COUNTRY       *
    FORM form_open USING us_screen us_country.
      DATA: xdevice(8) TYPE c.
      SET LANGUAGE nast-spras.
      CLEAR itcpo.
      MOVE-CORRESPONDING nast TO itcpo.
      itcpo-tdcover   = nast-tdocover.
      itcpo-tddest    = nast-ldest.
      itcpo-tddataset = nast-dsnam.
      itcpo-tdsuffix1 = nast-dsuf1.
      itcpo-tdsuffix2 = nast-dsuf2.
      itcpo-tdimmed   = nast-dimme.
      itcpo-tddelete  = nast-delet.
      itcpo-tdcopies  = nast-anzal.
      itcpo-tdprogram = sy-repid.
      itcpo-tdteleland = us_country.
      itcpo-tdsenddate = nast-vsdat.
      itcpo-tdsendtime = nast-vsura.
      IF us_screen NE space.
        itcpo-tdpreview = 'X'.
        itcpo-tdnoprint = 'X'.
      ENDIF.
      IF sy-tcode EQ 'J1IP'.
        itcpo-tdpreview = 'X'.
      ENDIF.
      CASE nast-nacha.
        WHEN '1'.
          xdevice = 'PRINTER'.
        WHEN '2'.
          xdevice = 'TELEFAX'.
          itcpo-tdtelenum = nast-telfx.
          IF nast-tland IS INITIAL.
            itcpo-tdteleland = us_country.
          ELSE.
            itcpo-tdteleland = nast-tland.
          ENDIF.
        WHEN '3'.
          xdevice = 'TELETEX'.
          itcpo-tdtelenum = nast-teltx.
          IF nast-tland IS INITIAL.
            itcpo-tdteleland = us_country.
          ELSE.
            itcpo-tdteleland = nast-tland.
          ENDIF.
        WHEN '4'.
          xdevice = 'TELEX'.
          itcpo-tdtelenum = nast-telx1.
          IF nast-tland IS INITIAL.
            itcpo-tdteleland = us_country.
          ELSE.
            itcpo-tdteleland = nast-tland.
          ENDIF.
        WHEN OTHERS.
          xdevice = 'PRINTER'.
      ENDCASE.
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          form           = tnapr-fonam
          language       = nast-spras
          OPTIONS        = itcpo
          archive_index  = toa_dara
          archive_params = arc_params
          device         = xdevice
          dialog         = ' '
        EXCEPTIONS
          OTHERS         = 1.
      IF sy-subrc NE 0.
        retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
      SET COUNTRY us_country.
    ENDFORM.                    "FORM_OPEN
          FORM FORM_CLOSE                                               *
          Formular schließen                                            *
    FORM form_close.
      CALL FUNCTION 'CLOSE_FORM'           "...Ende Formulardruck
           EXCEPTIONS OTHERS = 1.
      IF sy-subrc NE 0.
        retcode = 1.
        PERFORM protocol_update.
      ENDIF.
      SET COUNTRY space.
      SET LANGUAGE space.
    ENDFORM.                    "FORM_CLOSE
          FORM SD_INVOICE_SUPPL                                         *
          Rechnung aufbereiten                                          *
    FORM sd_invoice_suppl.
      CLEAR : wa_j_1iexchdr, wa_j_1iexcdtl, wa_lips,  wa_duties,
              gv_tot_amt.
    get data from excise header
      SELECT * FROM j_1iexchdr INTO TABLE it_j_1iexchdr
      WHERE exgrp = '31'
      AND rdoc = nast-objky
      AND trntyp = 'DLFC'
      AND lifnr = space
      AND docyr = rdocyr.
    AND exdat IN so_dat.
      SORT it_j_1iexchdr BY exdat exnum.
      READ TABLE it_j_1iexchdr INTO wa_j_1iexchdr INDEX 1.
      SELECT * FROM j_1iexcdtl INTO TABLE it_j_1iexcdtl
      FOR ALL ENTRIES IN it_j_1iexchdr
      WHERE exnum = it_j_1iexchdr-exnum
      AND trntyp = 'DLFC'
      AND docno = it_j_1iexchdr-docno.
      SORT it_j_1iexcdtl BY exdat exnum.
    LOOP AT it_j_1iexchdr INTO wa_j_1iexchdr.
    *open form
    PERFORM open_form USING  'ZSD_EXCINV' 1
                              'printer'  'X'.
      MOVE : wa_j_1iexchdr-exnum TO wa_header-exnum,
            wa_j_1iexchdr-exdat TO wa_header-exdat,
            wa_j_1iexchdr-rdoc TO wa_header-rdoc.
    get plant details
      SELECT SINGLE * FROM j_1iwrkcus INTO wa_j_1iwrkcus
      WHERE j_1iwerks = wa_j_1iexchdr-werks.
      SELECT SINGLE * FROM j_1iregset INTO wa_j_1iregset
      WHERE j_1iregid = wa_j_1iwrkcus-j_1iregid.
      SELECT adrnr INTO gv_plant_adrnr FROM t001w
      WHERE werks = wa_j_1iexchdr-werks.
      ENDSELECT.
      MOVE : wa_j_1iregset-j_1iexccd TO wa_header-exccd,
             wa_j_1iregset-j_1iexcrg TO wa_header-excrg,
             wa_j_1iregset-j_1iexcdi TO wa_header-excd1.
    get order no. from vbrk
      SELECT * INTO wa_vbrk FROM vbrk
      WHERE vbeln = wa_j_1iexchdr-rdoc.
      ENDSELECT .
      MOVE : wa_vbrk-bstnk_vf TO wa_header-bstnk_vf,
       wa_vbrk-zterm TO wa_header-zterm.
      SELECT vtext FROM tvzbt INTO gv_zterm
       WHERE zterm = wa_vbrk-zterm
       AND   spras = 'EN'.
      ENDSELECT.
    get nature of removal
      SELECT iever INTO lv_iever FROM eikp
      WHERE refnr = wa_vbrk-vbeln.
      ENDSELECT.
      SELECT SINGLE * FROM t618t INTO wa_t618t
      WHERE expvz = lv_iever
      AND   spras = 'E'.
       MOVE : lv_iever TO wa_header-iever.
    *get consignment weight.
      SELECT SINGLE * FROM vbrp INTO wa_vbrp
      WHERE vbeln = wa_vbrk-vbeln.
      READ TABLE it_j_1iexcdtl INDEX 1 INTO wa_j_1iexcdtl.
      SELECT btgew traid gewei INTO (lv_btgew, lv_traid, wa_header-meins) FROM likp
      WHERE vbeln = wa_j_1iexcdtl-rdoc1.
      ENDSELECT.
      MOVE : lv_btgew TO wa_header-btgew,
             lv_traid TO wa_header-traid.
              lv_weight to wa_header-meins.
    *get chapter id
      READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl WITH KEY exnum = wa_j_1iexchdr-exnum .
      IF sy-subrc = 0.
        MOVE : wa_j_1iexcdtl-chapid TO wa_header-chapid,
               wa_j_1iexcdtl-maktx TO wa_header-maktx.
      ENDIF.
    *get customer details.
      SELECT adrnr FROM kna1 INTO gv_cust_adrnr
      WHERE kunnr = wa_j_1iexchdr-kunag.
      ENDSELECT.
      SELECT SINGLE * FROM j_1imocust INTO wa_j_cust
      WHERE kunnr = wa_j_1iexchdr-kunag.
    *write invoice header details
      PERFORM write_form  USING '' 'APPEND' 'BODY' 'LOCCODE' .
    *get data from excise details.
      LOOP AT it_j_1iexcdtl INTO wa_j_1iexcdtl.
        MOVE : wa_j_1iexcdtl-zeile TO wa_detail-zeile,
               wa_j_1iexcdtl-matnr TO wa_detail-matnr,
               wa_j_1iexcdtl-maktx TO wa_detail-maktx,
               wa_j_1iexcdtl-menge TO wa_detail-menge,
               wa_j_1iexcdtl-meins TO wa_detail-meins.
        SELECT  SINGLE * FROM vbrp INTO  wa_vbrp
            WHERE vbeln = wa_vbrk-vbeln
            AND   matnr = wa_j_1iexcdtl-matnr.
        SELECT kbetr kwert  FROM konv
        INTO (wa_detail-rate, wa_detail-amount)
        WHERE knumv = wa_vbrk-knumv
        AND   kposn = wa_vbrp-posnr
        AND  kschl  = 'ZPR0'.
        ENDSELECT.
        SELECT kwert  FROM konv
        INTO lv_ins
        WHERE knumv = wa_vbrk-knumv
        AND   kposn = wa_vbrp-posnr
        AND  kschl  = 'ZINS'.
        ENDSELECT.
        SELECT kwert  FROM konv
        INTO lv_fre
        WHERE knumv = wa_vbrk-knumv
        AND   kposn = wa_vbrp-posnr
        AND  kschl  = 'ZFRE'.
        ENDSELECT.
         wa_detail-fob = wa_detail-amount + lv_ins + lv_fre.
        gv_tot_amt = gv_tot_amt + wa_detail-amount.
       gv_amount  =   gv_amount + wa_detail-amount.
    write item details
        PERFORM write_form  USING 'LINE_ITEMS' 'SET' 'BODY' 'MAIN' .
      ENDLOOP.
    **get insurance .
    SELECT kwert INTO lv_ins FROM konv
    WHERE knumv = wa_vbrk-knumv
    AND  kschl = 'ZINS'.
    ENDSELECT.
    **get freight .
    SELECT kwert INTO lv_fre FROM konv
    WHERE knumv = wa_vbrk-knumv
    AND  kschl = 'ZFRE'.
    ENDSELECT.
    **get net value .
       MOVE wa_vbrk-netwr TO wa_costs-grandtot.
    **calculate netvalue(fobvalue)
       wa_costs-fobval = wa_costs-grandtot + wa_costs-insurance + wa_costs-freight.
    gv_tot_amt = gv_tot_amt + lv_ins + lv_fre.
    *get values for different condition types.
    SELECT kbetr INTO wa_duties-zpr0  FROM konv
    WHERE knumv = wa_vbrk-knumv
    AND   kposn = wa_vbrp-posnr
    AND  kschl  = 'ZPR0'.
    ENDSELECT.
      SELECT kwert  INTO wa_duties-jadc FROM konv
      WHERE knumv = wa_vbrk-knumv
       AND   kposn = wa_vbrp-posnr
      AND  kschl  = 'JADC'.
        temp = temp + wa_duties-jadc.
        CLEAR : wa_duties-jadc.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jadc.
      CLEAR : temp.
       wa_duties-st1 = wa_duties-zpr0 + wa_duties-jadc.
      SELECT kwert  INTO wa_duties-jexp FROM konv
       WHERE knumv = wa_vbrk-knumv
        AND   kposn = wa_vbrp-posnr
       AND  kschl  = 'JEXP'.
        temp = temp + wa_duties-jexp.
        CLEAR : wa_duties-jexp.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jexp.
      CLEAR : temp.
      SELECT kwert  INTO wa_duties-jecs FROM konv
        WHERE knumv = wa_vbrk-knumv
       AND   kposn = wa_vbrp-posnr
        AND  kschl  = 'JECS'.
        temp = temp + wa_duties-jecs.
        CLEAR : wa_duties-jecs.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jecs.
      CLEAR : temp.
      wa_duties-st3 =  gv_tot_amt + wa_j_1iexchdr-exbed + wa_j_1iexchdr-ecs.
      SELECT kwert  INTO wa_duties-jetc FROM konv
            WHERE knumv = wa_vbrk-knumv
             AND   kposn = wa_vbrp-posnr
            AND  kschl  = 'JETC'.
        temp = temp + wa_duties-jetc.
        CLEAR : wa_duties-jetc.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jetc.
      CLEAR : temp.
       wa_duties-st3 =  wa_duties-zpr0 + wa_duties-st2 + wa_duties-jetc.
      SELECT kwert  INTO wa_duties-jsad FROM konv
      WHERE knumv = wa_vbrk-knumv
       AND   kposn = wa_vbrp-posnr
      AND  kschl  = 'JSAD'.
        temp = temp + wa_duties-jsad.
        CLEAR : wa_duties-jsad.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jsad.
      CLEAR : temp.
      SELECT kbetr kwert  INTO (wa_duties-jeap_per, wa_duties-jeap) FROM konv
      WHERE knumv = wa_vbrk-knumv
       AND   kposn = wa_vbrp-posnr
      AND  kschl  = 'JEAP'.
        temp = temp + wa_duties-jeap.
        CLEAR : wa_duties-jeap.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jeap.
      CLEAR : temp.
      wa_duties-jeap_per = wa_duties-jeap_per / 10.
      SELECT kbetr kwert INTO (wa_duties-zeap_per, wa_duties-zeap) FROM konv
      WHERE knumv = wa_vbrk-knumv
       AND   kposn = wa_vbrp-posnr
      AND  kschl  = 'ZEAP'.
        temp = temp + wa_duties-zeap.
        CLEAR : wa_duties-zeap.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zeap.
      CLEAR : temp.
      wa_duties-zeap_per = wa_duties-zeap_per / 10.
             (st2jetcjsad)
       wa_duties-st4 =   wa_duties-st2 + wa_duties-jetc + wa_duties-jsad.
             (zpr0+st4)
       wa_duties-st5 =   wa_duties-zpr0 + wa_duties-st4 .
       SELECT kbetr  INTO wa_duties-vat FROM konv
             WHERE knumv = wa_vbrk-knumv
             AND   kposn = wa_vbrp-posnr
             AND  kschl  = 'VAT'.
       ENDSELECT.
      SELECT kbetr kwert INTO (wa_duties-vat_per, wa_duties-vat_val) FROM konv
            WHERE knumv = wa_vbrk-knumv
           AND   kposn = wa_vbrp-posnr
            AND  kschl  = 'ZVAT'.
        temp = temp + wa_duties-vat_val.
        CLEAR : wa_duties-vat_val.
      ENDSELECT.
      MOVE  : temp TO wa_duties-vat_val.
      CLEAR : temp.
      wa_duties-vat_per = wa_duties-vat_per / 10.
      SELECT kbetr kwert INTO (wa_duties-zcst_per, wa_duties-zcst_val) FROM konv
           WHERE knumv = wa_vbrk-knumv
           AND   kposn = wa_vbrp-posnr
           AND  kschl  = 'ZCST'.
        temp = temp + wa_duties-zcst_val.
        CLEAR : wa_duties-zcst_val.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zcst_val.
      CLEAR : temp.
      wa_duties-zcst_per = wa_duties-zcst_per / 10.
      SELECT kbetr kwert INTO (wa_duties-zlst_per, wa_duties-zlst_val) FROM konv
            WHERE knumv = wa_vbrk-knumv
           AND   kposn = wa_vbrp-posnr
            AND  kschl  = 'ZLST'.
        temp = temp + wa_duties-zlst_val.
        CLEAR : wa_duties-zlst_val.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zlst_val.
      CLEAR : temp.
      wa_duties-zlst_per = wa_duties-zlst_per / 10.
             (st5+vat)
       wa_duties-st6 =   wa_duties-vat_val + wa_duties-st5 .
      SELECT kwert  INTO wa_duties-zint FROM konv
            WHERE knumv = wa_vbrk-knumv
             AND   kposn = wa_vbrp-posnr
            AND  kschl  = 'ZINT'.
        temp = temp + wa_duties-zint.
        CLEAR : wa_duties-zint.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zint.
      CLEAR : temp.
      SELECT kwert  INTO wa_duties-jead FROM konv
               WHERE knumv = wa_vbrk-knumv
               AND   kposn = wa_vbrp-posnr
               AND  kschl  = 'JEAD'.
        temp = temp + wa_duties-jead.
        CLEAR : wa_duties-jead.
      ENDSELECT.
      MOVE  : temp TO wa_duties-jead.
      CLEAR : temp.
      SELECT kbetr kwert  INTO (wa_duties-zect_per, wa_duties-zect) FROM konv
            WHERE knumv = wa_vbrk-knumv
             AND   kposn = wa_vbrp-posnr
            AND  kschl  = 'ZECT'.
        temp = temp + wa_duties-zect.
        CLEAR : wa_duties-zect.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zect.
      CLEAR : temp.
      wa_duties-zect_per = wa_duties-zect_per / 10.
      SELECT kwert  INTO wa_duties-zsad FROM konv
        WHERE knumv = wa_vbrk-knumv
         AND   kposn = wa_vbrp-posnr
        AND  kschl  = 'ZSAD'.
        temp = temp + wa_duties-zsad.
        CLEAR : wa_duties-zsad.
      ENDSELECT.
      MOVE  : temp TO wa_duties-zsad.
      CLEAR : temp.
      IF wa_vbrk-kalsm = 'ZINSCR'.
        wa_duties-total = gv_tot_amt
                       + wa_duties-jexp
                       + wa_duties-jecs
                       + wa_duties-zlst_val
                       + wa_duties-zint
                     + wa_duties-jead
                       + wa_duties-vat_val
                       + wa_duties-zcst_val.
                     + wa_duties-jecs
                     + wa_duties-zeap
                     + wa_duties-zecs
                     + wa_duties-zsad
                     + wa_duties-jadc.
      ELSEIF wa_vbrk-kalsm = 'ZINFAC'.
        wa_duties-total = gv_tot_amt
                       + wa_duties-jexp
                       + wa_duties-jecs
                       + wa_duties-zlst_val
                       + wa_duties-zint
                       + wa_duties-jeap
                       + wa_duties-vat_val
                       + wa_duties-zcst_val
                     + wa_duties-jecs
                       + wa_duties-zeap
                       + wa_duties-zect.
                     + wa_duties-zsad
                     + wa_duties-jadc.
      ENDIF.
    Get Condition descriptions.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZVAT' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_vat.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZVAT' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_vat.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZLST' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_zlst.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZCST' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_zcst.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZECT' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_zect.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'ZEAP' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_zeap.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'JETC' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_jetc.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'JEAP' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_jeap.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'JECS' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_jecs.
      CLEAR wa_t685t.
      SELECT SINGLE * FROM t685t INTO wa_t685t
      WHERE kschl = 'JADC' AND spras = 'EN'.
      MOVE wa_t685t-vtext TO gv_jadc.
      CLEAR wa_t685t.
       gv_ecsduty = wa_j_1iexchdr-exbed * ( c_ecs / 100 ).
      cen_amt = wa_duties-jexp + wa_duties-jeap.
      gv_tot_cen_amt = cen_amt + wa_duties-jecs.
      MOVE wa_j_1iexchdr-remtime TO wa_duties-remtime.
      MOVE wa_j_1iexchdr-exdat TO wa_duties-exdat.
    Convert amount to words.
      CALL FUNCTION 'SPELL_AMOUNT'
        EXPORTING
          amount    = wa_duties-total
          currency  = 'INR '
          filler    = space
          language  = sy-langu
        IMPORTING
          in_words  = in_words
        EXCEPTIONS
          not_found = 1
          too_large = 2
          OTHERS    = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      MOVE : in_words-word TO word,
           in_words-decword TO decword.
    write  duty details
      IF wa_vbrk-kalsm = 'ZINSCR'.
        PERFORM write_form USING 'ZINSCR' 'APPEND' 'BODY' 'GRANDTOT' .
      ELSEIF  wa_vbrk-kalsm = 'ZINFAC'.
        PERFORM write_form USING 'ZINFAC' 'APPEND' 'BODY' 'GRANDTOT' .
      ENDIF.
    *close form
       PERFORM close_form.
    ENDLOOP.
    ENDFORM.                    "SD_INVOICE_SUPPL
          FORM FORM_TITLE_PRINT                                         *
          Formulartitel entsprenchend des Feldes VBTYP drucken          *
    FORM form_title_print.
      CASE vbdkr-vbtyp.
        WHEN 'M'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
             element = 'TITLE_M'
              window  = 'HEADER'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'N'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_N'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'O'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_O'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'P'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_P'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'S'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_S'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN 'U'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_U'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
        WHEN OTHERS.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TITLE_M'
              window  = 'TITLE'
            EXCEPTIONS
              element = 1
              window  = 2.
          IF sy-subrc NE 0.
            PERFORM protocol_update.
          ENDIF.
      ENDCASE.
      IF repeat NE space.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            element = 'REPEAT'
            window  = 'REPEAT'
          EXCEPTIONS
            element = 1
            window  = 2.
        IF sy-subrc NE 0.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
    ENDFORM.                    "FORM_TITLE_PRINT
          FORM REFERENCE_NUMBER                                         *
          Referenznummer ausgeben                                       *
    FORM reference_number.
      CHECK vbdkr-vbtyp CA 'MUN'.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          window = 'INVOICE'
        EXCEPTIONS
          window = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "REFERENCE_NUMBER
          FORM HEADER_TEXT_PRINT                                        *
          Kopftexte ausgeben                                            *
    FORM header_text_print.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element = 'HEADER_TEXT'
        EXCEPTIONS
          element = 1
          window  = 2.
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                    "HEADER_TEXT_PRINT
          FORM ITEM_PRINT                                               *
          Rechnungsposition ausgeben                                    *
    FORM item_print.
    Kopieren LVBPLP für direkt Zugriff
      LOOP AT lvbplp.
        MOVE-CORRESPONDING lvbplp TO tvbplp.
        APPEND tvbplp.
      ENDLOOP.
      LOOP AT tvbdpr.
        vbdpr = tvbdpr.
        IF tvbdpr-charg IS INITIAL.
          PERFORM get_item_prices.
          PERFORM get_item_characteristics.
          CALL FUNCTION 'CONTROL_FORM'
            EXPORTING
              command = 'PROTECT'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'ITEM_LINE'.
          PERFORM item_price_print.
          PERFORM item_characteristics_print.
          CALL FUNCTION 'CONTROL_FORM'
            EXPORTING
              command = 'ENDPROTECT'.
          PERFORM different_consignee.
          PERFORM different_order_no.
          PERFORM different_delivery_no.
          PERFORM different_extern_no.
          PERFORM different_purchase_order_no.
          PERFORM item_packing_print.
        ELSE.
          IF NOT tvbdpr-fkimg IS INITIAL.
            PERFORM get_item_prices.
            PERFORM item_price_print.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "ITEM_PRINT
          FORM ITEM_PACKING_PRINT                                       *
          Verpackung zu einer Position ausgeben                         *
    FORM item_packing_print.
      DATA: count LIKE sy-index.
      DATA: BEGIN OF hvbplp OCCURS 0,
              stufe     TYPE i.
              INCLUDE STRUCTURE vbplp.
      DATA: END OF hvbplp.
      DATA: vs_element LIKE vbplp-venum.
      CLEAR   hvbplp.
      REFRESH hvbplp.
    Aufbau Versandelementstruktur für Ausgabe
      LOOP AT tvbplp WHERE vbeln = vbdkr-vbeln AND posnr = tvbdpr-posnr.
        hvbplp-stufe = 1.
        MOVE-CORRESPONDING tvbplp  TO hvbplp.
        APPEND hvbplp.
        vs_element = tvbplp-venum.
        IF vs_element EQ ' '. EXIT. ENDIF.         "unverpackt
        CLEAR lvbplk.
        WHILE lvbplk-kzobe NE 'X'.       "nicht oberstes VS-Ele
          suchen übergeordnetes Versandelement
          LOOP AT lvbplp WHERE unvel = vs_element.
            hvbplp-stufe = hvbplp-stufe + 1.
            MOVE-CORRESPONDING lvbplp  TO hvbplp.
            APPEND hvbplp.
            EXIT.
          ENDLOOP.
          vs_element = lvbplp-venum.
          lesen übergeordnetes Versandelement
          READ TABLE lvbplk WITH KEY vs_element.
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
        ENDWHILE.
      ENDLOOP.
      SORT hvbplp BY stufe venum.
      CLEAR vbplp.
      LOOP AT hvbplp.
        lesen Versandelement
        CLEAR vbplk.
        CLEAR vbpls.
        IF hvbplp-venum EQ ' '.

    Hi,
    SAPScript addresses are formated by postal standards...irrespective of the data populated....
    In line
    /: ADDRESS PARAGRAPH LZ
    change to
    /: ADDRESS DELIVERY PARAGRAPH LZ
    that should bring the street into the address
    Regards
    Stu

  • Invoice List SAP script - Problem with SAP script functionality

    Hello Friends,
    I am working on SAP script - Invoice List SD_INVOICE_LIST. The invoice list contains the underlying billing documents. As per the standard functionality, in the line items, its printing the underlying billing documents with the net value. My requirement is to dig these line items into another level, meaning, I need to display the line items of billing documents  as well(like material, material description, quantity, net price and net value of that item etc).
    The billing linte item informatin is stored in VBRP table and the VBRP structure is not at all defined in the print program of SD_INVOICE_LIST (I.E.RVADIL01). Change of standard SAP program is not an option for me here.
    In the external subroutine we can fetch these line items for each billing document in the invoice list. However, my question here is how to take these line items back to the sap script and print them in SAP script (We can print one line item but how to loop these fetched lines and print them on SAP script. Any help in this regard would be greatly appreciated.
    I think there is no standard smart form exist for the invoice list. Please also let me know if there is any standard smart form available for INVOICE List.
    Thanks in advanace for any help in this regard.
    Best regards,
    Siva

    Hi
    As you cannot change the standard, you will have to see if there are any enhancements provided in the print program. if not you have to copy into a custom one and do changes accordingly.
    Thanks,
    Venkatesh

  • PROTECT-ENDPROTECT problem in SAP Script

    In SAP Script MAIN Window I have 10 different elements to print differet stuff related with each delivery line item.
    Like Material Number
    Material Description
    Long text [Has formatted text and I am reading that text and printed in some format some lines under material number and some under materail desc.]
    and other information required by client.
    Loop at Delivery item table.
    CALL FUNCTION 'CONTROL_FORM'
           EXPORTING
                command = 'PROTECT'.
    Print differnt elements.
    Loop at lond text internal table.
    print in proper format as I mentioned.
    endloop.
      CALL FUNCTION 'CONTROL_FORM'
           EXPORTING
                command = 'ENDPROTECT'.
    ENDLOOP.
    My problem is PROTECT ENDPROTECT is not working properly.
    It is printing only 1 item with other info on first page as there are enough space left to print minimum three items with details.
    on next page it is priting only 3-4 items as there are enough sapce to ptint at lease 10 items with details.
    The only good thing is it is not spliting the Item details and other text.[Main window on next page has bigger size]
    Any idea why PROTECT - ENDPOTECT not behaving properly.
    Thanks
    Aman
    Message was edited by: Amandeep  Singh

    Hello,
    Try to do like, Put PROTECT and ENDPROTECT in the SAPScript itself.
    Like
    Element 1
    Protect
    ..matnr....
    element 2
    ...desc....
    element 3 (long text)
    ...text
    ....text
    element 4
    endprotect
    call the element 4 in the loop statment, whenever required.
    Hope it will work.
    Regards,
    Naimesh.

  • Problem in SAP-Script

    Hi All,
    I am creating one report form using SAP Script, it is a replacement of standard SAP Script and which uses standard driver program. I am getting one dump while running SAP Script, it shows like "variable with name 'XXX' has not been used in so and so window".
    In that window there is a code block like,
    /: IF XXX == 'yes'
    /: ENDIF
    As I dont want this block I have commented this like,
    /* IF XXX == 'yes'
    /* ENDIF
    Please let me know how to overcome this short-dump and provide solution why such dump is comming?
    <<removed by moderator>>
    Edited by: kishan P on Sep 13, 2010 4:19 PM

    Hi,
    This is one of the problem of Standard SAP Script driver program, we can over come easily, we no need to comment anything rather do follow the code you can easily solve your issue, I also face the same issue previously.
    your code is,
    /: IF XXX = 'Yes'
    /: ENDIF
    like this means, then change the code like this,
    /: IF 1 = 2
    /: IF XXX = 'Yes'
    /: ENDIF
    /: ENDIF
    here, you didnt write any comment, also the code will never execute.
    Why we are doing this means, driver program expects particular variable has to be used in particular window, but it never expects that variable has to be executed. By using this code you can use the variable also it will never be executed.
    Hope it will be helpful. If you find any other solution please let me know, Thank you:)

  • Problem in sap script for Item data

    Hi Guys ,
    Although I am working in ABAP for last 1 year but I am new to SAP script , This is first time I am doing this -
    I am creating excise invoice profarma and able to print all that data except J_1IEXCDTL ( Item data ) that I have to display in loop ,
    I am using
    LOOP AT ITAB_J_1IEXCDTL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'ITEM_VALUES'
                WINDOW  = 'MAIN'
           EXCEPTIONS
                ELEMENT = 1
                WINDOW  = 2.
    ENDLOOP.
    My problem is that this is working fine for 1 record but if there are more than 1 record in ITAB_J_1IEXCDTL. , it is showing only first record ,
    Other thing i want to know what is connection of element between Driver program and sap script , Can we give any name to element and it doesnt make any impact on Sap script
    i have done same in my program ,
    Thanks in advance
    Amit

    my problem is solved now ,
    Thanks

Maybe you are looking for