cancel
Showing results for 
Search instead for 
Did you mean: 

PrintProgram for custom-made SAPScript_form

Former Member
0 Kudos

Hi,

[once again, excuse my double-posting; I suppose that no one's following the other thread anymore and I'm a bit short on time - of course, when I get an answer here, I will close the other thread.]

I have created my own custom-made SAPScript_form with just four windows, a simple example, just for a demonstration, as a PoC. I have written the PrintProgram for it using the sample code that was proposed to me by one of the supporters: http://saptechnical.com/Tutorials/SAPScripts/AddressPrinting/Page2.htm

I have adapted that example, using four SELECT statements (from the four tables involved), each one with two filters, one on cust_no and one on the invoice_date. And I have written four calls of the function WRITE_form since I have four windows (two of the windows hold information from two different tables). I have for now written four subroutines, WRITE_FORM_1 etc.

Now the PrintProgram runs, the correct records are selected and it does print - only without data, the printout shows only the layout, nearly the same I can do via se71 direct.

I will just post my code here. I'll continue trying myself, but I'm no expert and since SAPScript is quite old and writing SAPScript_forms is actually not the main task I have to tackle, I'd be grateful for any hints:

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

*& Report  ZFH_PRINT_BILLING_DOC                                       *

*&                                                                     *

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

*&                                                                     *

*&                                                                     *

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

REPORT  ZFH_PRINT_BILLING_DOC                   .

*************************************************************************************************

* Before we start with the actual code of the PP, we have to create a small internal table with

* the windows we have in our test_document. We will use that to LOOP through and call the

* function WRITE_FORM once for each window.

*************************************************************************************************

TYPES: BEGIN OF Win_line,

             WindowName TYPE C LENGTH 20,

       END   OF Win_line.

TYPES Win_type TYPE STANDARD TABLE OF Win_line.

DATA Win_tab TYPE Win_type.

DATA wa_Win TYPE Win_line.

* Now we can fill that (using fixed values, we know what windows we have)

wa_Win-Windowname = 'CUSTADDR'.

APPEND wa_Win TO Win_tab.

CLEAR wa_Win.

wa_Win-Windowname = 'OUR_ADDR'.

APPEND wa_Win TO Win_tab.

CLEAR wa_Win.

wa_Win-Windowname = 'HEADER'.

APPEND wa_Win TO Win_tab.

CLEAR wa_Win.

wa_Win-Windowname = 'MAIN'.

APPEND wa_Win TO Win_tab.

CLEAR wa_Win.

********************************************************************************************

**********************  BEGINNING OF THE ACTUAL PRINTPROGRAM-CODE  *************************

********************************************************************************************

TABLES:        "Here are the tables (or structures) that we use in this Program.

  KNA1, T001, VBRK, VBRP.

* Mind that the date has to be entered in German format: >> DD.MM.YYYY <<

SELECT-OPTIONS:              "This is like a From-To-parameter that the user can select to limit the datarange.

  s_custno FOR KNA1-KUNNR,   "The filter in this simple PrintProgram will be on the cust. nr.

  s_date   FOR VBRK-FKDAT.

* When doing the SELECT statements to actually get the data from the DB_tables used,

* we have to mind the order in which we address the tables so they can be properly

* linked (which is necessary so the filter can be applied):

* 1) VBRK must be first, we can join that with KNA1 to apply the filter.

* 2) KNA1 is the easiest part as we can implement the filter without need for a JOIN.

* 3) When we have VBRK, we can also do T001 and VBUK and implement a filter using a

*    JOIN with KNA1 via VBRK.

* 3) When we have VBUK, we can join the last table, VBRP (mind the filter)

* Internal table for VBRK

TYPES: BEGIN OF i_VBRK_line,

             ReNr TYPE VBRK-VBELN,

             ReDAT TYPE VBRK-FKDAT,

             Waer  TYPE VBRK-WAERK,

       END   OF i_VBRK_line.

TYPES i_VBRK_typ TYPE STANDARD TABLE OF i_VBRK_line.

DATA i_VBRK_tab TYPE i_VBRK_typ.

DATA i_VBRK TYPE i_VBRK_line.

SELECT

      VBRK~VBELN

      VBRK~FKDAT

      VBRK~WAERK

  FROM VBRK

   JOIN KNA1

     ON  VBRK~MANDT = KNA1~MANDT

     AND VBRK~KUNAG = KNA1~KUNNR

  INTO TABLE i_VBRK_tab

  WHERE KNA1~KUNNR IN s_custno

  AND   VBRK~FKDAT IN s_date.

* Internal table for KNA1

TYPES: BEGIN OF custno_line,

    KUNNR TYPE KNA1-KUNNR,

    ANRED TYPE KNA1-ANRED,

    TITEL TYPE KNA1-PSOTL,

    NAME1 TYPE KNA1-NAME1,

    NAME2 TYPE KNA1-NAME2,

    STRAS TYPE KNA1-STRAS,

    PSTLZ TYPE KNA1-PSTLZ,

    ORT   TYPE KNA1-ORT01,

    REGIO TYPE KNA1-REGIO,

    LAND  TYPE KNA1-LAND1,

  END OF custno_line.

TYPES custno_type TYPE STANDARD TABLE OF custno_line.

DATA cust_tab TYPE custno_type.

DATA wa_cust TYPE custno_line.

* Strictly, the fields don't have to be addressed as

* >KNA1~KUNNR< and so on, >KUNNR< would be enough if it

* is unique among the tables used in this program. It is

* just for reasons of completeness that we use it

* everywhere.

SELECT

      KNA1~KUNNR

      KNA1~ANRED

      KNA1~PSOTL

      KNA1~NAME1

      KNA1~NAME2

      KNA1~STRAS

      KNA1~PSTLZ

      KNA1~ORT01

      KNA1~REGIO

      KNA1~LAND1

        INTO TABLE cust_tab

        FROM KNA1

          JOIN VBRK

            ON  VBRK~MANDT = KNA1~MANDT

            AND VBRK~KUNAG = KNA1~KUNNR

        WHERE KNA1~KUNNR IN s_custno

        AND   VBRK~FKDAT IN s_date.

* Internal table for T001

TYPES: BEGIN OF T001_line,

             FIRMA TYPE T001-BUTXT,

             ORT   TYPE T001-ORT01,

             LAND  TYPE T001-LAND1,

             UstID TYPE T001-STCEG,

       END   OF T001_line.

TYPES T001_int_type TYPE STANDARD TABLE OF T001_line.

DATA T001_int TYPE T001_int_type.

DATA wa_T001_int TYPE T001_line.

SELECT

      T001~BUTXT      "We have to specify the table in this SELECT...

      T001~Ort01      "... because the field_name ORT01 is not unique...

      T001~LAND1      "... and neither is LAND1.

      T001~STCEG

   INTO TABLE T001_int

   FROM T001

     JOIN   VBRK

       ON   VBRK~MANDT = T001~MANDT

       AND  VBRK~BUKRS = T001~BUKRS

     JOIN KNA1

       ON   VBRK~MANDT = KNA1~MANDT

       AND  VBRK~KUNAG = KNA1~KUNNR

   WHERE KNA1~KUNNR IN s_custno

   AND   VBRK~FKDAT IN s_date.

* Internal table for VBUK

* Similar to the Designer-approach, we need VBUK to establish

* a link between VBRP and VBRK (and KNA1).

TYPES: BEGIN OF VBUK_int_line,

             ReNr TYPE VBUK-VBELN,

       END   OF VBUK_int_line.

TYPES VBUK_int_type TYPE STANDARD TABLE OF VBUK_int_line.

DATA VBUK_int_tab TYPE VBUK_int_type.

DATA wa_VBUK_int TYPE VBUK_int_line.

* It is not sure whether this SELECT is really necessary in the

* line to be able to link VBRK and VBRP.

SELECT

      VBUK~VBELN

    INTO TABLE VBUK_int_tab

    FROM VBUK

      JOIN  VBRK

        ON  VBRK~MANDT = VBUK~MANDT

        AND VBRK~VBELN = VBUK~VBELN

      JOIN KNA1

        ON   VBRK~MANDT = KNA1~MANDT

       AND  VBRK~KUNAG = KNA1~KUNNR

    WHERE KNA1~KUNNR IN s_custno

    AND   VBRK~FKDAT IN s_date.

* Internal table for VBRP

* This is where it gets most complex: We have to

* join VBRK to VBUK, on to VBRK, on to KNA1 to

* establish our filter.

TYPES: BEGIN OF VBRP_int_line,

             Pos   TYPE VBRP-POSNR,

             MATNR TYPE VBRP-MATNR,

             TEXT  TYPE VBRP-ARKTX,

             WERT  TYPE VBRP-NETWR,

       END   OF VBRP_int_line.

TYPES VBRP_int_type TYPE STANDARD TABLE OF VBRP_int_line.

DATA i_VBRP_tab TYPE VBRP_int_type.

DATA i_VBRP TYPE VBRP_int_line.

SELECT

      VBRP~POSNR

      VBRP~MATNR

      VBRP~ARKTX

      VBRP~NETWR

    INTO TABLE i_VBRP_tab

    FROM VBRP

     JOIN VBUK

      ON  VBRP~MANDT = VBUK~MANDT

      AND VBRP~VBELN = VBUK~VBELN

     JOIN  VBRK

        ON  VBRK~MANDT = VBUK~MANDT

        AND VBRK~VBELN = VBUK~VBELN

      JOIN KNA1

        ON   VBRK~MANDT = KNA1~MANDT

       AND  VBRK~KUNAG = KNA1~KUNNR

    WHERE KNA1~KUNNR IN s_custno

    AND   VBRK~FKDAT IN s_date.

* This is where the SAPScript_form is touched for the first time now that we have

* all the data in place.

PERFORM open_form.

* This is the actual core of the PrintProgram: The windowname is just a commentary

* here; It is used further down in the actual function call.

LOOP AT cust_tab INTO wa_cust.

  PERFORM write_form_1. "USING 'CUSTADDR'.

ENDLOOP.

LOOP AT T001_int INTO wa_T001_int.

  PERFORM write_form_2. "USING 'OUR_ADDR'.

ENDLOOP.

LOOP AT i_VBRK_tab INTO i_VBRK.

  PERFORM write_form_3.  "USING 'HEADER'

ENDLOOP.

LOOP AT i_VBRP_tab INTO i_VBRP.

  PERFORM write_form_4.  "USING 'MAIN'.

ENDLOOP.

PERFORM close_form.

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

*&      Form  OPEN_FORM

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

FORM open_form .

  CALL FUNCTION 'OPEN_FORM'

   EXPORTING

*   APPLICATION                       = 'TX'

*   ARCHIVE_INDEX                     =

*   ARCHIVE_PARAMS                    =

    DEVICE                            = 'PRINTER'

*   DIALOG                            = 'X'

    form                              = 'ZFH_TEST2_BILLIN'

    LANGUAGE                          = SY-LANGU

*   OPTIONS                           =

*   MAIL_SENDER                       =

*   MAIL_RECIPIENT                    =

*   MAIL_APPL_OBJECT                  =

*   RAW_DATA_INTERFACE                = '*'

*   SPONUMIV                          =

* IMPORTING

*   LANGUAGE                          =

*   NEW_ARCHIVE_PARAMS                =

*   RESULT                            =

* EXCEPTIONS

*   CANCELED                          = 1

*   DEVICE                            = 2

*   FORM                              = 3

*   OPTIONS                           = 4

*   UNCLOSED                          = 5

*   MAIL_OPTIONS                      = 6

*   ARCHIVE_ERROR                     = 7

*   INVALID_FAX_NUMBER                = 8

*   MORE_PARAMS_NEEDED_IN_BATCH       = 9

*   SPOOL_ERROR                       = 10

*   CODEPAGE                          = 11

*   OTHERS                            = 12

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.                               "FORM OPEN_FORM

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

*&      Form  WRITE_FORM_1

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

FORM write_form_1 .

  CALL FUNCTION 'WRITE_FORM'

   EXPORTING

*   element                        = 'ADDRESS'

*   FUNCTION                       = 'SET'

*   TYPE                           = 'BODY'

     window                         = 'CUSTADDR'

* IMPORTING

*   PENDING_LINES                  =

   EXCEPTIONS

     element                        = 1

     function                       = 2

     type                           = 3

     unopened                       = 4

     unstarted                      = 5

     window                         = 6

     bad_pageformat_for_print       = 7

     spool_error                    = 8

     codepage                       = 9

     OTHERS                         = 10

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.                               " If sy-subrc <> 0

ENDFORM.                               "FORM WRITE_FORM

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

*&      Form  WRITE_FORM_2

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

FORM write_form_2 .

  CALL FUNCTION 'WRITE_FORM'

   EXPORTING

*   element                        = 'ADDRESS'

*   FUNCTION                       = 'SET'

*   TYPE                           = 'BODY'

     window                         = 'OUR_ADDR'

* IMPORTING

*   PENDING_LINES                  =

   EXCEPTIONS

     element                        = 1

     function                       = 2

     type                           = 3

     unopened                       = 4

     unstarted                      = 5

     window                         = 6

     bad_pageformat_for_print       = 7

     spool_error                    = 8

     codepage                       = 9

     OTHERS                         = 10

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.                               " If sy-subrc <> 0

ENDFORM.                               "FORM WRITE_FORM

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

*&      Form  WRITE_FORM_3

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

FORM write_form_3 .

  CALL FUNCTION 'WRITE_FORM'

   EXPORTING

*   element                        = 'ADDRESS'

*   FUNCTION                       = 'SET'

*   TYPE                           = 'BODY'

     window                         = 'HEADER'

* IMPORTING

*   PENDING_LINES                  =

   EXCEPTIONS

     element                        = 1

     function                       = 2

     type                           = 3

     unopened                       = 4

     unstarted                      = 5

     window                         = 6

     bad_pageformat_for_print       = 7

     spool_error                    = 8

     codepage                       = 9

     OTHERS                         = 10

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.                               " If sy-subrc <> 0

ENDFORM.                               "FORM WRITE_FORM

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

*&      Form  WRITE_FORM_4

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

FORM write_form_4 .

  CALL FUNCTION 'WRITE_FORM'

   EXPORTING

*   element                        = 'ADDRESS'

*   FUNCTION                       = 'SET'

*   TYPE                           = 'BODY'

     window                         = 'MAIN'

* IMPORTING

*   PENDING_LINES                  =

   EXCEPTIONS

     element                        = 1

     function                       = 2

     type                           = 3

     unopened                       = 4

     unstarted                      = 5

     window                         = 6

     bad_pageformat_for_print       = 7

     spool_error                    = 8

     codepage                       = 9

     OTHERS                         = 10

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.                               " If sy-subrc <> 0

ENDFORM.                               "FORM WRITE_FORM

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

*&      Form CLOSE_FORM

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

FORM close_form .

  CALL FUNCTION 'CLOSE_FORM'

* IMPORTING

*   RESULT                         =

*   RDI_RESULT                     =

* TABLES

*   OTFDATA                        =

* EXCEPTIONS

*   UNOPENED                       = 1

*   BAD_PAGEFORMAT_FOR_PRINT       = 2

*   SEND_ERROR                     = 3

*   SPOOL_ERROR                    = 4

*   CODEPAGE                       = 5

*   OTHERS                         = 6

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.                               " If sy-subrc <> 0

ENDFORM.                               " FORM CLOSE_FORM

Thanks a lot!

Best regards,

Sapperdapper

<< Added Code Tags >>

Message was edited by: Kesavadas Thekkillath

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I have now narrowed down my filtering so I get only one record in each one of those four tables, so I don't have to bother with them all fitting each other.

In the example I have found, that >> /E << for >> element << is active in the function call. There is only one in the example, I have four and in the tutorial I followed to generate the form, all four necessary text_elements were listed, but only one had that - but I'll try anyway.

Best regards,

Sapperdapper

Former Member
0 Kudos

Hi,

I guess the error is rather in the form - or in the interplay between form and PrintProgram - than in the PrintProgram itself: That one runs error-free and it does select the correct data, only for some reason it is not connected. So I will post the layout of my form here, too.

SFORMZFH_TEST2_BILLIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
HFORMZFH_TEST2_BILLIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
OLANE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
HEADFORM  ZFH_TEST2_BILLINSAP                                               DEF EExample 2 Billing Doc                         ZFH_TEST2_BILLIN    00006F.HOFMANN   620 20121203141313F.HOFMANN   620 2012121111203813200015 E0                                                                                                                       800                                                                                                                                            
LINE/:FORM CPI 10; LPI 6; TAB-STOP 1 CM; START-PAGE FIRST; FORMAT DINA4 LANDSCAPE;                                                                                                                                                                                                                                                                                                                                                                                                                                       
LINE/:FORM PARAGRAPH DF; RDI; RDIDEV;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
LINE/:PARAGRAPH DF LINE-SPACE 1 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
LINE/:PARAGRAPH IT LINE-SPACE 1 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
LINE/:PARAGRAPH IT TAB 1 2 CH LEFT; TAB 2 15 CH LEFT; TAB 3 57 CH LEFT;                                                                                                                                                                                                                                                                                                                                                                                                                                                  
LINE/:STRING B FONT COURIER; FONT-SIZE 12; BOLD ON;                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
LINE/:WINDOW CUSTADDR TYPE VAR;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
LINE/:WINDOW HEADER TYPE VAR;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
LINE/:WINDOW MAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
LINE/:WINDOW OUR_ADDR TYPE VAR;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
LINE/:PAGE FIRST NEXT FIRST;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE/:PAGE FIRST MAIN 0 4.72 CH 20.08 LN 106.30 CH 19.84 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE/:PAGE FIRST WINDOW CUSTADDR 5 CH 3 LN 50 CH 6 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
LINE/:PAGE FIRST WINDOW HEADER 4.33 CH 14.41 LN 106.30 CH 2.36 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                       
LINE/:PAGE FIRST WINDOW OUR_ADDR 59.45 CH 2.83 LN 51.57 CH 5.91 LN;                                                                                                                                                                                                                                                                                                                                                                                                                                                      
END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
HEADFORM  ZFH_TEST2_BILLINSAP                                               TXT EExample 2 Billing Doc                         ZFH_TEST2_BILLIN    00006F.HOFMANN   620 20121203141313F.HOFMANN   620 2012121111203813200038 E0                                                                                                                       800                                                                                                                                            
LINE/:FORM TEXT 'Example 2 Billing Doc';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
LINE/:PARAGRAPH DF TEXT 'Default paragraph';                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE/:PARAGRAPH IT TEXT 'Item Paragraph';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
LINE/:STRING B TEXT 'Bold';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE/:WINDOW CUSTADDR TEXT 'Customer address';                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
LINE/:WINDOW HEADER TEXT 'Header window';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
LINE/:WINDOW MAIN TEXT 'Main Window';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
LINE/:WINDOW OUR_ADDR TEXT 'Our address';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
LINE/:PAGE FIRST TEXT 'first page';                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
LINE/WMAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
LINE/EITEM HEADER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
LINEIT,,<B> Material,, Description,, Net value,, Currency </>                                                                                                                                                                                                                                                                                                                                                                                                                                                            
LINE/EITEM LINE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
LINEIT,, &I_VBRP-MATNR&,, &I_VBRP-ARKTX&,, &I_VBRP-NETWR&,, &I_VBRK-WAERK&                                                                                                                                                                                                                                                                                                                                                                                                                                               
LINE/WCUSTADDR                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
LINE* <B> Your cust. nr. : </> &KNA1-KUNNR&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE/ <B> Salutation : </> &KNA1-ANRED&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE/ <B> Title      : </> &KNA1-PSOTL&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Customer   : </> &KNA1-NAME1&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Customer   : </> &KNA1-NAME2&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Street     : </> &KNA1-STRAS&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Postal code: </> &KNA1-PSTLZ&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> City       : </> &KNA1-ORT01&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Region     : </> &KNA1-REGIO&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE* <B> Country    : </> &KNA1-LAND1&                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
LINE/WOUR_ADDR                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
LINE* <B> Company : </> &T001-BUTXT&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
LINE* <B> City: </> &T001-ORT01&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
LINE* <B> Country : </> &T001-LAND1&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
LINE* <B> VAT_ID  : </> &T001-STCEG&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
LINE/WHEADER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE/*------------------------------------------------------------------------                                                                                                                                                                                                                                                                                                                                                                                                                                           
LINE/*This is a Header line - Three lines in the Editor                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
LINE/*------------------------------------------------------------------------                                                                                                                                                                                                                                                                                                                                                                                                                                           
LINE* <B> Invoice nr.   : </> &i_vbrk-vbeln&                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE* <B> Invoice item  : </> &i_vbrp-posnr&                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE* <B> Invoice date  : </> &i_vbrk-fkdat&                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
LINE* <B> Printed on: </> &sy-datum&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
ACTVSAP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
E                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

I hope that is okay - attaching the file is not possible, the content is blocked - because of the tags, I guess?

Thanks a lot!

Best regards,

Sapperdapper

Former Member
0 Kudos

Hi,

I have edited the PrintProgram a little bit so that the SELECT from VBRK now includes the field POSNR from VBRP and the SELECT from VBRP includes the field WAERK from VBRK. So now the table VBRK_int holds all the info necessary for the HEADER window and the table VBRP_int holds all the info necessary for the MAIN window.

It still does not print any data.

Best regards,

Sapperdapper

P.S.: It seems that function WRITE FORM can only be called once? The first window - the customer_address - is printed all right. The second (company_address) and third (header_line) windows are not printed at all (no data anyway) and of the fourth window (main, line_item data from VBRP), only the leftmost field (MATNR) is output, the rest is blank.

I'm running out of ideas about what I could have been doing wrong now.

P.P.S.: I seem to be getting closer - now I get the complete contents of the first window (well, not quite, I guess I have made the window too small in the form to contain all the info I want there), parts of the second window and 3/4 of the infos in the MAIN window - the third window is still blank although the info is in the tables.

Former Member
0 Kudos

Hi,

I'm nearly there now - but only nearly:

- The first window (cust_address) is now being filled properly, all the info is there. I'd like to dynamize
  the field >KNA1-NAME2< so that it is only output when there is anything in that field, but I can do
  with that.

- The second window (comp_data) is also properly filled.

- The third window (header_data) consists of two fields from VBRK and one from VBRP, those from
  VBRK are printed, the one from VBRP is not.

- The fourth window (item data) consists of three fields from VBRP and one from VBRK. The linking is
  done in exactly the same way, this time all four fields are printed!? Only the lines are a bit askew, the
  third value is beneath the header for the fourth and the fourth value is to the right of the header_line
  altogether.

Best regards,

Sapperdapper

Former Member
0 Kudos

Hi,

I've made it - at least data-wise: All the data that is in the DB_tables used is now displayed in the form.

The only remaining issue which I cannot seem to get to grips with is the formatting:

- In the MAIN window, there is supposed to be a header_line with four header_texts and underneath
  that, there is one (or potentially more, but for now just one) item_line with four items which are
  supposed to go directly underneath the headers ... supposed to, yeah...

That is precisely what I cannot get quite right: How do I insert, like, a TAB in a text_element? The element that is in the tutorial I have followed is the >>,, << - two commas followed by a BLANK - but that does not appear to work, or I don't know how to use it properly.

Can anybody assist me in that last step?

Thanks a lot!

Best regards,

Sapperdapper

che_eky
Active Contributor
0 Kudos

Define the TAB stops and there offsets/positions in the actual Paragraph format. Use that paragraph format when printing the text and the >>,,<<  should then get picked up.

Former Member
0 Kudos

Hi Che,

I have by now made it, 'simply' using BLANKs like in the good old days of DOS operating systems... Your solution actually sounds not much easier than that. Really, it is a long time since I have seen an interface as uncomfortable as that SAPScript_forms stuff...
However, it is solved for now.

Unfortunately I have realized in the process that the names of the DB_tables used need not necessarily be in the layout, though it would be good practice to name e.g. an internal table with KNA1-information something like KNA1 - it is not necessary though...

Well, that is something to think of going forward.

Best regards,

Sapperdapper

che_eky
Active Contributor
0 Kudos

Friedrich Hofmann wrote:

I have by now made it, 'simply' using BLANKs like in the good old days of DOS operating systems... Your solution actually sounds not much easier than that.

It is the best solution as opposed to using blanks. When you have headings, followed by items, then sub totals, totals, etc and all columns need to line up then Tab stops are best. Imagine all the blanks you would have to repeat for each line type. Also if you then have to change the width of a column or add or remove columns it is much easier to change a single Tab stop than have to remove or add blanks all over the place.

In your case a few blanks probably did the job for now.

Former Member
0 Kudos

Hi Che,

you're right. "A few" BLANKs did the job for now - but I'd like to select a different record - I filter for only one single record so I get only one document and no trouble - where every field is filled in our IDES system so I really get all the information I have built into the form. Maybe, however, I'll rather do that by editing a table; Fudging around with the existing SAPScript_forms is not my actual task, after all. I might need one for comparison again going forward and then I'll try to not make my life with that harder than need be, but not right now.

Thanks for the hint anyway! I guess I'll use it eventually.

Best regards,

Sapperdapper

P.S.: Very strange - I cannot edit my own form! I can view everything all right, the windows and their individual position and size, paragraph formats and all - but I cannot change it... Ah, I can only edit anything in the original language 😉

P.P.S.: Hmm... it doesn't work yet - when I define the Tabstops for that paragraph_format as 5, 10 and 15 and then replace all the BLANKs I have inserted by just >>,, << - all my items are askew again...

Former Member
0 Kudos

Hi,

this is done. I have completed the PrintProgram and my own method of getting the data. However, it did not do the job of proving the capabilities of this method and my own. I have to use one of the "standard" SAPScript_forms - not that mine did not go with the SAP standard - one of the ones we have in the system. So now I'm off to find one that my program will work on till Thursday.

Thanks for helping!

Best regards,

Sapperdapper