Read_text in smart forms

I use read_text in smart form...how to pass object in this fm....actually there is standard table which maintains data according username......from which we can fetch data required for this fm..i am not getting tasble name..plz can u suggest

t_code s010
ABAP READ_TEXT functions to read the SAP Long Text
You have to used the READ_TEXT functions to read the SAP long text. e.g. Sales Order, Purchase Order Item text etc.
To check your long text header, go into the long text. Click Goto -> Header
Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.
Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.
REPORT ZTEXT .
TABLES: PBIM.
stxh, stxl, stxb - trans tables for text
ttxit - text on text-ids
ttxot - Short texts on text objects
Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
S_WERKS FOR PBIM-WERKS.
DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.
DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.
DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.
DATA: TNAME LIKE THEAD-TDNAME.
SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
MOVE PBIM-BDZEI TO TNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'PB'
LANGUAGE = 'E'
NAME = TNAME
OBJECT = 'PBPT'
ARCHIVE_HANDLE = 0
IMPORTING
HEADER = HTEXT
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE PBIM-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.
http://www.sapdevelopment.co.uk/sapscript/sapscript_texts.htm
Also
*Internal table to store standard texts
DATA: IT_TEXTS like T_LINE occurs o with header line.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
id = "Text ID
language = "Laguage
name = "Text name
object = "text object
ARCHIVE_HANDLE = 0
IMPORTING
HEADER =
tables
lines = IT_TEXTS "Internal table
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>save text</b>
Fill out following parameters of SAVE_TEXT function module:
HEADER
TDOBJECT C 10 BUT000
TDNAME C 70 10 digit BP number
TDID C 4 Z001
TDSPRAS C 1 Language
INSERT = ’X’
LINES
TDFORMAT TDLINE
|
|testtttttttttttttttttttttttt( Your text)
I would suggest you to use some other BAPI that would attach your text to BP than SAVE_TEXT.
If you still wanted to use SAVE_TEXT then first make sure how the TDNAME is generated. It depends on the text determination procedure. For examples, it can be guid of BP, GUID followed by date or time or else the BP number itself.
Just go to BP transaction, double click on the text pad, it will open you the SAP Script editor. Click on menu GOTO and select Header which will give you info about your TDID, TDOBJECT, TDNAME....
Hope this helps.

Similar Messages

  • How to use Read_text in Smart Forms for printing Header Texts

    Dear ALL,
    I want to print Header Texts in SmartForms, For that
    I am using T/Code VL02N .. and choosed  Header ..
    got this details...  from Text Header.
    Text Name       :0080000441
    Language         :EN
    Text ID             :Z002
    Text Object       :VBBK.
    So in Smart forms Under Template i have created a text and Program Code .
    Inside that I have used this below code .
    CALL FUNCTION 'READ_TEXT'
    EXPORTING
    *CLIENT= SY-MANDT
    ID = 'Z002'
    LANGUAGE =  SY-LANGU
    NAME = NAME
    OBJECT = 'VBBK'
    TABLES
    LINES = IT_TLINE
    EXCEPTIONS
    ID = 1
    LANGUAGE = 2
    NAME = 3
    NOT_FOUND = 4
    OBJECT = 5
    REFERENCE_CHECK = 6
    WRONG_ACCESS_TO_ARCHIVE = 7
    OTHERS = 8.
    IF SY-SUBRC 0.
    CLEAR IT_TLINE.
    ENDIF.
    Kindly suggest me, Where  to declare the variables and loops for using this Read_Text Syntax in Smartforms .
    Response to this will be highly appreciated........  
    Regards ,
    Vinoth.

    hi
    good
    please check this code
    CONSTANTS:
    *For text reading like in LCNMMFTX / FORM SET_CONTROL_TEXT
               text_id  like thead-tdid     value 'MATK',
               text_obj like thead-tdobject value 'AUFK  '.
    data tlines like tline occurs 0 with header line.
    data tdname like thead-tdname.
    data tdheader like thead.
    if not it_proj-ltxsp is initial.
    refresh tlines.
            tdname = sy-mandt.
            tdname+3 = it_proj-rsnum.
            tdname+13 = it_proj-rspos.
            tdname+17 = it_proj-rsart.
            call function 'READ_TEXT'
                 exporting
                    id        = text_id
                    language  = it_proj-ltxsp
                    name      = tdname
                    object    = text_obj
                 importing
                    header    = tdheader
                 tables
                    lines     = tlines.
                exceptions
                   not_found = 01.
    thanks
    mrutyun^

  • Text element not gettin refreshed in smart form

    Hi
    Text element does not get refreshed in the smart form preview. 
    I have a selection screen on which i have a few selection parameters and three application
    toolbar buttons. "Save" , "Preview" and "Print". At the end of selection screen I have a
    button "text" which when clicked takes me to the text element editor(FM  'TEXT_EDIT' )
    I have to enter a project number on the selection screen, enter all other details and
    then click on the "Text" button. I would then change /edit some text etc and come back
    to sel screen. Now i click on preview , the smart form shows up and the text gets dispalyed
    with the modified text. 
    I am passing the text name by appending "sometext" + project number to the TEXT_EDIT
    and while eiditing and as a parameter to the smart form. In the smart form i have given the variable in the "include text".
    Now Herez the problem.
    I am still in selection screen and clik on the "text" button and it takes me to the
    text editor. Now i add more lines, save and come back. Now i clik on preview
    button and it displays the old text data.
    When i come out of the transaction and renter , clik on the preview it displays data
    correctly. Now if i repeat the steps
    1.edit text button , add a few lines
    2.preview button, shows data as entered in step 1.
    3.edit text button, add few more lines
    4.preview button .. the text displays is from step 1 and not 3.
    I am not sure if this is lot of info for anybody to write an answer straight away but
    if u need more info i can provide. I can do a read_text in the smart form but its toooooo
    much of a pain for the data i need to display. million adjustments to be taken care of.
    What could be the problem ? I have given all the basic settings like save parameter
    in edit_text fm , checked all the print preview options in sdn.
    Here are my questions
    1. Why is the text element not getting refreshed.
    2. After a form is displayed for preview , will it store anywhere in the buffer ? if yes
        is there any method to clear it ?

    Hi,
      The problem is not with text elements, it might be your size of window which you are using to display the text elements. Check your window size and modify that accordingly.
    Cheers,
    Bujji

  • Using & in SMART FORMS

    Hi All,
    I am reading a text ( Header text) from PO using Read_text FM, and if the text contains any & symbol my form prints it as <(> & <)>, how to rectify this error ?
    user need to use & in text, so we can't avoid using it in the header text .
    Please guide me to rectify this error.
    Thanks in Advance.
    Regards,
    Joseph

    I am facing problem due to & only, the user enters & in Header text, but smart form prints it as <(> & <)>, now i am replacing all occurences of & with 'and' to solve the problem , but i want to know , whether we can use & in smart forms or not?
    Can special characters like & < > use in smart forms or not ?
    Kindly reply.
    Thanks & Regards,
    Joseph.

  • Regading Including Text in Smart forms

    Hi gurus,
    In vf02 they are giving some text . that text is going and saving in STXL table. I want to include this text in smart form.
    After choosing include text in General attributes. I am giving
    text object is vbbk
    Text id is time
    language en
    but i don't know what i want to give in text name.
    so plz help me.
    S.Murali Naidu
    Edited by: Murali Sreerama on Feb 6, 2008 10:12 AM

    Hi,
    Please use this code:: (reward pts)
    DATA gt_text LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA: gt_lines.
    REFRESH gt_text.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
       CLIENT                        = SY-MANDT
        id                            = 'your text id'
        language                      = sy-langu
        name                          = your billing doc no
        object                        = 'your obj id'
       ARCHIVE_HANDLE                = 0
       LOCAL_CAT                     = ' '
    IMPORTING
       HEADER                        =
      tables
        lines                         = gt_text
    EXCEPTIONS
       ID                            = 1
    LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
       WRONG_ACCESS_TO_ARCHIVE       = 7
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CLEAR: gt_line7,
    gt_lines.
    then to display that
    LOOP AT   gt_text.
    IF NOT gt_text-tdline IS INITIAL.
    CONCATENATE gt_line gt_text-tdline INTO gt_line SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    Edited by: rohitaash sharma on Feb 6, 2008 10:22 AM

  • Purchase requisition header text in smart forms

    Dear Experts,
        i want to pick the header text in smart form from purchase requisition ( Transaction code me52n).Can any one tell me from which table i can find out the header text of purchase requsition. please tell me table name objectid for include.
    Thanks in advance.
    Regards
    Maqsood Ahmed

    Hi,
    Go to the screen where the long text is placed, From menu bar go to the header you will get the Object details.
    Use FM READ_TEXT by passing those object details you will get the text.
    Have a look in this link to use READ_TEXT
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap+general&
    Regards,
    Satish

  • Use of SAP Smart Forms - Text Modules

    Hi!
    One or two questions regarding the SAP Smart Forms text modules.
    First: In which table the text name is saved? Is there something like the STXH table for SapScript Objects?
    Second: Is it possible to use SmartForm text modules in the text determination for SD (Invoice e.g.)?
    I´m looking forward for many answers
    Greetings
    Mark

    Hi,
      From STXL table u can get the text object, id n name pertaining to a text .These things put in FM 'READ_TEXT'. u get the long text...
    Instead in smartforms, u can directly include texts using Create-Text, Type Include text...enter the id, name ,lang and object....
    Also, for text names, objects and ID..u go to the place where long text has been entered, enter the sapscript editor from there, goto Header...u ll get all the detaails..
    hope it helps,
    Regards,
    Bikash

  • Smart forms and print program needed

    Can anyone provide me with the following print programs and smart forms? I can't find it in my SAP. Thanks.
    Print Program:
    /SMB40/M07DR
    Smart Forms:
    /SMB40/MMGR1_A
    /SMB40/MMGR3_A
    /SMB40/MMGI1_A
    Please kindly email me at [email protected]

    Hi
    I appreciate for your sincierty i cant send through mail but i'm sending directly plz copy all the programs
    INCLUDE /SMB40/M07DRTOP.
    PROGRAM /BPR3PF/m07dr MESSAGE-ID m7.
    DATA  lgortsplit LIKE am07m-xselk.
    DATA  ladr LIKE sadr.
    DATA  *ladr LIKE sadr.
    CONSTANTS: a TYPE c VALUE 'A',
               b TYPE c VALUE 'B',
               c TYPE c VALUE 'C',
               d TYPE c VALUE 'D',
               e TYPE c VALUE 'E',
               f TYPE c VALUE 'F',
               g TYPE c VALUE 'G',
               h TYPE c VALUE 'H',
               i TYPE c VALUE 'I',
               j TYPE c VALUE 'J',
               k TYPE c VALUE 'K',
               l TYPE c VALUE 'L',
               m TYPE c VALUE 'M',
               n TYPE c VALUE 'N',
               o TYPE c VALUE 'O',
               p TYPE c VALUE 'P',
               q TYPE c VALUE 'Q',
               r TYPE c VALUE 'R',
               s TYPE c VALUE 'S',
               t TYPE c VALUE 'T',
               u TYPE c VALUE 'U',
               v TYPE c VALUE 'V',
               w TYPE c VALUE 'W',
               x TYPE c VALUE 'X',
               y TYPE c VALUE 'Y',
               z TYPE c VALUE 'Z'.
    CONSTANTS: plus  TYPE c VALUE '+',
               minus TYPE c VALUE '-',
               punkt TYPE c VALUE '.',
               null  TYPE c VALUE '0',
               eins  TYPE c VALUE '1',
               zwei  TYPE c VALUE '2',
               drei  TYPE c VALUE '3',
               vier  TYPE c VALUE '4',
               fuenf TYPE c VALUE '5',
               sechs TYPE c VALUE '6',
              sieben TYPE c VALUE '7',
               acht  TYPE c VALUE '8',
               neun  TYPE c VALUE '9',
               einsi TYPE i VALUE '1',
               zweii TYPE i VALUE '2',
               dreii TYPE i VALUE '3',
               vieri TYPE i VALUE '4',
               nzwei TYPE i VALUE '02',
               ndrei TYPE i VALUE '03'.
    CONSTANTS: actvt01 LIKE tact-actvt VALUE '01',
               actvt02 LIKE tact-actvt VALUE '02',
               actvt03 LIKE tact-actvt VALUE '03',
               actvt04 LIKE tact-actvt VALUE '04',
               actvt06 LIKE tact-actvt VALUE '06',
               actvt65 LIKE tact-actvt VALUE '65',
               actvt70 LIKE tact-actvt VALUE '70'.
    CONSTANTS: maximum     TYPE f VALUE 9999999999999,
               minimum     TYPE f VALUE -9999999999999,
               maximum_gld TYPE f VALUE  99999999999,
               minimum_gld TYPE f VALUE  -99999999999,
               maxvalue LIKE am07m-maxvalue VALUE 9999999999999,
               minvalue LIKE am07m-maxvalue VALUE -9999999999999,
               cnull(18)   TYPE c VALUE '000000000000000000',
               pf02(4)     TYPE c VALUE 'PF02',
               pf15(4)     TYPE c VALUE 'PF15',
               stern       TYPE c VALUE '*',
               doublestar(2) TYPE c VALUE '**',
               underscore  TYPE c VALUE '_',
               slasch      TYPE c VALUE '/',
               dpunkt      TYPE c VALUE ':',
               curtp00     LIKE smbew-curtp VALUE '00', "Transaktionswährung
               curtp10     LIKE smbew-curtp VALUE '10', "ML in Hauswährung
               auto_best   LIKE mseg-ebeln  VALUE '9999999999',
               modulpool   LIKE sy-repid    VALUE 'SAPMM07M'.
    CONSTANTS: BEGIN OF hlp,
                 b(4) TYPE c VALUE 'HLPB',
                 f(4) TYPE c VALUE 'HLPF',
                 g(4) TYPE c VALUE 'HLPG',
                 m(4) TYPE c VALUE 'HLPM',
                 r(4) TYPE c VALUE 'HLPR',
                 v(4) TYPE c VALUE 'HLPV',
               END OF hlp.
                                           "Equates für Alphabet
    TABLES:
       afko,
       aufk,
       itcpo,
       mkpf,
      *mkpf,
       mseg,
      *mseg,
       ekko,
       ekkn,
      *ekko,
      arc_params,
       ekpo,
       ekbe,
       lfa1,
      *lfa1,
       thead,
       toa_dara,
       am07m,
      *am07m,
       t001,
       t001w,
      *t001w,
       t027b,
       t027c,
       t027d,
       t156,
       t156t,
       t157e,
      *t157e,
       t159m,
       t159n,
       t159o,
       t159p,
       t159s,
       t159e,
       t024,
       t024d,
      *t024,
       t064b,
       nast,
      *nast,
      tnapr.
    TABLES: mabdr,
            mtcom,
            mtcor,
            twlad.
    * Reportinterne Daten                                                 *
    *--- Strukturen ------------------------------------------------------*
    DATA: x_protab TYPE c,
          x_bwart TYPE c,
          bwart LIKE mseg-bwart,
          eintraege LIKE sy-tfill,
          anzahl LIKE mseg-weanz,
          anzahl1(7) TYPE n,
          x_kont TYPE c,                   "Mehrfachkontierung
          x_kont1 TYPE c,              "Einfache Kontierung (WE unbewertet)
          x_form TYPE c,
          x_open TYPE c.
    DATA: BEGIN OF jahr,
            jahr(4) TYPE n,
            monat(2) TYPE n,
            tag(2) TYPE n,
          END OF jahr.
    DATA:
       BEGIN OF we,
         version1 VALUE '1',               "Standardversion
         version2 VALUE '2',               "Version mit Prüftext
         version3 VALUE '3',               "WE-Sammelschein
       END OF we,
       BEGIN OF alt,
          matnr LIKE mseg-matnr,
          bwart LIKE mseg-bwart,
          ebeln LIKE mseg-ebeln,
          usnam LIKE mkpf-usnam,
       END OF alt,
       BEGIN OF kunde,
          kdauf LIKE mseg-kdauf,
          kdpos LIKE mseg-kdpos,
          kdein LIKE mseg-kdein,
       END OF kunde,
       BEGIN OF anlage,
          anln1 LIKE mseg-anln1,
          anln2 LIKE mseg-anln2,
       END OF anlage,
       BEGIN OF belpos,
          mblnr LIKE mseg-mblnr,
          zeile LIKE mseg-zeile,
       END OF belpos,
        xskkz,
        xpsty,
        xkdanr    VALUE 'C',
        xkde      VALUE 'E',
        xfert     VALUE 'F',
        xrvkdanr  VALUE 'A',
        xanlage   VALUE 'A',
        xanln1    VALUE 'I',
        xkostl    VALUE 'K',
        xprojn    VALUE 'P',
        xmunbw    VALUE 'M',
        xumlag    VALUE 'U',
        xvbelg    VALUE 'V',
        xnplan    VALUE 'N',
        xkonsi(2) VALUE 'KB',
        xwabel(2) VALUE 'WA',
        xwibel(2) VALUE 'WI',
        xwebel(2) VALUE 'WE',
         xsele,                            "Position selektiert
         xkont,                            "Kontierungswechsel
         xsamm,                            "Sammel-WE-Schein
         xanha.                            "Mehrfachkontierung
    DATA BEGIN OF theader.
            INCLUDE STRUCTURE thead.
    DATA END OF theader.
    *--- Interne Tabellen -------------------------------------------------*
    DATA:
       BEGIN OF dummy OCCURS 0,
         dummy,
       END OF dummy.
    DATA:
       BEGIN OF ausgabe OCCURS 20,
          mblnr LIKE mseg-mblnr,
       END OF ausgabe.
    DATA: BEGIN OF xekkn OCCURS 50.
            INCLUDE STRUCTURE ekkn.
    DATA: END OF xekkn.
    DATA: BEGIN OF xmseg OCCURS 50.
            INCLUDE STRUCTURE mseg.
    DATA: END OF xmseg.
    DATA: BEGIN OF dtext OCCURS 1.
            INCLUDE STRUCTURE tline.
    DATA: END OF dtext.
    DATA: BEGIN OF dktext OCCURS 1.
            INCLUDE STRUCTURE tline.
    DATA: END OF dktext.
    DATA: BEGIN OF dptext OCCURS 1.
            INCLUDE STRUCTURE thead.
    DATA: END OF dptext.
    DATA: BEGIN OF nast_key,
            mblnr LIKE mkpf-mblnr,
            mjahr LIKE mkpf-mjahr,
            zeile LIKE mseg-zeile,
          END OF nast_key.
    DATA: BEGIN OF beltab OCCURS 20.
            INCLUDE STRUCTURE mseg.
    DATA: vgart LIKE mkpf-vgart,
          blart LIKE mkpf-blart,
          blaum LIKE mkpf-blaum,
          bldat LIKE mkpf-bldat,
          budat LIKE mkpf-budat,
          cpudt LIKE mkpf-cpudt,
          cputm LIKE mkpf-cputm,
          aedat LIKE mkpf-aedat,
          usnam LIKE mkpf-usnam,
          tcode LIKE mkpf-tcode,
          xblnr LIKE mkpf-xblnr,
          bktxt LIKE mkpf-bktxt,
          frath LIKE mkpf-frath,
          frbnr LIKE mkpf-frbnr,
          wever LIKE mkpf-wever,
          kzdru LIKE t156-kzdru,
          END OF beltab.
    DATA: BEGIN OF traptab OCCURS 50.
            INCLUDE STRUCTURE mseg.
    DATA:   vgart LIKE mkpf-vgart,
            blart LIKE mkpf-blart,
            blaum LIKE mkpf-blaum,
            bldat LIKE mkpf-bldat,
            budat LIKE mkpf-budat,
            cpudt LIKE mkpf-cpudt,
            cputm LIKE mkpf-cputm,
            aedat LIKE mkpf-aedat,
            usnam LIKE mkpf-usnam,
            tcode LIKE mkpf-tcode,
            xblnr LIKE mkpf-xblnr,
            bktxt LIKE mkpf-bktxt,
            frath LIKE mkpf-frath,
            frbnr LIKE mkpf-frbnr,
            wever LIKE mkpf-wever,
          END OF traptab.
    DATA: BEGIN OF inthead OCCURS 50.
            INCLUDE STRUCTURE thead.
    DATA: END OF inthead.
    DATA: BEGIN OF intline OCCURS 50.
            INCLUDE STRUCTURE tline.
    DATA: END OF intline.
    DATA: BEGIN OF intline1 OCCURS 50.
            INCLUDE STRUCTURE tline.
    DATA: END OF intline1.
    *-------- Hilfsfelder -------------------------------------------------*
    DATA: index_z LIKE sy-tabix,
          drucker LIKE rm07m-ldest,
          old_tdform LIKE t159o-tdform,
          r_werks LIKE t001w-werks,
          r_name1 LIKE t001w-name1,
          x_form3 TYPE c,
          x_nopdest TYPE c,
          language LIKE t001w-spras,
          zaehler_m LIKE sy-tabix,
          edruck  TYPE c.
    DATA: old_mkpf LIKE mkpf-usnam,
          old_budat LIKE mkpf-budat,
          old_cpudt LIKE mkpf-cpudt,
          old_werks LIKE t001w-werks,
          old_name1 LIKE t001w-name1,
          old_mblnr LIKE mkpf-mblnr,
          old_lifnr LIKE ekko-lifnr,
          old_ebeln LIKE ekko-ebeln,
          old_ekgrp LIKE ekko-ekgrp,
          old_reswk LIKE ekko-reswk,
          old_linam LIKE am07m-name1,
          old_lina2 LIKE am07m-name2,
          old_eknam LIKE t024-eknam,
          old_ektel LIKE t024-ektel,
          old_ematn LIKE mseg-ematn,
          old_lfa1  LIKE lfa1,
          old_lgort LIKE mseg-lgort,
          old_ladr LIKE ladr,
          save_mkpf LIKE mkpf-usnam,
          save_budat LIKE mkpf-budat,
          save_cpudt LIKE mkpf-cpudt,
          save_werks LIKE t001w-werks,
          save_name1 LIKE t001w-name1,
          save_mblnr LIKE mkpf-mblnr,
          save_lifnr LIKE ekko-lifnr,
          save_reswk LIKE ekko-reswk,
          save_ebeln LIKE ekko-ebeln,
          save_ekgrp LIKE ekko-ekgrp,
          save_linam LIKE am07m-name1,
          save_lina2 LIKE am07m-name2,
          save_eknam LIKE t024-eknam,
          save_ektel LIKE t024-ektel,
          save_ematn LIKE mseg-ematn,
          save_lfa1  LIKE lfa1,
          save_lgort LIKE mseg-lgort,
          save_ladr LIKE ladr,
          offwhile TYPE c,
          & TYPE c VALUE '&',
          blank TYPE c VALUE ' ',
          fenster(5) TYPE c VALUE 'WIN  ',
          fcount(2) TYPE c,
          text1(21) TYPE c VALUE 'INTLINE-TDLINE+  (  )',
          text2(22) TYPE c VALUE 'INTLINE1-TDLINE+  (  )',
          text5(22) TYPE c VALUE 'INTLINE1-TDLINE+  (  )',
          hifeld1(21) TYPE c VALUE 'INTLINE-TDLINE+  (10)',
          shift(2) TYPE n,
          fpage LIKE sy-pagno,
          xscreen(1) TYPE c,
          retco LIKE sy-subrc,
          mblnr LIKE mkpf-mblnr,
          zeile LIKE mseg-zeile,
          new_page,
          xkopfdr,                         "Kopf bereits gedruckt
          n_vornr LIKE resb-vornr.         "Netzplanvorgang
    INCLUDE /SMB40/M07DRMTA.
    *------Lesen Tabelle T001----------------------------------------------*
    FORM TAB001_LESEN.
      IF NOT T001-BUKRS = MSEG-BUKRS.
        SELECT SINGLE * FROM T001 WHERE BUKRS = MSEG-BUKRS.
      ENDIF.
    ENDFORM.
    *-------Lesen Tabelle T001w--------------------------------------------*
    FORM TAB001W_LESEN.
      IF NOT T001W-WERKS = MSEG-WERKS.
        SELECT SINGLE * FROM T001W WHERE WERKS = MSEG-WERKS.
      ENDIF.
        R_WERKS = T001W-WERKS.
        R_NAME1 = T001W-NAME1.
    * Sprache für Formular aus Kondition, sonst aus Werk
      IF NOT NAST-SPRAS IS INITIAL.
        LANGUAGE = NAST-SPRAS.
      ELSE.
        LANGUAGE = T001W-SPRAS.
      ENDIF.
      SET LANGUAGE LANGUAGE.
    ENDFORM.
    *-------Lesen Tabelle T001w bei Werkswechsel --------------------------*
    FORM TAB001W_LESEN_2.
      IF NOT MSEG-WERKS = T001W-WERKS.
        SELECT SINGLE * FROM T001W WHERE WERKS = MSEG-WERKS.
      ENDIF.
    ENDFORM.
    *--------Lesen Tabelle T156--------------------------------------------*
    FORM TAB156_LESEN.
      IF NOT T156-BWART = MSEG-BWART.
        SELECT SINGLE * FROM T156 WHERE BWART = MSEG-BWART.
      ENDIF.
    ENDFORM.
    *-------Lesen Tabelle T156t--------------------------------------------*
    FORM TAB156T_LESEN.
      SELECT SINGLE * FROM T156T WHERE SPRAS = LANGUAGE
                                 AND   BWART = MSEG-BWART
                                 AND   SOBKZ = MSEG-SOBKZ
                                 AND   KZBEW = MSEG-KZBEW
                                 AND   KZZUG = MSEG-KZZUG
                                 AND   KZVBR = MSEG-KZVBR.
    ENDFORM.
    *------Lesen Tabelle T024----------------------------------------------*
    FORM TAB024_LESEN.
       IF NOT T024-EKGRP = EKKO-EKGRP.
         SELECT SINGLE * FROM T024 WHERE EKGRP = EKKO-EKGRP.
       ENDIF.
    ENDFORM.
    *------Lesen Tabelle T024D---------------------------------------------*
    FORM TAB024D_LESEN.
       SELECT SINGLE * FROM T024D WHERE WERKS = MSEG-WERKS
                                  AND   DISPO = AFKO-DISPO.
    ENDFORM.
    *---------------------- T027B,C lesen ---------------------------------*
    FORM T027_LESEN.
      SELECT SINGLE * FROM T027B WHERE SPRAS = LANGUAGE
                                 AND   EVERS = MSEG-EVERS.
      CHECK NOT MSEG-EVERE IS INITIAL.
      SELECT SINGLE * FROM T027C WHERE EVERS = MSEG-EVERS
                                 AND   EVERE = MSEG-EVERE.
      IF NOT T027C-EVDRK IS INITIAL.
        SELECT SINGLE * FROM T027D WHERE SPRAS = LANGUAGE
                                   AND   EVERS = MSEG-EVERS
                                   AND   EVERE = MSEG-EVERE.
      ENDIF.
    ENDFORM.
    *------------ Lesen der Tabelle T159P Barcode oder Mehrfachdruck ------*
    *----------------------- gewünscht ? ----------------------------------*
    FORM LESEN_T159P.
      IF NOT T159P-TDDEST = NAST-LDEST.
        SELECT SINGLE * FROM T159P WHERE TDDEST = NAST-LDEST.
      ENDIF.
    ENDFORM.
    *&      Form  T064B_LESEN
    *       Lesen Text zur Bestandsart Qualität/Gesperrt bei WE
    FORM T064B_LESEN.
      DATA: BSTAR LIKE T064B-BSTAR.
      CASE MSEG-INSMK.
        WHEN SPACE.
          CLEAR T064B.
          EXIT.
        WHEN F.
          CLEAR T064B.
          EXIT.
        WHEN X.
          BSTAR = ZWEI.
        WHEN ZWEI.
          BSTAR = ZWEI.
        WHEN S.
          BSTAR = VIER.
        WHEN DREI.
          BSTAR = VIER.
      ENDCASE.
      IF NOT T064B-BSTAR = BSTAR.
        SELECT SINGLE * FROM T064B WHERE SPRAS = LANGUAGE
                                   AND   BSTAR = BSTAR.
      ENDIF.
    ENDFORM.                    " T064B_LESEN
    INCLUDE /SMB40/M07DRMMA.
    *---------Material lesen-----------------------------------------------*
    FORM MATERIAL_LESEN.
      CLEAR MTCOM.
      MTCOM-KENNG = 'MABDR'.
      MTCOM-MATNR = MSEG-MATNR.
      MTCOM-WERKS = MSEG-WERKS.
      MTCOM-LGORT = MSEG-LGORT.
      MTCOM-SPRAS = LANGUAGE.
      MTCOM-NOMUS = 'X'.
      CALL FUNCTION 'MATERIAL_LESEN'
           EXPORTING
                SCHLUESSEL = MTCOM
           IMPORTING
                MATDATEN   = MABDR
                RETURN     = MTCOR
           TABLES
                SEQMAT01   = DUMMY.
      IF NOT T156-KZMHD IS INITIAL.
        IF NOT MABDR-MHDLP IS INITIAL.
          IF T001W-VLFKZ = B.              "Zentrale ?
            PERFORM MHD_BERECHNEN.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.
    *----------------- Mindesthaltbarkeit berechnen  ---------------------*
    FORM MHD_BERECHNEN.
      IF NOT EKPO-MHDRZ IS INITIAL.
        AM07M-MHDAT = MSEG-VFDAT - ( EKPO-MHDRZ * MABDR-MHDLP / 100 ).
      ELSEIF NOT MABDR-MHDRZ IS INITIAL.
        AM07M-MHDAT = MSEG-VFDAT - ( MABDR-MHDRZ * MABDR-MHDLP / 100 ).
      ENDIF.
    ENDFORM.
    *----------------- Prueftext lesen-------------------------------------*
    FORM PRUEFTEXT_LESEN.
      CLEAR  DPTEXT.
      CLEAR  THEADER.
      REFRESH DPTEXT.
      THEADER-TDID             = 'PRUE'.
      THEADER-TDSPRAS          = LANGUAGE.
      THEADER-TDNAME           = MSEG-MATNR.
      THEADER-TDOBJECT         = 'MATERIAL '.
      CALL FUNCTION 'SELECT_TEXT'
           EXPORTING
                ID         = THEADER-TDID
                LANGUAGE   = THEADER-TDSPRAS
                NAME       = THEADER-TDNAME
                OBJECT     = THEADER-TDOBJECT
           IMPORTING
                ENTRIES    = EINTRAEGE
           TABLES
                SELECTIONS = DPTEXT.
    ENDFORM.
    *                Lesen der Herstellerteilenummer                       *
    FORM LESEN_HTN.
      SELECT SINGLE MFRPN FROM MARA
               INTO (AM07M-MFRPN) WHERE MATNR = MSEG-EMATN.
    ENDFORM.
    INCLUDE /SMB40/M07DRMBE.
    *-------------Bestellung lesen-----------------------------------------*
    FORM BESTELLUNG_LESEN."ORDER READING
      DATA: NAME1 LIKE ADDR1_VAL-NAME1.
      DATA: OLD_LIFNR LIKE EKKO-LIFNR.
      CLEAR AM07M-NAME1.
      CLEAR AM07M-NAME2.
      IF EKKO-EBELN NE MSEG-EBELN.
        SELECT SINGLE * FROM EKKO WHERE EBELN = MSEG-EBELN.
      ENDIF.
      SELECT SINGLE * FROM EKPO WHERE EBELN = MSEG-EBELN
                                AND   EBELP = MSEG-EBELP.
    * Purchase order history because of XBLNR read, since from MKPF can
    *deviate
      SELECT SINGLE * FROM EKBE WHERE EBELN = MSEG-EBELN
                                AND   EBELP = MSEG-EBELP
                                AND   VGABE = '1'
                                AND   GJAHR = MSEG-MJAHR
                                AND   BELNR = MSEG-MBLNR
                                AND   BUZEI = MSEG-ZEILE.
      IF NOT SY-SUBRC IS INITIAL.
        CLEAR EKBE.
      ELSE.
        IF NOT EKBE-XBLNR IS INITIAL.
          MKPF-XBLNR = EKBE-XBLNR.
        ENDIF.
      ENDIF.
      CALL FUNCTION 'MM_ADDRESS_GET'
           EXPORTING  I_EKKO    = EKKO
           IMPORTING  E_NAME1   = NAME1
           EXCEPTIONS OTHERS    = 1.
      AM07M-NAME1 = NAME1.
      IF NOT EKKO-LLIEF IS INITIAL.
        OLD_LIFNR = EKKO-LIFNR.
        EKKO-LIFNR = EKKO-LLIEF.
        CALL FUNCTION 'MM_ADDRESS_GET'
             EXPORTING  I_EKKO    = EKKO
             IMPORTING  E_NAME1   = NAME1
             EXCEPTIONS OTHERS    = 1.
        AM07M-NAME2 = NAME1.
        EKKO-LIFNR = OLD_LIFNR.
      ENDIF.
      XPSTY = EKPO-KNTTP.
      CASE XPSTY.
        WHEN B.
          XPSTY = XKDE.
        WHEN D.
          XPSTY = XKDE.
        WHEN G.
          XPSTY = XPROJN.
        WHEN O.
          XPSTY = XPROJN.
        WHEN Q.
          XPSTY = XPROJN.
      ENDCASE.
    ENDFORM.
    *----------Bestelltext lesen, wenn Matnr. = 0--------------------------*
    FORM BESTELLTEXT_LESEN.
       CLEAR:   THEADER,
                THEAD,
                DTEXT.
       REFRESH
                DTEXT.
       THEADER-TDID          = 'F01 '.
       THEADER-TDSPRAS       = EKKO-SPRAS.
       THEADER-TDNAME(10)    = MSEG-EBELN.
       THEADER-TDNAME+10(5)  = MSEG-EBELP.
       THEADER-TDOBJECT      = 'EKPO      '.
       CALL FUNCTION 'READ_TEXT'
          EXPORTING ID          = THEADER-TDID
                    LANGUAGE    = THEADER-TDSPRAS
                    NAME        = THEADER-TDNAME
                    OBJECT      = THEADER-TDOBJECT
         IMPORTING  HEADER      = THEAD
         TABLES     LINES       = DTEXT
         EXCEPTIONS ID          = 1
                    LANGUAGE    = 2
                    NAME        = 3
                    NOT_FOUND   = 4
                    OBJECT      = 5.
    ENDFORM.
    *------------Bestellkopf lesen für WE-Version 2.-----------------------*
    FORM BESTELLKOPF_LESEN.
       CLEAR:   THEADER,
                THEAD,
                DKTEXT.
       REFRESH:
                DKTEXT.
       THEADER-TDID           = 'F01 '.
       THEADER-TDSPRAS        = EKKO-SPRAS.
       THEADER-TDNAME(10)     = MSEG-EBELN.
       THEADER-TDOBJECT       = 'EKKO      '.
       CALL FUNCTION 'READ_TEXT'
          EXPORTING ID        = THEADER-TDID
                    LANGUAGE  = THEADER-TDSPRAS
                    NAME      = THEADER-TDNAME
                    OBJECT    = THEADER-TDOBJECT
         IMPORTING  HEADER    = THEAD
         TABLES     LINES     = DKTEXT
         EXCEPTIONS ID        = 1
                    LANGUAGE  = 2
                    NAME      = 3
                    NOT_FOUND = 4
                    OBJECT    = 5.
    ENDFORM.
    INCLUDE /SMB40/M07DRMFA.
    *------ Auftragskopf lesen --------------------------------------------*
    FORM AUFTRAG_LESEN.
      SELECT SINGLE * FROM AFKO WHERE AUFNR = MSEG-AUFNR.
      IF MSEG-MATNR IS INITIAL.
        SELECT SINGLE * FROM AUFK WHERE AUFNR = MSEG-AUFNR.
        IF NOT SY-SUBRC IS INITIAL.
          MESSAGE E001 WITH 'AUFK' MSEG-AUFNR.
        ELSE.
          MABDR-MAKTX = AUFK-KTEXT.
        ENDIF.
      ENDIF.
    ENDFORM.
    INCLUDE /SMB40/M07DRKON.
    FORM KONTIERUNG_LESEN.
       REFRESH XEKKN. CLEAR XEKKN.
       SELECT * FROM EKKN WHERE EBELN = EKPO-EBELN
                          AND   EBELP = EKPO-EBELP.
         MOVE-CORRESPONDING EKKN TO XEKKN.
         APPEND XEKKN.
    *    x_kont = x.
       ENDSELECT.
       DESCRIBE TABLE XEKKN LINES INDEX_Z.
       IF INDEX_Z GT 1.
         X_KONT = X.
       ELSE.
         X_KONT1 = X.
       ENDIF.
    ENDFORM.
    * Network plan process determine.
    FORM NW_VORGANG_LESEN USING F_AUFPL F_APLZL.
      CALL FUNCTION 'READ_NETWORK_NPLNR_VORNR'
           EXPORTING
                APLZL     = F_APLZL
                AUFPL     = F_AUFPL
           IMPORTING
                VORNR     = N_VORNR
           EXCEPTIONS
                NOT_FOUND = 01.
    ENDFORM.
    *       FORM PSP_CONVERT                                               *
    *       Konvertierung des internen Felds PS_PSP_PNR zur Ausgabe        *
    FORM PSP_CONVERT USING PSPNR LIKE MSEG-PS_PSP_PNR.
      CALL FUNCTION 'CJPN_INTERN_TO_EXTERN_CONV'
           EXPORTING
                INT_NUM = PSPNR
           IMPORTING
                EXT_NUM = AM07M-KONTIERUNG.
    ENDFORM.
    INCLUDE /SMB40/M07DRF01.
    FORM WF01_DRUCK.
       CALL FUNCTION 'START_FORM'
          EXPORTING FORM = TNAPR-FONAM
                LANGUAGE = LANGUAGE.
          BELPOS-MBLNR = MKPF-MBLNR.
          BELPOS-ZEILE = MSEG-ZEILE.
          CONDENSE BELPOS NO-GAPS.
          AM07M-BELPOS = BELPOS.
          IF T156-SHKZG = H.
            AM07M-HDLNE = TEXT-020.
          ELSE.
            AM07M-HDLNE = TEXT-010.
          ENDIF.
          IF NOT T159P-BACOD IS INITIAL.
            CALL FUNCTION 'WRITE_FORM'
                 EXPORTING ELEMENT = 'W1BACOKOPF'.
          ELSE.
             CALL FUNCTION 'WRITE_FORM'
                 EXPORTING ELEMENT = 'W1KOPF'.
          ENDIF.
          IF XPSTY       IS INITIAL.
             IF MSEG-XBLVS IS INITIAL.
                PERFORM WF1_LAGERMATERIAL.             "Lagermaterial
             ELSE.
                PERFORM WF1_LVSMATERIAL.               "LVS-Material
             ENDIF.
          ELSE.
             PERFORM WF1_VERBRAUCHSMATERIAL.
          ENDIF.
       CALL FUNCTION 'END_FORM'.
       PERFORM MKTO_DRUCK.
    ENDFORM.
    *------------ Drucken Lagermaterial ---------------------------------*
    FORM WF1_LAGERMATERIAL.
       CALL FUNCTION 'WRITE_FORM'
          EXPORTING ELEMENT = 'W1LGMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELGGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'LGAUSST'.
    ENDFORM.
    FORM WF1_LVSMATERIAL.
       CALL FUNCTION 'WRITE_FORM'
          EXPORTING ELEMENT = 'W1LVSMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELVSGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'LVSAUSST'.
    ENDFORM.
    *-------------Drucken Verbrauchsmaterial------------------------------*
    FORM WF1_VERBRAUCHSMATERIAL.
       CASE XPSTY.
         WHEN XKDANR.                             "Kundenauftrag
           MOVE SPACE TO KUNDE.
           CLEAR AM07M-KOTXT.
           AM07M-KOTXT = TEXT-030.
           KUNDE-KDAUF = MSEG-KDAUF.
           KUNDE-KDPOS = MSEG-KDPOS.
           KUNDE-KDEIN = MSEG-KDEIN.
           MOVE SPACE TO AM07M-KONTIERUNG.
           CONDENSE KUNDE NO-GAPS.
           AM07M-KONTIERUNG = KUNDE.
         WHEN XANLAGE.                            "Anlage
           MOVE SPACE TO ANLAGE.
           CLEAR AM07M-KOTXT.
           AM07M-KOTXT = TEXT-040.
           ANLAGE-ANLN1 = MSEG-ANLN1.
           ANLAGE-ANLN2 = MSEG-ANLN2.
           MOVE SPACE TO AM07M-KONTIERUNG.
           CONDENSE ANLAGE NO-GAPS.
           AM07M-KONTIERUNG = ANLAGE.
         WHEN XKOSTL.                             "Kostenstelle
           CLEAR AM07M-KOTXT.
           AM07M-KOTXT = TEXT-050.
           AM07M-KONTIERUNG = MSEG-KOSTL.
         WHEN XPROJN.                             "Projekt/Netzplan
           CLEAR AM07M-KOTXT.
           IF MSEG-NPLNR IS INITIAL.
             AM07M-KOTXT = TEXT-060.
             PERFORM PSP_CONVERT USING MSEG-PS_PSP_PNR.
           ELSE.
             AM07M-KOTXT = TEXT-061.
             AM07M-KONTIERUNG = MSEG-NPLNR.
             PERFORM NW_VORGANG_LESEN USING MSEG-AUFPL MSEG-APLZL.
             IF NOT N_VORNR IS INITIAL.
               MOVE '/'     TO AM07M-KONTIERUNG+12.
               MOVE N_VORNR TO AM07M-KONTIERUNG+13.
             ENDIF.
           ENDIF.
       ENDCASE.
       CALL FUNCTION 'WRITE_FORM'
         EXPORTING ELEMENT = 'W1VERBRMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELVERBRGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'VERBRAUSST'.
    ENDFORM.
    INCLUDE /SMB40/M07DRF02.
    FORM WF02_DRUCK.
       T001W-WERKS = R_WERKS.
       T001W-NAME1 = R_NAME1.
       CALL FUNCTION 'START_FORM'
            EXPORTING FORM = TNAPR-FONAM
                  LANGUAGE = LANGUAGE.
       PERFORM PRUEFTEXT_LESEN.
          IF T156-SHKZG = 'H'.           "Kennzeichen Haben ?
            AM07M-HDLNE = TEXT-020.
          ELSE.
            AM07M-HDLNE = TEXT-010.
          ENDIF.
          IF NOT T159P-BACOD IS INITIAL.
            BELPOS-MBLNR = MKPF-MBLNR.
            BELPOS-ZEILE = MSEG-ZEILE.
            CONDENSE BELPOS NO-GAPS.
            AM07M-BELPOS = BELPOS.
            CALL FUNCTION 'WRITE_FORM'
                 EXPORTING ELEMENT = 'WE2BACOKOPF'.
          ELSE.
            CALL FUNCTION 'WRITE_FORM'
                 EXPORTING ELEMENT = 'WE2KOPF'.
          ENDIF.
          IF XPSTY       IS INITIAL.        "Lagermaterial ?
             PERFORM W2_LAGERMATERIAL.
          ELSE.
             PERFORM W2_VERBRAUCHSMATERIAL.
          ENDIF.
       CALL FUNCTION 'END_FORM'.
       PERFORM MKTO_DRUCK.
    ENDFORM.
    *-------------- Lagermaterial WE-Version 2 ---------------------------*
    FORM WF2_LAGERMATERIAL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING ELEMENT = 'WE2LGMAT'.
      IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
        SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                   AND   GRUND = MSEG-GRUND
                                   AND   SPRAS = LANGUAGE.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING ELEMENT = 'RUELGGRUND'.
      ENDIF.
        THEAD-TDID     = THEADER-TDID.
        THEAD-TDNAME   = THEADER-TDNAME.
        THEAD-TDOBJECT = THEADER-TDOBJECT.
        THEAD-TDSPRAS  = THEADER-TDSPRAS.
        CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'PRTXTLGMAT'.
    ENDFORM.
    *------------ Verbrauchsmaterial WE-Version 2 ----------------------*
    FORM WF2_VERBRAUCHSMATERIAL.
        CASE XPSTY.
           WHEN XKDANR.
              MOVE SPACE TO KUNDE.
              CLEAR AM07M-KOTXT.
              AM07M-KOTXT = TEXT-030.
              KUNDE-KDAUF = MSEG-KDAUF.
              KUNDE-KDPOS = MSEG-KDPOS.
              KUNDE-KDEIN = MSEG-KDEIN.
              MOVE SPACE TO AM07M-KONTIERUNG.
              CONDENSE KUNDE NO-GAPS.
              AM07M-KONTIERUNG = KUNDE.
           WHEN XANLAGE.
              MOVE SPACE TO ANLAGE.
              CLEAR AM07M-KOTXT.
              AM07M-KOTXT = TEXT-040.
              ANLAGE-ANLN1 = MSEG-ANLN1.
              ANLAGE-ANLN2 = MSEG-ANLN2.
              MOVE SPACE TO AM07M-KONTIERUNG.
              CONDENSE ANLAGE NO-GAPS.
              AM07M-KONTIERUNG = ANLAGE.
           WHEN XKOSTL.
              CLEAR AM07M-KOTXT.
              AM07M-KOTXT = TEXT-050.
              AM07M-KONTIERUNG = MSEG-KOSTL.
           WHEN XPROJN.
              CLEAR AM07M-KOTXT.
              IF MSEG-NPLNR IS INITIAL.
                AM07M-KOTXT = TEXT-060.
                PERFORM PSP_CONVERT USING MSEG-PS_PSP_PNR.
              ELSE.
                AM07M-KOTXT = TEXT-061.
                AM07M-KONTIERUNG = MSEG-NPLNR.
                PERFORM NW_VORGANG_LESEN USING MSEG-AUFPL MSEG-APLZL.
                IF NOT N_VORNR IS INITIAL.
                  MOVE '/'     TO AM07M-KONTIERUNG+12.
                  MOVE N_VORNR TO AM07M-KONTIERUNG+13.
                ENDIF.
              ENDIF.
        ENDCASE.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING ELEMENT = 'WE2VERBRMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUEVERBRGRUND'.
       ENDIF.
         THEAD-TDID     = THEADER-TDID.
         THEAD-TDNAME   = THEADER-TDNAME.
         THEAD-TDOBJECT = THEADER-TDOBJECT.
         THEAD-TDSPRAS  = THEADER-TDSPRAS.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'PRTXTVERBRMAT'.
    ENDFORM.
    INCLUDE /SMB40/M07DRE01.
    FORM WE01_DRUCK.
       T001W-WERKS = R_WERKS.
       T001W-NAME1 = R_NAME1.
    ENDFORM.
    *------------ Drucken Lagermaterial ---------------------------------*
    FORM W1_LAGERMATERIAL.
       CALL FUNCTION 'WRITE_FORM'
          EXPORTING ELEMENT = 'W1LGMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELGGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'LGAUSST'.
    ENDFORM.
    FORM W1_LVSMATERIAL.
       CALL FUNCTION 'WRITE_FORM'
          EXPORTING ELEMENT = 'W1LVSMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELVSGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'LVSAUSST'.
    ENDFORM.
    *-------------Drucken Verbrauchsmaterial------------------------------*
    FORM W1_VERBRAUCHSMATERIAL.
       CLEAR: AM07M-KOTXT, AM07M-KONTIERUNG.
       CASE XPSTY.
         WHEN XFERT.                            "Fertigungsauftrag
           AM07M-KOTXT = TEXT-062.
           IF X_KONT1 IS INITIAL.
             AM07M-KONTIERUNG = MSEG-AUFNR.
           ELSE.
             AM07M-KONTIERUNG = EKKN-AUFNR.
           ENDIF.
         WHEN XKDE.                             "Kundeneinzelbest.
           MOVE SPACE TO KUNDE.
           AM07M-KOTXT = TEXT-030.
           IF X_KONT1 IS INITIAL.
             KUNDE-KDAUF = MSEG-KDAUF.
             KUNDE-KDPOS = MSEG-KDPOS.
            ELSE.
             KUNDE-KDAUF = EKKN-VBELN.
             KUNDE-KDPOS = EKKN-VBELP.
            ENDIF.
           MOVE SPACE TO AM07M-KONTIERUNG.
           CONDENSE KUNDE NO-GAPS.
           AM07M-KONTIERUNG = KUNDE.
         WHEN XKDANR.                             "Kundenauftrag
           MOVE SPACE TO KUNDE.
           AM07M-KOTXT = TEXT-030.
           IF X_KONT1 IS INITIAL.
             KUNDE-KDAUF = MSEG-KDAUF.
             KUNDE-KDPOS = MSEG-KDPOS.
             KUNDE-KDEIN = MSEG-KDEIN.
            ELSE.
             KUNDE-KDAUF = EKKN-VBELN.
             KUNDE-KDPOS = EKKN-VBELP.
             KUNDE-KDEIN = EKKN-VETEN.
            ENDIF.
           MOVE SPACE TO AM07M-KONTIERUNG.
           CONDENSE KUNDE NO-GAPS.
           AM07M-KONTIERUNG = KUNDE.
         WHEN XANLAGE.                            "Anlage
           MOVE SPACE TO ANLAGE.
           AM07M-KOTXT = TEXT-040.
           IF X_KONT1 IS INITIAL.
             ANLAGE-ANLN1 = MSEG-ANLN1.
             ANLAGE-ANLN2 = MSEG-ANLN2.
           ELSE.
             ANLAGE-ANLN1 = EKKN-ANLN1.
             ANLAGE-ANLN2 = EKKN-ANLN2.
           ENDIF.
           MOVE SPACE TO AM07M-KONTIERUNG.
           CONDENSE ANLAGE NO-GAPS.
           AM07M-KONTIERUNG = ANLAGE.
         WHEN XKOSTL.                             "Kostenstelle
           AM07M-KOTXT = TEXT-050.
           IF X_KONT1 IS INITIAL.
             AM07M-KONTIERUNG = MSEG-KOSTL.
           ELSE.
             AM07M-KONTIERUNG = EKKN-KOSTL.
           ENDIF.
         WHEN XPROJN.                             "Projekt/Netzplan
           IF X_KONT1 IS INITIAL.
             IF MSEG-NPLNR IS INITIAL.
               AM07M-KOTXT = TEXT-060.
               PERFORM PSP_CONVERT USING MSEG-PS_PSP_PNR.
             ELSE.
               AM07M-KOTXT = TEXT-061.
               AM07M-KONTIERUNG = MSEG-NPLNR.
               PERFORM NW_VORGANG_LESEN USING MSEG-AUFPL MSEG-APLZL.
               IF NOT N_VORNR IS INITIAL.
                 MOVE '/'     TO AM07M-KONTIERUNG+12.
                 MOVE N_VORNR TO AM07M-KONTIERUNG+13.
               ENDIF.
             ENDIF.
           ELSE.
             IF EKKN-NPLNR IS INITIAL.
               AM07M-KOTXT = TEXT-060.
               PERFORM PSP_CONVERT USING EKKN-PS_PSP_PNR.
             ELSE.
               AM07M-KOTXT = TEXT-061.
               AM07M-KONTIERUNG = EKKN-NPLNR.
               PERFORM NW_VORGANG_LESEN USING EKKN-AUFPL EKKN-APLZL.
               IF NOT N_VORNR IS INITIAL.
                 MOVE '/'     TO AM07M-KONTIERUNG+12.
                 MOVE N_VORNR TO AM07M-KONTIERUNG+13.
               ENDIF.
             ENDIF.
           ENDIF.
       ENDCASE.
       CLEAR X_KONT1.
    * User-Exit über Erweiterung MBCF0005
       CALL CUSTOMER-FUNCTION '001'
            EXPORTING
                 I_MKPF  = MKPF
                 I_MSEG  = MSEG
                 I_EKKO  = EKKO
                 I_EKPO  = EKPO
                 I_NAST  = NAST
                 I_TNAPR = TNAPR
            TABLES
                 I_EKKN  = XEKKN
            CHANGING
                 C_AM07M = AM07M
            EXCEPTIONS
                 OTHERS  = 0.
       CALL FUNCTION 'WRITE_FORM'
         EXPORTING ELEMENT = 'W1VERBRMAT'.
       IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
         SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                    AND   GRUND = MSEG-GRUND
                                    AND   SPRAS = LANGUAGE.
         CALL FUNCTION 'WRITE_FORM'
              EXPORTING ELEMENT = 'RUELVERBRGRUND'.
       ENDIF.
       CALL FUNCTION 'WRITE_FORM'
            EXPORTING ELEMENT = 'VERBRAUSST'.
    ENDFORM.
    INCLUDE /SMB40/M07DRE02.
    *       FORM WE02_DRUCK                                               *
    FORM WE02_DRUCK.
      T001W-WERKS = R_WERKS.
      T001W-NAME1 = R_NAME1.
      CALL FUNCTION 'START_FORM'
           EXPORTING
                FORM     = TNAPR-FONAM
                LANGUAGE = LANGUAGE.
      PERFORM PRUEFTEXT_LESEN.
      IF NOT MSEG-VFDAT IS INITIAL.
        AM07M-MHTXT = TEXT-105.
      ENDIF.
      IF NOT AM07M-MHDAT IS INITIAL.
        AM07M-MHZTX = TEXT-106.
      ENDIF.
      IF EKKO-BSART = 'UB'.
        AM07M-LITXT = TEXT-101.
        AM07M-LIBZG = EKKO-RESWK.
      ELSE.
        AM07M-LITXT = TEXT-100.
        AM07M-LIBZG = EKKO-LIFNR.
        IF NOT EKKO-LLIEF IS INITIAL.
          AM07M-LIBZ2 = EKKO-LLIEF.
        ELSE.
          AM07M-LIBZ2 = EKKO-LIFNR.
        ENDIF.
      ENDIF.
      IF T156-SHKZG = 'H'.                 "Kennzeichen Haben ?
        AM07M-HDLNE = TEXT-020.
      ELSE.
        AM07M-HDLNE = TEXT-010.
      ENDIF.
      IF NOT T159P-BACOD IS INITIAL.
        BELPOS-MBLNR = MKPF-MBLNR.
        BELPOS-ZEILE = MSEG-ZEILE.
        CONDENSE BELPOS NO-GAPS.
        AM07M-BELPOS = BELPOS.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING
                  ELEMENT = 'WE2BACOKOPF'.
      ELSE.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING
                  ELEMENT = 'WE2KOPF'.
      ENDIF.
      IF XPSTY       IS INITIAL.           "Lagermaterial ?
    * User-Exit über Erweiterung MBCF0005
        CALL CUSTOMER-FUNCTION '001'
             EXPORTING
                  I_MKPF  = MKPF
                  I_MSEG  = MSEG
                  I_EKKO  = EKKO
                  I_EKPO  = EKPO
                  I_NAST  = NAST
                  I_TNAPR = TNAPR
             TABLES
                  I_EKKN  = XEKKN
             CHANGING
                  C_AM07M = AM07M
             EXCEPTIONS
                  OTHERS  = 0.
        IF MSEG-XBLVS IS INITIAL.
           PERFORM W2_LAGERMATERIAL.             "Lagermaterial
        ELSE.
           PERFORM W2_LVSMATERIAL.               "LVS-Material
        ENDIF.
      ELSE.
        PERFORM W2_VERBRAUCHSMATERIAL.
      ENDIF.
      CALL FUNCTION 'END_FORM'.
      PERFORM MKTO_DRUCK.
    ENDFORM.
    *-------------- Lagermaterial WE-Version 2 ---------------------------*
    FORM W2_LAGERMATERIAL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'WE2LGMAT'.
      IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
        SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                   AND   GRUND = MSEG-GRUND
                                   AND   SPRAS = LANGUAGE.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING
                  ELEMENT = 'RUELGGRUND'.
      ENDIF.
      THEAD-TDID     = THEADER-TDID.
      THEAD-TDNAME   = THEADER-TDNAME.
      THEAD-TDOBJECT = THEADER-TDOBJECT.
      THEAD-TDSPRAS  = THEADER-TDSPRAS.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'PRTXTLGMAT'.
    ENDFORM.
    *-------------- LVS-Daten     WE-Version 2 ---------------------------*
    FORM W2_LVSMATERIAL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'W1LVSMAT'.
      IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
        SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                   AND   GRUND = MSEG-GRUND
                                   AND   SPRAS = LANGUAGE.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING
                  ELEMENT = 'RUELVSGRUND'.
      ENDIF.
      THEAD-TDID     = THEADER-TDID.
      THEAD-TDNAME   = THEADER-TDNAME.
      THEAD-TDOBJECT = THEADER-TDOBJECT.
      THEAD-TDSPRAS  = THEADER-TDSPRAS.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'PRTXTLVSMAT'.
    ENDFORM.
    *------------ Verbrauchsmaterial WE-Version 2 ----------------------*
    FORM W2_VERBRAUCHSMATERIAL.
      CLEAR: AM07M-KOTXT, AM07M-KONTIERUNG.
      CASE XPSTY.
        WHEN XFERT.                        "Fertigungsauftrag
          AM07M-KOTXT = TEXT-062.
          IF X_KONT1 IS INITIAL.
            AM07M-KONTIERUNG = MSEG-AUFNR.
          ELSE.
            AM07M-KONTIERUNG = EKKN-AUFNR.
          ENDIF.
        WHEN XKDE.
          MOVE SPACE TO KUNDE.
          AM07M-KOTXT = TEXT-030.
          IF X_KONT1 IS INITIAL.
            KUNDE-KDAUF = MSEG-KDAUF.
            KUNDE-KDPOS = MSEG-KDPOS.
          ELSE.
            KUNDE-KDAUF = EKKN-VBELN.
            KUNDE-KDPOS = EKKN-VBELP.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE KUNDE NO-GAPS.
          AM07M-KONTIERUNG = KUNDE.
        WHEN XKDANR.
          MOVE SPACE TO KUNDE.
          AM07M-KOTXT = TEXT-030.
          IF X_KONT1 IS INITIAL.
            KUNDE-KDAUF = MSEG-KDAUF.
            KUNDE-KDPOS = MSEG-KDPOS.
            KUNDE-KDEIN = MSEG-KDEIN.
          ELSE.
            KUNDE-KDAUF = EKKN-VBELN.
            KUNDE-KDPOS = EKKN-VBELP.
            KUNDE-KDEIN = EKKN-VETEN.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE KUNDE NO-GAPS.
          AM07M-KONTIERUNG = KUNDE.
        WHEN XANLAGE.
          MOVE SPACE TO ANLAGE.
          AM07M-KOTXT = TEXT-040.
          IF X_KONT1 IS INITIAL.
            ANLAGE-ANLN1 = MSEG-ANLN1.
            ANLAGE-ANLN2 = MSEG-ANLN2.
          ELSE.
            ANLAGE-ANLN1 = EKKN-ANLN1.
            ANLAGE-ANLN2 = EKKN-ANLN2.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE ANLAGE NO-GAPS.
          AM07M-KONTIERUNG = ANLAGE.
        WHEN XKOSTL.
          AM07M-KOTXT = TEXT-050.
          IF X_KONT1 IS INITIAL.
            AM07M-KONTIERUNG = MSEG-KOSTL.
          ELSE.
            AM07M-KONTIERUNG = EKKN-KOSTL.
          ENDIF.
        WHEN XPROJN.
          IF X_KONT1 IS INITIAL.
            IF MSEG-NPLNR IS INITIAL.
              AM07M-KOTXT = TEXT-060.
              PERFORM PSP_CONVERT USING MSEG-PS_PSP_PNR.
            ELSE.
              AM07M-KOTXT = TEXT-061.
              AM07M-KONTIERUNG = MSEG-NPLNR.
              PERFORM NW_VORGANG_LESEN USING MSEG-AUFPL MSEG-APLZL.
              IF NOT N_VORNR IS INITIAL.
                MOVE '/'     TO AM07M-KONTIERUNG+12.
                MOVE N_VORNR TO AM07M-KONTIERUNG+13.
              ENDIF.
            ENDIF.
          ELSE.
            IF EKKN-NPLNR IS INITIAL.
              AM07M-KOTXT = TEXT-060.
              PERFORM PSP_CONVERT USING EKKN-PS_PSP_PNR.
            ELSE.
              AM07M-KOTXT = TEXT-061.
              AM07M-KONTIERUNG = EKKN-NPLNR.
              PERFORM NW_VORGANG_LESEN USING EKKN-AUFPL EKKN-APLZL.
              IF NOT N_VORNR IS INITIAL.
                MOVE '/'     TO AM07M-KONTIERUNG+12.
                MOVE N_VORNR TO AM07M-KONTIERUNG+13.
              ENDIF.
            ENDIF.
          ENDIF.
      ENDCASE.
      CLEAR X_KONT1.
    * User-Exit über Erweiterung MBCF0005
      CALL CUSTOMER-FUNCTION '001'
           EXPORTING
                I_MKPF  = MKPF
                I_MSEG  = MSEG
                I_EKKO  = EKKO
                I_EKPO  = EKPO
                I_NAST  = NAST
                I_TNAPR = TNAPR
           TABLES
                I_EKKN  = XEKKN
           CHANGING
                C_AM07M = AM07M
           EXCEPTIONS
                OTHERS  = 0.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'WE2VERBRMAT'.
      IF T156-SHKZG = H AND
        NOT MSEG-GRUND IS INITIAL.
        SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                   AND   GRUND = MSEG-GRUND
                                   AND   SPRAS = LANGUAGE.
        CALL FUNCTION 'WRITE_FORM'
             EXPORTING
                  ELEMENT = 'RUEVERBRGRUND'.
      ENDIF.
      THEAD-TDID     = THEADER-TDID.
      THEAD-TDNAME   = THEADER-TDNAME.
      THEAD-TDOBJECT = THEADER-TDOBJECT.
      THEAD-TDSPRAS  = THEADER-TDSPRAS.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'PRTXTVERBRMAT'.
    ENDFORM.
    INCLUDE /SMB40/M07DRE03.
    *       FORM WE03_AUSGABE                                             *
    FORM WE03_AUSGABE using lgortsplit.
    *----------------Drucken WE-Version 3 Überschrift---------------------*
      if lgortsplit is initial.
         ON CHANGE OF MKPF-MBLNR OR MSEG-EBELN OR MSEG-BWART
                                 OR NAST-KSCHL OR MSEG-WERKS.
         CLEAR XKOPFDR.
         endon.
      else.
         ON CHANGE OF MKPF-MBLNR OR MSEG-EBELN OR MSEG-BWART
                                 OR NAST-KSCHL OR MSEG-WERKS
                                 OR MSEG-LGORT.
         CLEAR XKOPFDR.
         endon.
      endif.
      IF XKOPFDR IS INITIAL.
        XKOPFDR = X.
        IF NEW_PAGE = X.
          CALL FUNCTION 'CONTROL_FORM'
               EXPORTING
                    COMMAND = 'NEW-PAGE'.
        ENDIF.
        IF EKKO-BSART = 'UB'.
          AM07M-LITXT = TEXT-101.
          AM07M-LIBZG = EKKO-RESWK.
        ELSE.
          AM07M-LITXT = TEXT-100.
          AM07M-LIBZG = EKKO-LIFNR.
          IF NOT EKKO-LLIEF IS INITIAL.
            AM07M-LIBZ2 = EKKO-LLIEF.
          ELSE.
            AM07M-LIBZ2 = EKKO-LIFNR.
          ENDIF.
        ENDIF.
        IF T156-SHKZG = H.
          AM07M-HDLNE = TEXT-020.
        ELSE.
          AM07M-HDLNE = TEXT-010.
        ENDIF.
        IF XPSTY       IS INITIAL.         "Lagermaterial ?
          IF MSEG-XBLVS IS INITIAL.
            IF T156-SHKZG = H AND
               NOT MSEG-GRUND IS INITIAL.
              IF NOT T159P-BACOD IS INITIAL.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3BACOKOPF'
                          WINDOW  = 'RÜKOPF'.
                NEW_PAGE = X.
              ELSE.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3KOPF'
                          WINDOW  = 'RÜKOPF'.
                NEW_PAGE = X.
              ENDIF.
            ELSE.
              IF NOT T159P-BACOD IS INITIAL.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3BACOKOPF'
                          WINDOW  = 'KOPF'.
                NEW_PAGE = X.
              ELSE.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3KOPF'
                          WINDOW  = 'KOPF'.
                NEW_PAGE = X.
              ENDIF.
            ENDIF.
          ELSE.
            IF T156-SHKZG = H AND
               NOT MSEG-GRUND IS INITIAL.
              IF NOT T159P-BACOD IS INITIAL.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3BACOLVSKOPF'
                          WINDOW  = 'RÜKOPF'.
                NEW_PAGE = X.
              ELSE.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3LVSKOPF'  "RL-Material
                          WINDOW  = 'RÜKOPF'.
                NEW_PAGE = X.
              ENDIF.
            ELSE.
              IF NOT T159P-BACOD IS INITIAL.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3BACOLVSKOPF'
                          WINDOW  = 'KOPF'.
                NEW_PAGE = X.
              ELSE.
                CALL FUNCTION 'WRITE_FORM'
                     EXPORTING
                          ELEMENT = 'WE3LVSKOPF'  "RL-Material
                          WINDOW  = 'KOPF'.
                NEW_PAGE = X.
              ENDIF.
            ENDIF.
          ENDIF.
        ELSE.
          IF T156-SHKZG = H AND
             NOT MSEG-GRUND IS INITIAL.
            IF NOT T159P-BACOD IS INITIAL.
              CALL FUNCTION 'WRITE_FORM'
                   EXPORTING
                        ELEMENT = 'WE3BACOKOPF1'
                        WINDOW  = 'RÜKOPF'.
              NEW_PAGE = X.
            ELSE.
              CALL FUNCTION 'WRITE_FORM'
                   EXPORTING
                        ELEMENT = 'WE3KOPF1'
                        WINDOW  = 'RÜKOPF'.
              NEW_PAGE = X.
            ENDIF.
          ELSE.
            IF NOT T159P-BACOD IS INITIAL.
              CALL FUNCTION 'WRITE_FORM'
                   EXPORTING
                        ELEMENT = 'WE3BACOKOPF1'
                        WINDOW  = 'KOPF'.
              NEW_PAGE = X.
            ELSE.
              CALL FUNCTION 'WRITE_FORM'
                   EXPORTING
                        ELEMENT = 'WE3KOPF1'
                        WINDOW  = 'KOPF'.
              NEW_PAGE = X.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    *------------- Drucken WE-Version 3 Position --------------------------*
    **perform w3_lieferplan.                  "Routine Lieferplan
      CLEAR T157E.
      IF T156-SHKZG = H AND
         NOT MSEG-GRUND IS INITIAL.
        SELECT SINGLE * FROM T157E WHERE BWART = MSEG-BWART
                                   AND   GRUND = MSEG-GRUND
                                   AND   SPRAS = LANGUAGE.
      ENDIF.
      IF MSEG-EBELN IS INITIAL.
        IF NOT MABDR-MAKTX IS INITIAL.
          EKPO-TXZ01 = MABDR-MAKTX.
        ENDIF.
      ENDIF.
      IF MABDR-WERTU IS INITIAL AND
         MABDR-MENGU = X   OR              "Bestandsfuehrung = UNBW oder
         XPSTY       IS INITIAL.           "Lagermaterial ?
    * User-Exit über Erweiterung MBCF0005
        CALL CUSTOMER-FUNCTION '001'
             EXPORTING
                  I_MKPF  = MKPF
                  I_MSEG  = MSEG
                  I_EKKO  = EKKO
                  I_EKPO  = EKPO
                  I_NAST  = NAST
                  I_TNAPR = TNAPR
             TABLES
                  I_EKKN  = XEKKN
             CHANGING
                  C_AM07M = AM07M
             EXCEPTIONS
                  OTHERS  = 0.
        IF MSEG-XBLVS IS INITIAL.
          PERFORM W3_LAGERMATERIAL.        "Routine Lagermaterial
        ELSE.
          PERFORM W3_LVSMATERIAL.          "Routine RL-Material
        ENDIF.
      ELSE.
        PERFORM W3_VERBRAUCHSMATERIAL.     "Routine Verbrauchsmaterial
      ENDIF.
    *-------------- Drucken WE-Version 3 Seitenfuss ----------------------*
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT  = 'WE3FUSS'
                WINDOW   = 'FUSS'
                FUNCTION = 'APPEND'.
    ENDFORM.
    *--------------Unteroutinen für Positionsdruck -----------------------*
    FORM W3_LAGERMATERIAL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'WE3LGMAT'.
    ENDFORM.
    *       FORM W3_LVSMATERIAL                                           *
    FORM W3_LVSMATERIAL.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT = 'WE3LVSMAT'.
    ENDFORM.
    *       FORM W3_VERBRAUCHSMATERIAL                                    *
    FORM W3_VERBRAUCHSMATERIAL.
      CLEAR: AM07M-KONTIERUNG.
      AM07M-RSTYP = XPSTY.
      CASE XPSTY.
        WHEN XFERT.                        "Fertigungsauftrag
          IF X_KONT1 IS INITIAL.
            AM07M-KONTIERUNG = MSEG-AUFNR.
          ELSE.
            AM07M-KONTIERUNG = EKKN-AUFNR.
          ENDIF.
        WHEN XANLAGE.
          MOVE SPACE TO ANLAGE.
          IF X_KONT1 IS INITIAL.
            ANLAGE-ANLN1 = MSEG-ANLN1.
            ANLAGE-ANLN2 = MSEG-ANLN2.
          ELSE.
            ANLAGE-ANLN1 = EKKN-ANLN1.
            ANLAGE-ANLN2 = EKKN-ANLN2.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE ANLAGE NO-GAPS.
          AM07M-KONTIERUNG = ANLAGE.
        WHEN   XKDE.                     "Kundeneinzelbestand?
          MOVE SPACE TO KUNDE.
          IF X_KONT1 IS INITIAL.
            KUNDE-KDAUF = MSEG-KDAUF.
            KUNDE-KDPOS = MSEG-KDPOS.
          ELSE.
            KUNDE-KDAUF = EKKN-VBELN.
            KUNDE-KDPOS = EKKN-VBELP.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE KUNDE NO-GAPS.
          AM07M-KONTIERUNG = KUNDE.
        WHEN   XKDANR.                     "Kundenauftrag ?
          MOVE SPACE TO KUNDE.
          IF X_KONT1 IS INITIAL.
            KUNDE-KDAUF = MSEG-KDAUF.
            KUNDE-KDPOS = MSEG-KDPOS.
            KUNDE-KDEIN = MSEG-KDEIN.
          ELSE.
            KUNDE-KDAUF = EKKN-VBELN.
            KUNDE-KDPOS = EKKN-VBELP.
            KUNDE-KDEIN = EKKN-VETEN.
          ENDIF.
          MOVE SPACE TO AM07M-KONTIERUNG.
          CONDENSE KUNDE NO-GAPS.
          AM07M-KONTIERUNG = KUNDE.
        WHEN   XKOSTL.                     "auf Kostenstelle kontiert
          IF X_KONT1 IS INITIAL.
            AM07M-KONTIERUNG = MSEG-KOSTL.
          ELSE.
            AM07M-KONTIERUNG = EKKN-KOSTL.
          ENDIF.
        WHEN   XPROJN.                     "auf Projekt/Netzplan
          IF X_KONT1 IS INITIAL.
            IF MSEG-NPLNR IS INITIAL.
              PERFORM PSP_CONVERT USING MSEG-PS_PSP_PNR.
            ELSE.
              AM07M-KONTIERUNG = MSEG-NPLNR.
              PERFORM NW_VORGANG_LESEN USING MSEG-AUFPL MSEG-APLZL.
              IF NOT N_VORNR IS INITIAL.
                MOVE '/'     TO AM07M-KONTIERUNG+12.
                MOVE N_VORNR TO AM07M-KONTIERUNG+13.
              ENDIF.
            ENDIF.
          ELSE.
            IF EKKN-NPLNR IS INITIAL.
              PERFORM PSP_CONVERT USING EKKN-PS_PSP_PNR.
            ELSE.
              AM07M-KONTIERUNG = EKKN-NPLNR.
              PERFORM NW_VORGANG_LESEN USING EKKN-AUFPL EKKN-APLZL.
              IF NOT N_VORNR IS INITIAL.
      

  • How do we write the sub routines in smart forms?

    1) How do we write the sub routines in smart forms?
    2) What is the’ form interface’ in smart forms?
    3) Write down the path for writing for select queries in smart forms?
    4) How do we put dynamic page break in smart forms?
    5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
    6) What is the name of function module used to calling smart forms?
    1)     What is the functionality of function module ‘controal_form’?
    2)     How do we print the system date in this format ’15th Jan 2008’ on scripts?
    3)     What r the various print modes available in scripts?
    4)     What is the tcode for text element?
    5)     How do we draw horizontal line in scripts?
    6)     How can we suppress the leading zeros for a field in scripts?
    7)     In which system field is used to print current no page in scripts?
    Which f.m is used to reads text in sap scripts

    1) How do we write the sub routines in smart forms?
    after opening form see global definitions
    click on that there one tab called form routines inthat you can write subroutines logic.
    You can call in program lines .
    2) What is the’ form interface’ in smart forms?
    It is an interface between program and form .
    like function module we provide import,export,tables,exceptions
    Based on import and export parameters form will display for us.
    3) Write down the path for writing for select queries in smart forms?
    On window give right click in that command->programlines
    you can write all select  statements.
    4) How do we put dynamic page break in smart forms?
    you can define break point using break-point<>. syntax.
    5) in which system field contain the total page number of all forms in the currently processed print request in smart forms?
    SFSY-PAGE
    SFSY-JOBPAGES
    6) What is the name of function module used to calling smart forms?
    SSF_FUNCTION_MODULE_NAME
    =================
    1) What is the functionality of function module ‘control_form’?
    This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.
    CALL FUNCTION 'CONTROL_FORM'
    EXPORTING
      COMMAND    =
    EXCEPTIONS
      UNOPENED   = 1
      OTHERS        = 3
    IF SY-SUBRC NE 0.
    MESSAGE ...
    ENDIF.
    2) How do we print the system date in this format ’15th Jan 2008’ on scripts?
    Use SET DATE MASK to change format of date display.
    3) What r the various print modes available in scripts?
    4) What is the tcode for text element?
    se91
    5) How do we draw horizontal line in scripts?
    &ULINE&
    6) How can we suppress the leading zeros for a field in scripts?
    &it_vbak-vbeln(Z)&
    7) In which system field is used to print current no page in scripts?
    &SYST-PAGE& of &SYST-FORMPAGES&
    Which f.m is used to reads text in sap scripts
    READ_TEXT functiomodule.
    Reward points

  • Month view in smart form depending on date

    if the date is 01.01.08 I want it to display as 01 Jan 08..?and if is
    02.02.08 I want it as 02 Feb 08..
    How to resolve this in smart form field..?
    let me know..
    Thanks,

    Hi,
    You should write code in order to obtain this,
    If v_date is your date field.
    In the porgram logic you check for v_date+4(2)
    If g_date+4(2) = '01'.
    concatenate g_date6(2) 'JAN' g_date0(2) into g_date.
    elseif g_date_4(2) = '02'.
    concatenate g_date6(2) 'FEB' g_date0(2) into g_date.
    elseif...................
    then display g_date.
    Regards
    Madhu G S
    Reward Points if usefull

  • What is the diff b/w Sap Scripts and Smart Forms

    Hi,
          Whats the diff b/w SAP Scripts and Smart Forms..
             I need the internal explanation for both Smart Forms and SAP Scripts mean when we execute what happens whether Print Program r Forms starts execution 1st  and SIMILARLY FOR SMARTFORMS WHETHER FM'S  R FORMS.
    Thanks & Regards,
    Gopi.

    Hi
    Difference with SMARTFORMS vs. SapScript(SE71)
    The Following are the differences :-
    a) Multiple page formats are possible in smartforms which is not the case in SAPScripts
    b) It is possible to have a smartform without a main window .
    c) Labels cannot be created in smartforms.
    d) Routines can be written in smartforms tool.
    e) Smartforms generates a function module when activated.
    f) Unlike sapscripts (RSTXSCRP), you cannot upload/download Smartform to your local harddisk.
    It was said that it was provided in CRM 3.0 version, but not available in R/3. You can download smartforms into Local PC in a XML format. In the same way you can upload this XML format into Smartform. From the smartform editor itself you can call download option, if you are working in CRM 3.0 environment.
    In R3 also, you can download into XML format. However, it's not sure about uploading. Refer to the program 'SF_XSF_DEMO'.
    In 4.7 Enterprise, other have seen this utlity which is completey missing in 4.6c. There is functionality to downlaod a complete form or only a particular node. (Utilities -> Download form). It will create a XML file and save it in the hard disk.
    For others, if you want to download/upload the Smartforms source, you will need the help from the Basis people. What you can do is to create a Transport and then FTP down to your local harddisk. When you need the Smartform source in another system, you have FTP up the Smartforms file back to the SAP server. Finally, the Basis team, will tp it into your system.
    g) The protect and endprotect command in sapscript doesn't work with smartforms. For example on a invoice: First data of position no 80. is printed on page one, other data of position no 80 is printed on page 2. And there's nothing you can do about it. Actually, there is something you can do about it. By using a folder node and checking the 'protect' checkbox, everything in that folder will be page protected.
    check out this link:
    http://www.sap-img.com/smartforms/sap-smart-forms.htm
    Reward points if helpful.
    Regards,
    Swathi.

  • Need to convert a SAP Script to Smart Form

    Hello,
    I need to convert a SAP script to a Smart form.
    I am aware of converting it but have a question abt print program?
    Can the print program which is currently attached to the SAP script supprot the Smart form?
    Could some one let me know if i can use the same program or need to do some modifications in it?
    Pointa rewareded if useful.
    Thanks,
    Krishna

    hi
    t-code smartforms
    utilities->migrate sapscript
    check the link below it provides steps to convert sap scripts to smartforms
    http://www.ficoexpertonline.com/downloads/Iyer_SmartForms.pdf
    Check these threads.
    Smartforms -> sapscript
    Re: Convert SapScript to Smartforms ?
    regards.
    Kiran Sure

  • Text inversed in the smart form table

    Dear all,
    I'm new in ABAP and working on a smart form which has a cell in table shows an article description in both Arabic & English
    but the Arabic text appears in reversed sequence  in the print preview and after printing it shows like this ##### #########.
    any idea how to solve this problem
    thanks

    Hello,
    Please see the following SAP Note about printing Arabic:
    587150 - Support of Arabic-script languages
    For your Unicode system, then you should be able to print Arabic
    characters via device type ARSWIN or device type SWINCF.
    The Unicode cascading fonts solution with the device type SWINCF
    described in the following SAP Note:
       812821 - Cascading Font settings
    So you need to configure a Frontend output device that uses device type
    ARSWIN and use this to create the print with the Arabic characters.
    Regards,
    David

  • Service cannot be reached while sending a smart form in html format

    Hello,
    I'm trying to send a smart form as email in html format and I'm getting the following error message at the beginning of the message:
    Service cannot be reached
    What has happened?
    URL http://localhost/SAP/BC/BSP/SAP/SMART_FORMS/DEFAULT.CSS call was terminated because the corresponding service is not available.
    Note
    The termination occurred in system XD1 with error code 403 and for the reason Forbidden.
    The selected virtual host was 0 .
    What can I do?
    Please select a valid URL.
    If you do not yet have a user ID, contact your system administrator.
    Error code:ICF-NF-http-c:100-u:MYUSER-l:D-i:my_test_system:0-s:403-r:Forbidden
    HTTP 403 - Forbidden
    Your SAP Internet Communication Framework Team
    .SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#PAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#PAGE1-001.page #MAIN.win.AGGR-BILL div#B.par{ font-family : "Arial" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.AGGR-BILL div#F.par{ font-family : "Arial" ; font-size : 8pt ; font-weight : normal ; line-height : 3.39mm ; text-decoration : none ; text-align : left ; clear : both ;}.AGGR-BILL div#L.par{ font-family : "Arial" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.AGGR-BILL div#R.par{ font-family : "Arial" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : right ; clear : both ;}.AGGR-BILL a.AGGR-BILL span#H.char{ font-family : "Arial" ; font-size : 12pt ; font-weight : bold ;}.AGGR-BILL span#I.char{ font-family : "Arial" ; font-size : 12pt ; font-style : italic ;}.AGGR-BILL span#K.char{ font-family : "Arial" ; font-size : 8pt ;}.AGGR-BILL span#M.char{ font-family : "Arial" ; font-size : 10pt ;}.AGGR-BILL span#U.char{ font-family : "Arial" ; font-size : 12pt ; text-decoration : underline ;} div#PROJEKTE.tab@media screen { div#PROJEKTE.tab table.tr{ border-collapse : collapse ;}}@media print { div#PROJEKTE.tab table.tr{ border-collapse : collapse ;}}@media screen { div#PROJEKTE.tab table.tr{ margin-top : -1px ;}}@media print { div#PROJEKTE.tab table.tr{ margin-top : 0px ;}} div#PROJEKTE.tab table.tr div#PROJEKTE.tab .topline{ border-top : 1pt solid black ;} div#PROJEKTE.tab .bottomline{ border-bottom : 1pt solid black ;} div#PROJEKTE.tab .leftline{ border-left : 1pt solid black ;} div#PROJEKTE.tab .rightline{ border-right : 1pt solid black ;}#PROJEKTE.tab #sf--LTYPE1.tr td#C1
    and here comes the email's body: bla,bla,bla... bla.
    Do you have any idea how can I solve the problem with the css file? Any suggestion is welcome!
    Regards,
    Jaime

    I just solved the problem by activating the service  /SAP/BC/BSP/SAP/smart_forms/ through the transaction SICF. So I close the thread!
    Jaime

  • Use of NACE after creating print program n smart form

    Wat's d purpose of NACE?I hav created my own print program n smart form according to my own requirement.If NACE is necessary 4 my smart from.How can i use NACE i mean navigation steps.
    Please help me out.Its urgent.
    Thanks & Regards,
    Santhosh.

    Hi Santhosh,
    Nace is for message control settings. Say if u want to trigger a Smartform or an Idoc or any other customized program u can do the message control settings.
    Say at the time of Sales Order creation or updation u want to trigger a Smartform, then u have to follow the following steps:
    Goto NACE
    Select application V1 and then click Output Type.
    create a new Output type or copy the existing one abd save it with new name
    then in Processing Routine Mention the driver program name and in Form routine mention the main subroutine name.
    In Smartform mention your SMartform name and also the layout if u have ceated.
    Again go to NACE and Select application V1 and press Procedures.
    here out of the many procedures u have to select the right one and attach your Output Type to it.
    You can also create a condition record..Say if u want to trigger this Smartforms for Sales Order of particular type.
    Hope this helps.
    Reward Points if useful.
    Thanks.

Maybe you are looking for

  • Haven't been able to use MyKuler for months.

    Hi!  I used to really like using Kuler.  Then, a few months ago, something went haywire, and I was no longer able to use MyKuler at all.  I haven't been able to use it, since.  I use both the website AND the desktop application (and CS5.5 integration

  • How does account determination take place ??

    dear experts pls enlighten me on how excatly account determination take place . what is an account grping code what is transaction event key what is the technical name for keys used in OBYC like BSX , WRX GBB etc what is the other keys like VAX ,INV

  • OSX Lion, Lightroom 3 & deleted files: could be a bug?

    I've a library saved inside an external HD. Normally I work with this catalog, selecting the photos and elaborating the images. Last week I've made the upgrade from Snow Leopard to Lion and today I've found that if I try to delete an image, LR tell m

  • How to create a dimension that will reference another dimension

    Im creating a new cube without having a schema or DSV in place yet.  Starting from scratch.  In my OLTP database I have a table 'Orders' which contains various FK references to other tables, which in turn might reference two other tables. For example

  • AirPort card not installed and other odd behaviour

    Sorry for the long post, just want to provide all relevant info. I have a first gen intel mac book pro 15" that has been working fine from the day I got it (well except for the optical drive, but that's another story) and today it decided to start pl