sap notebook

233
SAP NOTEBOOK - ABAP INTERVIEW QUESTIONS ANSWERS TIPS Hybris and SAP Hybris is a e-commerce product which is now a part of SAP after SAP's acquisition. Hybris' strong suit is supporting business-to-business (B2B) commerce, but it also supports business-to-consumer (B2C) commerce, product content management and order management. B2B customers include the likes of industrial products supplier Granger while coffee equipment maker Nespresso and camera manufacturer Nikon use Hybris for both B2B and B2C commerce. Hybris' core architecture provides a master data-management layer said to ensure consistent inventory, pricing, order-status and other information across channels, whether that's Web, mobile, call center or retail stores. There's also a process-management layer that applies the same business rules across channels, so prices and promotions encountered online are consistent with those encountered in stores or on mobile devices. With the Hybris acquisition completed, Sheldon says the enterprise commerce technology landscape is now "dominated by four large software companies: SAP, IBM, Oracle and eBay." IBM and Oracle are clearly SAP's chief rivals, and they've both spent billions on acquisitions in the commerce and customer

Upload: gobara-dhan

Post on 28-Dec-2015

111 views

Category:

Documents


1 download

DESCRIPTION

SAP

TRANSCRIPT

Page 1: Sap Notebook

SAP NOTEBOOK - ABAP

INTERVIEW QUESTIONS

ANSWERS TIPS

Hybris and SAP

Hybris is a e-commerce product which is now a part of SAP after SAP's acquisition. 

Hybris' strong suit is supporting business-to-business (B2B) commerce, but it also supports

business-to-consumer (B2C) commerce, product content management and order

management. B2B customers include the likes of industrial products supplier Granger

while coffee equipment maker Nespresso and camera manufacturer Nikon use Hybris for

both B2B and B2C commerce.

Hybris' core architecture provides a master data-management layer said to ensure

consistent inventory, pricing, order-status and other information across channels, whether

that's Web, mobile, call center or retail stores. There's also a process-management layer

that applies the same business rules across channels, so prices and promotions

encountered online are consistent with those encountered in stores or on mobile devices.

 With the Hybris acquisition completed, Sheldon says the enterprise commerce technology

landscape is now "dominated by four large software companies: SAP, IBM, Oracle and

eBay."

IBM and Oracle are clearly SAP's chief rivals, and they've both spent billions on

acquisitions in the commerce and customer experience arena. The most directly

competitive products to Hybris at IBM are Unica and Sterling Commerce, while Oracle has

ATG and commerce-oriented bits and pieces of BEA, E-Business Suite, FatWire, Stellent

and Eloqua.

Page 2: Sap Notebook

Looking for Unlimited very long input text entry field in SAP ABAP programming?

Method1: Simple: Function module for Popup

Use the function module CATSXT_SIMPLE_TEXT_EDITOR.

Just give a title for the function module and execute to give a POP UP and free text field.The resulting ITAB will give you the text lines.

Method2: Medium : OOPS method for Free text editor

DATA editor_container TYPE REF TO cl_gui_custom_container.

create object editor_container

exporting

      container_name = 'Container100'

exceptions

     cntl_error = 1

     cntl_system_error = 2

     create_error = 3

      lifetime_error = 4

      lifetime_dynpro_dynpro_link = 5.

b) Created a reference to your Text Edit Control and create it's object :

DATA text_editor TYPE REF TO cl_gui_textedit.

create object text_editor

exporting

    parent = editor_container

    wordwrap_mode =  cl_gui_textedit=>wordwrap_at_fixed_position

    wordwrap_position = line_length

    wordwrap_to_linebreak_mode = cl_gui_textedit=>true. "or simply = false

c)Hide toolbar and statusbar

call method text_editor ->set_toolbar_mode

exporting

     toolbar_mode = cl_gui_textedit=>false.

call method text_editor->set_statusbar_mode

exporting

        statusbar_mode = cl_gui_textedit=>false.

d) Answering your question Text Edit Control --> Database Table

call method text_editor->get_text_as_stream

exporting

    only_when_modified = cl_gui_textedit=>false

importing

     text               = wrk_text

exceptions

     others             = 1.

Save wrk_text to Table

Page 3: Sap Notebook

e) Text Edit Control <-- database="" table="" u="">

The reverse process of Step 4

With method :

CALL METHOD text_editor->set_text_as_stream

......

How to Clear the OOPS Free text:This is how I get rid of the existing text:

* Delete the Text

  me->o_editor->delete_text( ).

* Set the new text

  me->o_editor->set_textstream( EXPORTING text = iv_text ).

Set the Free text object editable and Disabled mode by using the below method.

IF condition.....

    CALL METHOD G_FREETEXT_1->SET_READONLY_MODE

        EXPORTING

          READONLY_MODE          = '1'

        EXCEPTIONS

          ERROR_CNTL_CALL_METHOD = 1

          INVALID_PARAMETER      = 2

          OTHERS                 = 3.

      IF SY-SUBRC  0.

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

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

      ENDIF.

else.

     CALL METHOD G_FREETEXT_1->SET_READONLY_MODE

        EXPORTING

          READONLY_MODE          = CL_GUI_TEXTEDIT=>FALSE

        EXCEPTIONS

          ERROR_CNTL_CALL_METHOD = 1

          INVALID_PARAMETER      = 2

          OTHERS                 = 3.

      IF SY-SUBRC  0.

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

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

      ENDIF.

endif.

Page 4: Sap Notebook

Editable ALV event trigger without pressing enter key

Making ALV to react to Change data automatically

LINK: http://wiki.scn.sap.com/wiki/display/ABAP/Making+ALV+to+react+to+Change+data+automatically

Scenario:

To make ALV to react to data change automatically without any need for the user to click on ENTER or any

other button/menu item.

Procedure:

In order to make the system react to an edit event, we need to first register the edit event.  

To register the edit event, call the method REGISTER_EDIT_EVENT

CALL METHOD cont_editalvgd -> register_edit_event

    Exporting

            {}I_event_id = cl_gui_alv_grid => mc_evt_modified.

When user press 'ENTER' the event MC_EVT_ENTER is triggered which automatically sets the variable

M_cell_edit to 'X'.

But if the user bypasses the enter key then the variable M_CELL_EDIT has to be set explicitly which is done by

passing mc_evt_modified to the exporting parameter I_EVENT_ID instead ofmc_evt_enter.

In the PAI event, call the method CHECK_CHANGED_DATA. This method automatically triggers

the data_changed event.

By default, SAP recognizes 'ENTER' event.  When only the CHECK_CHANGED_DATA is called in PAI event,

then the 'ENTER' event is not recognized by the system.  In order to have both the events recognized by the

system, we need to register the edit event.

Sample code:

REPORT  Z_ALV_EDIT_EVENT.*"Table declarations...................................................TABLES: SPFLI.                               " Flight Schedule Details*" Data declarations...................................................*"--------------------------------------------------------------------** Work variables                                                      **"--------------------------------------------------------------------*DATA: W_GRID TYPE REF TO CL_GUI_ALV_GRID,  " Reference object for alv grid W_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER." Reference object for container*"--------------------------------------------------------------------** Structure to hold Flight Schedule details                           **"--------------------------------------------------------------------*DATA: FS_SPFLI TYPE SPFLI.*"--------------------------------------------------------------------** Structure to hold Field Catalog details                             **"--------------------------------------------------------------------*DATA: WA_FIELD_CATALOG TYPE LVC_S_FCAT.*"--------------------------------------------------------------------** Structure to hold Layout of the ALV Report                          *

Page 5: Sap Notebook

*"--------------------------------------------------------------------*DATA: WA_LAYOUT TYPE LVC_S_LAYO.*"--------------------------------------------------------------------** Internal table to hold Flight Schedule details from table SPFLI     **"--------------------------------------------------------------------*DATA: T_SPFLI LIKESTANDARD TABLE      OF FS_SPFLI.*"--------------------------------------------------------------------** Internal table to hold Field Catalog Details                        **"--------------------------------------------------------------------*DATA: T_FIELD_CATALOG TYPE  LVC_T_FCAT.*"--------------------------------------------------------------------**                       START-OF-SELECTION EVENT                      **"--------------------------------------------------------------------*START-OF-SELECTION.* Data retrieval from the database table SELECT * FROM SPFLI INTO TABLE T_SPFLI. CALL SCREEN 100.*&amp;---------------------------------------------------------------------**&amp;      Module  set_layout  OUTPUT*&amp;---------------------------------------------------------------------**   This module is used to set the layout for the alv grid display     **----------------------------------------------------------------------*MODULE SET_LAYOUT OUTPUT. WA_LAYOUT-GRID_TITLE = 'SPFLI TABLE DETAILS'. WA_LAYOUT-ZEBRA = 'X'. WA_LAYOUT-EDIT = 'X'.ENDMODULE.                             " set_layout  OUTPUT*&amp;---------------------------------------------------------------------**&amp;      Module  field_catalog  OUTPUT*&amp;---------------------------------------------------------------------**   This module is used to populate the field catalog                  **----------------------------------------------------------------------*MODULE FIELD_CATALOG OUTPUT. CLEAR WA_FIELD_CATALOG. WA_FIELD_CATALOG-FIELDNAME = 'CARRID'. WA_FIELD_CATALOG-REF_FIELD = 'CARRIDS'. WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'. WA_FIELD_CATALOG-COL_POS   = 1. APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG. CLEAR WA_FIELD_CATALOG. WA_FIELD_CATALOG-FIELDNAME = 'CONNID'. WA_FIELD_CATALOG-REF_FIELD = 'CONNID'. WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'. WA_FIELD_CATALOG-COL_POS   = 2. APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG. CLEAR WA_FIELD_CATALOG. WA_FIELD_CATALOG-FIELDNAME = 'CITYFROM'. WA_FIELD_CATALOG-REF_FIELD = 'CITYFROM'. WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'. WA_FIELD_CATALOG-COL_POS   = 3. APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.

Page 6: Sap Notebook

 CLEAR WA_FIELD_CATALOG. WA_FIELD_CATALOG-FIELDNAME = 'CITYTO'. WA_FIELD_CATALOG-REF_FIELD = 'CITYTO'. WA_FIELD_CATALOG-REF_TABLE = 'SPFLI'. WA_FIELD_CATALOG-COL_POS   = 4. APPEND WA_FIELD_CATALOG TO T_FIELD_CATALOG.ENDMODULE.                             " field_catalog  OUTPUT*&---------------------------------------------------------------------**&      Module  USER_COMMAND_0100  INPUT*&---------------------------------------------------------------------*  This module is used to handle the PAI events*----------------------------------------------------------------------*MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM.   WHEN 'OK'.* Calling the check_changed_data method to trigger the data_changed* event

     CALL METHOD W_GRID->CHECK_CHANGED_DATA  IMPORTING    E_VALID   =  CHANGING    C_REFRESH = 'X'         .     UPDATE SPFLI FROM TABLE T_SPFLI.   WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.     LEAVE TO SCREEN 0. ENDCASE.                             " CASE SY-UCOMMENDMODULE.                             " USER_COMMAND_0100  INPUT*&---------------------------------------------------------------------**&      Module  manage_alv_grid  OUTPUT*&---------------------------------------------------------------------*   This module is used to manage the Grid display*----------------------------------------------------------------------*MODULE MANAGE_ALV_GRID OUTPUT. IF W_GRID IS INITIAL.   CREATE OBJECT W_CONTAINER     EXPORTING       CONTAINER_NAME              =   'CONTAINER1'     EXCEPTIONS       CNTL_ERROR                  = 1       CNTL_SYSTEM_ERROR           = 2       CREATE_ERROR                = 3       LIFETIME_ERROR              = 4       LIFETIME_DYNPRO_DYNPRO_LINK = 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 NE 0   CREATE OBJECT W_GRID     EXPORTING       I_PARENT          =  W_CONTAINER     EXCEPTIONS       ERROR_CNTL_CREATE = 1       ERROR_CNTL_INIT   = 2

Page 7: Sap Notebook

       ERROR_CNTL_LINK   = 3       ERROR_DP_CREATE   = 4       OTHERS            = 5.   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 NE 0   CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY     EXPORTING       I_STRUCTURE_NAME              = 'SPFLI'       IS_LAYOUT                     = WA_LAYOUT     CHANGING       IT_OUTTAB                     = T_SPFLI[]       IT_FIELDCATALOG               = T_FIELD_CATALOG     EXCEPTIONS       INVALID_PARAMETER_COMBINATION = 1       PROGRAM_ERROR                 = 2       TOO_MANY_LINES                = 3       OTHERS                        = 4.   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 NE 0 ENDIF.                               " IF W_GRID IS INITIAL  Registering the EDIT Event CALL METHOD W_GRID->REGISTER_EDIT_EVENT   EXPORTING     I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED   EXCEPTIONS     ERROR      = 1     OTHERS     = 2. 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 NE 0ENDMODULE.                             " manage_alv_grid  OUTPUT*&---------------------------------------------------------------------**&      Module  STATUS_0100  OUTPUT*&---------------------------------------------------------------------*   This module is used to set the PF-Status and title bar             **----------------------------------------------------------------------*MODULE STATUS_0100 OUTPUT. SET PF-STATUS 'ALVS_GUI'. SET TITLEBAR 'ALV_TITLE'.ENDMODULE.                             " STATUS_0100  OUTPUT

Page 8: Sap Notebook

Parallel Cursor - Simple

Improving performance in Nested loop scenario's:How ? Instead of sequential search in each loops, we will use Read table of ITAB2 and get the SY-TABIX of that second ITAB.

Now if sy-Subrc = 0 then proceed the loop into second ITAB and use the syntax LOOP AT ITAB2 INTO WA FROM w_TABIX.

Use if conditions inside the loop to check the keys thereafter.

sort: lt_vbpa by kunnr, "Sorting by key is very important lt_kna1 by kunnr. "Same key which is used for where condition is used hereloop at lt_vbpa into wa_vbpa. read lt_kna1 into wa_kna1 " This sets the sy-tabix with key kunnr = wa_vbpa-kunnr binary search. if sy-subrc = 0. "Does not enter the inner loop v_kna1_index = sy-tabix. loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop exit. endif.

****** Your Actual logic within inner loop ******

endloop. "KNA1 Loop endif.endloop. " VBPA Loop

Background Job scheduling - Interview Question

SM36 -DEFINE BACKGROUND JOB - Create background Jobs

Page 9: Sap Notebook

SM37 : SIMPLE JOB SELECTION - To check status ( maintenance )

Great interview preparation and knowledge making http://saplab.blogspot.com/2007/09/difference-with-smartforms-vs.html

Page 10: Sap Notebook

http://learnabap.blogspot.com/2007/05/performance-tuning-using-parallel.html

Smartform Interview questions Found in this site: http://saplab.blogspot.com/2007/09/smart-forms-frequently-asked-questions.html

Smart forms Frequently Asked Questions

Forcing a page break within table loop

Create a loop around the table. Put a Command node before the table in the loop that forces a NEWPAGE on whatever condition you want. Then only loop through a subset of the internal table (based on the conditions in the Command node) of the elements in the Table node.

Font style and Font size

Goto Transaction SMARTSTYLES.There you can create Paragraph formats etc just like in sapscript.

Then in your window under OUTPUT OPTIONS you include this SMARTSTYLE and use the Paragraph and character formats.

Line in Smartform

Either you can use a window that takes up the width of your page and only has a height of 1 mm.

Then you put a frame around it (in window output options).Thus you have drawn a box but it looks like a line.

Or you can just draw "__" accross the page and play with the fonts so that it joins each UNDER_SCORE.

Difference between 'form interface' and 'global definitions' in global settings of smart forms

The Difference is as follows.

To put it very simply:

Form Interface is where you declare what must be passed in and out of the smartform (in from the print program to the smartform and out from the smartform to the print program).

Global defs. is where you declare data to be used within the smartform on a global scope.ie: anything you declare here can be used in any other node in the form.

Page 11: Sap Notebook

Smartforms function module name

Once you have activated the smartform, go to the environment -> function module name. There you can get the name of funtion module name.

The key thing is the program that calls it. for instance, the invoice SMARTFORM LB_BIL_INVOICE is ran by the program RLB_INVOICE.

This program uses another FM to determine the name of the FM to use itself. The key thing is that when it calls this FM (using a variable to store the actual name), that the parameters match the paramters in your smartform.

Another thing to note is that the FM name will change wherever the SF is transported to.

So you need to use the FM to determine the name of the SF.

Here is the code that can be use to determine the internal name of the function module:

Code:

if sf_label(1) <> '/'. " need to resolve by namemove sf_label to externalname.call function 'SSF_FUNCTION_MODULE_NAME'exportingformname = externalnameimportingfm_name = internalnameexceptionsno_form = 1no_function_module = 2others = 3.if sy-subrc <> 0.message 'e427'.endif.move internalname to sf_label.endif.

It checks to see if the sf_label starts with a '/', which is how the internal names start. if it does, the name has already been converted. If not, it calls the FM and converts the name.

You would then CALL FUNCTION sf_label.

Smartforms FAQ Part Two

Smartforms output differenceProblem with Smartforms: in a certain form for two differently configured printers, there seem to be a difference in the output of characters per inch (the distance between characters which gives a layout problem - text in two lines instead of one.

It happens when the two printers having different Printer Controls' if you go to SPAD Menu (Spool Administrator Menu) you can see the difference in the Printer Control and if you make the Printer control setting for both the printers as same. then it will be ok. and also u have to check what is the device type used for both the output devices.

SmartForms Output to PDFThere is a way to download smartform in PDF format.Please do the following:1. Print the smartform to the spool.

Page 12: Sap Notebook

2. Note the spool number.3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering thenoted spool number.

SmartForm Double sided printing question Your customer wants your PO Smart Form to be able to print "Terms and Conditions" on the back side of each page. They don't want to purchase pre-printed forms with the company's logo on the front and terms & conditions on the back. Now this presents an interesting problem. Has anyone else ever had a request like this? If for example there was a 3 page PO to be printed, they want 3 pieces of paper, the front side of each to containe the PO information (page 1, 2, and 3) and the back side of each piece of paper to containg the static "Terms & Conditions" information. Anyone have a clue how to force this out?

Easy - page FRONT lists page CONTACTS as next page and CONTACTS lists FRONT as next page. Since CONTACTS does not contain a MAIN window, it will print the contacts info and then continue on to FRONT for the rest of the main items. Additionally, set print mode on FRONT to D (duplex) and set CONTACTS to 'blank' (for both resource name and print mode - this is the only way to get to the back of the page).

Transport Smart Forms

How does one transport SMARTFORM? SE01? How do you make sure that both, the SMARTFORM & it's function module gets transported? Or does the FM with same name gets generated automatically in the transported client?

A smartform is transported no differently than any other object. if it is assigned to a development class that is atteched to a transport layer, it will be transported.The definition is transported, and when called, the function module is regenerated.This leads to an interetsing situation. On the new machine, it is very likely the function module name will be different than the name on the source system. Make sure, before you call the function module, you resolve the external name to the internal name using the 'SSF_FUNCTION_MODULE_NAME' function module.Typically, generate the SF, then use the pattern to being in the interface. Then change the call function to use the name you get back from the above function module.

Smartforms: protect lines in main window.

How to protect lines in the main window from splitting between pages?

It was easy with SAPscript, but how to do it with SF's. For 4.7 version if you are using tables, there are two options for protection against line break:- You can protect a line type against page break.- You can protect several table lines against page break for output in the main area.

Protection against page break for line types- Double-click on your table node and choose the Table tab page.

Page 13: Sap Notebook

- Switch to the detail view by choosing the Details pushbutton.- Set the Protection against page break checkbox in the table for the relevant line type. Table lines that use this line type are output on one page.

Protection against page break for several table lines- Expand the main area of your table node in the navigation tree.- Insert a file node for the table lines to be protected in the main area.- If you have already created table lines in the main area, you can put the lines that you want to protect again page break under the file using Drag&Drop. Otherwise, create the table lines as subnodes of the file.- Choose the Output Options tab page of the file node and set the Page Protection option. All table lines that are in the file with the Page Protection option set are output on one page.

In 4.6, Alternatively in a paragraph format use the Page protection attribute to determine whether or not to display a paragraph completely on one page. Mark it if you want to avoid that a paragraph is split up by a page break. If on the current page (only in the main window) there is not enough space left for the paragraph, the entire paragraph appears on the next page.

Error handling: Conversion of Char to number exception

If you get this errorUnable to interpret "1,300 " as a number.Runtime error : CONVT_NO_NUMBER

then use the below solution

  data: i type i. data: c(10) type c.data: p(10) type p decimals 2.

c = '3.520,00'.

catch system-exceptions convt_no_number = 1. p = c.endcatch.

if sy-subrc = 1. clear sy-subrc.  while sy-subrc = 0. replace ',' with space into c. endwhile. clear sy-subrc.  while sy-subrc = 0. replace '.' with space into c. endwhile. condense c no-gaps.endif.  

Page 15: Sap Notebook

Message class Object Locked

This happens when someone saves a single message inside their own development TR and not an independent exclusive Message class TR.

To solve it, goto SE03 -> give MESS -> Give the class name and star as shown in the screenshot and dont forget to select the modifiable status and remove released status.

Now execute. It will give you the requests holding the single messages. Remove them from the development request and create/ use the exclusive message class request.

Page 16: Sap Notebook

Real time issues

1. How to change the package of a program.

                  Goto -> Object Directory Entry.

Real Time Standard Reports Used in SAP

The following is the list of Standard reports used in sap.

2. VA05 - List of Sales Orders3. VA25 - List of Quotations4. VA15 - List of Inquiries5. VF04 - Billing Due List6. V.14 - Sales Orders / Contracts Blocked for delivery7. V.15 - Backorders8. VL04 - Sales Order / Purchase orders worklist9. VF05 - General Delivery List - Outbound deliveries10. VL06O -11. VL06F -

BAPI's Used

BAPI_GOODSMVT_CREATE:

call function 'BAPI_GOODSMVT_CREATE'exporting          goodsmvt_header  = gwa_goodsmvt_header          goodsmvt_code    = gwa_goodsmvt_code          testrun          = g_testrunimporting          materialdocument = g_mblnrtables          goodsmvt_item    = git_goodsmvt          return           = git_return.

BAPI_BATCH_CREATE:

call function 'BAPI_BATCH_CREATE'exporting          material           = gwa_pourcast-matnr          batch              = gwa_pourcast-charg          plant              = mchb-werks

Page 17: Sap Notebook

          batchattributes    = lwa_batchatt          batchcontrolfields = lwa_batchattrtables          return             = git_rettab.

BAPI_TRANSACTION_COMMIT:call function 'BAPI_TRANSACTION_COMMIT'exporting      wait = 'X'.

BAPI_TRANSACTION_ROLLBACK:call function 'BAPI_TRANSACTION_ROLLBACK'.

BAPI_ROUTING_CREATE:

call function 'BAPI_ROUTING_CREATE'exporting       testrun                      = g_testrun       bomusage                     = '1'       application                  = 'PP01'importing       group                        = g_group       groupcounter                 = g_groupcountertables

       task                         = git_task"HEADER - TASK_LIST_GROUP, GROUP_COUNTER, "VALID_FROM ,TAS, PLAN, TAS, TAS, TAS(EMPTY), "LOT_SIZE_FROM, LOT SIZE TO, DESCR

       materialtaskallocation       = git_materialtaskallocation"HEADER -MATERIAL, PLAN, "VALID_FROM

       operation                    = git_operation"ITEMS - VALID_FROM, ACTI, CONTROL KEY, "WORK_CNT, PLANT, DESCRIPTION, DENOMI, NOMINA, "BASE_QUANTITY, STDUNIT(KG), STD_VALUE-->UPTO 6 "MAX

*          componentallocation          = git_componentallocation"VALID_FROM, ACTIVITY, "BOM_TYPE, BOM_NO, ALTERNATIVE_BOM, ITEM_ID, ITEM_NO, PLANT, MATERIAL,

       productionresource           = git_productionresource "VALID_FROM, ACTIVITY, ITEM_NO_OF_PROD, CTRL_KEY, PRT_USAGE_VALUE_UNIT, STD_USAGE_VALUE_FOR_PRT, "FORMULA_TOT_USAGE, PRT_CATEGORY, PRT_PLANT, EQUIPMENT

       inspcharacteristic           = git_inspcharacteristic "ACTIVITY, VALID_FROM, MSTR_CHAR, PMSTR_CHAR, CHA_MASTER_IMPORT_MODUS, TARGET_VAL, UP_TOL_MLT, "LW_TOL_LMT,*          TEXTALLOCATION               =*          TEXT                         =       return                       =  git_return.

Page 18: Sap Notebook

UP TO 1 ROWS Example

SQL Query examples:

SELECT A~ERNAM A~EBELN A~SUBMI A~AEDAT A~ANGDT A~KDATB A~LIFNR B~TXZ01 C~TFACTOR1 C~TFACTOR2 C~TFACTOR3 C~AMOUNT D~NAME1 INTO CORRESPONDING FIELDS OF ITAB FROM EKKO AS A INNER JOIN EKPO AS B ON B~EBELN = A~EBELN AND B~EBELP = A~LPONR INNER JOIN ZMMTENDER AS C ON C~TENDERNUMBER = B~EBELN INNER JOIN LFA1 AS D ON D~LIFNR = A~LIFNR UP TO 1 ROWS WHERE A~EBELN = P_RFQ_NO.

ENDSELECT.

HOW TO USE SAP GET SET PARAMETERS - GLOBAL VARIABLE

While working with SAP, many times you would have noticed screen fields getting populated with values on its own. Want to know how? It’s all by the virtue of SET/GET parameters (also known as SPA/GPA parameters). In this post, we will make ourselves knowledgible enough to work with these.

What are SET/GET parameters or SPA/GPA Parameters?

SET/GET Parameters or SPA/GPA parameters are the means through which you can make use of SAP memory to pass data between different main ( external ) sessions of a teminal ( user ) session. To elaborate a little on the terms used above, when you logon to SAP system, you basically create a terminal or user session. This terminal session can have multiple main or external sessions within it, which you can relate to multiple screens opened withing one user logon. SAP Application server allocates a memory area dedicated to each user or terminal session which can then be shared between all the main sessions within this user session. This user-specific memory dedicated to a user session is calledSAP memory. SET/GET parameters basically enable the exchange of data between these external sessions within the same user session through SAP memory.

How to create SET/ GET parameters?

Before you can make use of SET/GET parameter, you will have to create one, failing which you would get error while performing ‘Extended Check’ of your program. However, you

Page 19: Sap Notebook

wont get any compile time error or runtime error. SET/GET Parameters are also treated as repository objects and have normal Object directory entry (TADIR) similar to other repository objects. You can create SET/GET parameter using Object navigator (transaction SE80). Just select the package under which you want to create the SET/GET create parameter and follow the following path in the context menu obtained by right-clicking on the package.  -> Create -> Other(1) -> SET/GET Parameter ID

Create SET/GET Parameter ID

The definition of SET/GET parameters can be found in the transparent table TPARA.

How to transfer data from one external session to other using Parameter IDs? 

How to read / set values for the Parameter IDs in program?

After creating the parameter, the next step is setting the values to the created parameter ids. You can do this using the below mentioned ABAP command.

SET PARAMETER ID parameterid FIELD dobj.

Here, parameterid is the SET/GET Parameter ID whose name should not be of more than 20 characters. dobj is a flat character type data object whose value needs to be set to the parameter id mentioned earlier. You can read the value of any parameter id in the same or different main/external session of the same user/terminal session using a similar ABAP statement.

GET PARAMETER ID parameterid FIELD dobj.

Page 20: Sap Notebook

Same as above, parameterid is the name of parameter id whose value needs to be fetched and dobj is the flat character type data object to which the fetched value will be assigned. A small example to illustrate the above statements:

REPORT ZAS04. 

DATA: lv_cocd TYPE bukrs. 

SET PARAMETER ID ‘BUK’ FIELD ‘0001′. 

GET PARAMETER ID ‘BUK’ FIELD lv_cocd. 

WRITE: ‘Value fetched from Parameter ID – BUK : ‘, lv_cocd.

On executing this small program, you will get the following output:

Example of ABAP Statement 'SET PARAMETER ID' & 'GET PARAMETER ID'

HOW TO FIND USER EXIT

Find the User Exit SubroutinesDouble click on any of these Includes that contains User-Exits. You can see various subroutines with prefix USEREXIT.

Customers can insert their standard code inside these form routines.

Page 21: Sap Notebook

Customers can create their own form routines but should begin with ‘ZZ’.A more faster way to search is to search the string ‘PERFORM USEREXIT’ inside the program.

USER EXIT IN DETAIL

 1. What is a User Exit?o User exits allow you to add additional functions to the SAP standard.o Programs with user exits contain Subroutine (Form Routines) calls at certain

points in their syntax that are identified by the prefix USEREXIT.o The actual User Exits Form Routines are located in an Include Program that has

been assigned to a Module Pool Program.. The following diagram explains this:

o In the User Exits Form Routines customers can include any changes

(enhancements) that they want to make to the system. These includes are always processed during program flow

o So the SAP developer creates a special include in a module pool. These includes contain one or more subroutines routines that satisfy the naming convention USEREXIT_. The calls for these subroutines have already been implemented in the R/3 program.

o A user exit is considered a modification, since technically objects in the SAP namespace are being modified.

o After delivering them, SAP never alters includes created in this manner; if new user exits must be delivered in a new release, they are placed in a new include program.

2. In which SAP component User Exits are primarily used?User exits are primarily used in the Sales and Distribution component.3. What are the advantages and disadvantages of User Exit?Advantage: In principle, customers can modify anything they want that is found in the include (tables, structures, and so forth).

Page 22: Sap Notebook

Disadvantage: SAP cannot check the individual enhancements themselves which often leads to errors in the enhancement process. Also after upgrade, the inserted Userexit modifications are usually gone. Therefore its not recommended.4. How can we find overview of User Exits as well as a description of those user exits that exist in SD?We can find overview of User Exits as well as a description of those user exits that exist in SD in the SAP Reference IMG under Sales and Distribution -> System Modification -> User exits.Steps:

o Go to transaction : SPROo Go to Sales and Distribution -> System Modification -> User exits

5. How do you find User Exit in any transaction say VA01 – Create Sales Order?Step 1: Find the Module Pool ProgramGo to the transaction – VA01 – Create Sales Order.Then Go to SYSTEM in the Menu bar and then to STATUS from where we can find the ‘Program (screen)’.

Page 23: Sap Notebook

Step 2: Find the Includes Program that contains User-ExitsDouble click that ‘Program (screen)’. Generally user-exits are always at the start of the standard SAP program

Page 24: Sap Notebook

Step 3: Find the User Exit SubroutinesDouble click on any of these Includes that contains User-Exits. You can see various subroutines with prefix USEREXIT.

Page 25: Sap Notebook

Customers can insert their standard code inside these form routines.Customers can create their own form routines but should begin with ‘ZZ’.A more faster way to search is to search the string ‘PERFORM USEREXIT’ inside the program.

HOW TO FIND A CUSTOMER EXIT ? Open your program in SE38. Search globally for "CUSTOMER-FUNCTION" or "CL_EXIT".If there are hits, you have exits of the second generation (handled with CMOD) or a BADI (handled with SE18/SE19).

HOW TO FIND A BADI FIND A BADIThese steps should enable you to find any BADI related to any transaction in a matter of minutes.1) Go to the transaction SE37 to find your function module.2) Locate the function SXV_GET_CLIF_BY_NAME.3) Put a breakpoint there.4) Now open a new session.5) Go to your transaction.6) At that time, it will stop this function.7) Double click on the function field EXIT_NAME.8) That will give you name of the BADI that is provided in your transaction.

OR

GOTO SE24 - CLASS BUILDERGo the class CL_EXITHANDLER goto its method GET_INSTANCE

and put a breakpoint in this line calling the methodCALL METHOD CL_EXITHANDLER = > GET_CLASS_NAME_BY_INTERFACE

Run any tcode and in the debugger if you enter the fieldname EXIT_NAME it will give all the exits for this tcode.

Page 26: Sap Notebook

Difference between SMOD AND CMOD ?

What is the difference between SMOD and CMOD?

CMOD is the Project Management of SAP Enhancements (i.e., SMOD Enhancements). SMOD contains the actual enhancements and CMOD is the grouping of those SMOD enhancements. Enhancements are exits developed by SAP. The exit is implementerd as a call to a function module. The code for the function module is written by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module. The naming standard of function modules for function module exits is:EXIT_ [programname] [3 digit suffix]The call to a functionmodule exit is implemented as:CALL CUSTOMER.-FUNCTION [3 digit suffix ]For Example: The program for transaction VA01 Create salesorder is SAPMV45A1. If you search for CALL CUSTOMER-FUNCTION program SAPMV45A you will find ( Among other user exits): CALL CUSTOMER-FUNCTION '003'  exporting    xvbak   = vbak    xvbuk   = vbuk    xkomk   = tkomk  importing    lvf_subrc = lvf_subrc  tables    xvbfa = xvbfa    xvbap = xvbap    xvbup = xvbup. The exit calls function module EXIT_SAPMV45A_003 

2. How to find exits Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT If you know the Exit name, go to transaction CMOD. Choose menu Utillities = >SAP Enhancements. Enter the exit name and press enter. You will now come to a screen that shows the function module exits for the exit. or use this ABAP program to search for exits :-Finding the exits of a SAP transaction code

3. Using Project management of SAP Enhancements You want to create a project to enhance transaction VA01- Go to transaction CMOD- Create a project called ZVA01- Choose the Enhancement assign radio button and press the Change buttonIn the first column enter V45A0002 Predefine sold-to party in sales document . Note that an enhancement can only be used for 1 project. If the enhancement is allready in use, and error message will be displayed- Press Save

Page 27: Sap Notebook

- Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002.- Double Click on the exit.Now the function module is displayed. Double click on include ZXVVAU04 in the function moduleInsert the following code into the include: E_KUNNR = '2155'. Activate the include program. Go back to CMOD and activate the project.Goto transaction VA01 and create a salesorder. Note that Sold-to-party now automatically is "2155" 

SAP FORMS

1 Concepts1.1 Modifying SAP FormsIf you want to modify SAP forms, set up your development environment as follows:1. Make sure that no SAP-standard forms are stored as client-specific copies in your development client. Such forms should be held only in client 000, the SAP development and installation client. If you access an SAP-standard form from another client, then the central copy in client 000 is used.If you need to remove SAP-standard objects from your development client, see Notes 10388 and 3355 in the SAP Online Service System (OSS). These notes explain the procedure for saving modified forms and then deleting all forms.2. To modify SAP standard forms,

Copy the forms you need from client 000 to your development client. Rename the forms using a name from the customer name reserve (names

starting with Y or Z). Copy the forms to one of your own Y or Z development classes.

Renaming the SAP standard object makes it possible to manage and transport your changes with the SAP workbench organizer. The organizer is not activated for SAP-standard objects that are modified in clients other than 000.3. To put your modifications into effect, you must also modify the ABAP print program used to print documents that use this form. You should rename such print programs and store them in your own Y or Z development classes.You can use the SAP Customizing System to replace the SAP print program with your modified print program in the affected applications

1.2 Forms: ConceptsForms are used to control the page layout and also the text formatting in your documents. Before formatting a document for output to the screen or to a printer, you must assign a form to it. If you do not specify a form for a document, then the SYSTEM form is assigned to the document by default.Application-specific forms are used in SAP applications to specify the page layout for such special documents as invoice or checks. These forms specify the structure of the information on the page(s) of such a document. They define, for example, the address header, item lines, the footer, and so on. There are two ways to format texts with forms:

Page 28: Sap Notebook

In the standard SAPscript text processing (Tools Standard text), you can select a form for a document. You can then type text into the main window of the form and output the document in the format defined in the form. Word processing For example, you can select a form for a letter. You can then type the body text of the letter in the main window. When you print the letter, the default text elements in the other windows of the form (heading, footer, and so on) are printed with the body text.

A document can be generated by a print program in one of the SAP applications. The print program uses a form to generate the document. Most correspondence and document generation in the SAP System are handled by way of print programs.

A print program selects the text elements that are to be printed in the windows of a form. It may also collect information from the user or ask the user to input text directly, as in some correspondence functions. The print program may also provide data for variables defined in the form.Finally, the print program uses the form to format the document for display or printing.

1.3 Client and Language Versioning: ConceptsForms and styles are client-specific. That is, a form or style other than the SAP standard in client 000 is available only in the client in which it was created.Forms and styles are also language-specific. That is, the definitions and texts in a form or style are defined for a particular language. Forms and styles can be translated using the standard SAP translation tools.Client 000 Defaulting: SAPscript accords forms and styles in client 000 a special status.If a form or style that is used in a document is not available in the client in which the document is being printed, then SAPscript checks for the form or style in client 000. If it is found there, then the client 000 version is used to print the document.SAP standard forms and styles are always held in client 000. You can take advantage of the client 000 defaulting as well by storing your Yxxx and Zxxx forms and styles there. That way, if a local version of a form or style is not present in a client, the client 000 version is used instead.Language rules: SAPscript uses the following rules to manage versions of forms and styles in different languages:

The language in which a form or style is created is its "original language." You can translate a form or style into other languages using SAP’s translation tools.

If a form or style is needed only in its original language and need not be translated, then you can indicate this in the language attributes in the header data. The form or style then does not appear in work lists in the translation tools.

In versions other than the original language version, changes to a form or style are limited only to translation of texts. No changes to definitions and attributes are permitted.

2 Componentes2.1 Header DataYou can find header data in both form and style maintenance. In style maintenance, it is used primarily to present important information – information designed to make it easier for the end user to select a style. The header data in form maintenance, on the other hand, is

Page 29: Sap Notebook

used for information and control purposes. For this reason, the header data of a form will be described in more detail.

Below, the header data is described as it appears in the alphanumeric Form Painter.Like the header data of a style, the header data of a form comprises two parts: the data set by the system and the data you are expected to enter. The latter is dealt with separately.

Device-independent entries. Description

A short explanatory description of the form (also applies to the style), designed to make selection easier for the end user.

Form classYou can assign a form to a class to help you organize and search for forms. The default set of classes is the set of program classes in your system.

Start pageTells the print program which page format in a form to use first for printing.

Default paragraphParagraph set to * in standard text maintenance.

Tab stopA grid set at specified intervals in all windows defined in the form. However, you should note that the tab stops are only valid in paragraphs where you have not defined your own tabs.

Language, Original language, Translation applicUse these fields to record the master language and language of the current version of a form. Marking Translation applic makes the form accessible for translation from the SAP System’s translation tools (transaction SE63).

Device-dependent entries.You can only enter values here that are supported in the R/3 printer definition. If you make other entries, this leads to errors in the check routine.

Page formatDetermined from the spool administration table with transaction SPAD. Make sure there is a printer assignment – there must be an additional spool format for the printer with the same page format.

OrientationDepends on the page format selected. This can also be determined from the spool administration table. Please note that the formats landscape and portrait are not supported by all printers.

Lines per inch (LPI)Basis for converting the unit of measurement LN in style and form maintenance. The value 6.00 is set by the system, as this value is supported by all printers.

Characters per inch (CPI)Basis for converting the unit of measurement CH in style and form maintenance. The value 10.00 is set by the system, as this value is supported by all printers.

Font attributesWith these fields, you can set the default font for a form. The default font applies if other objects do not specify a font. SAPscript suggests a default font, which you can change.

2.2 Paragraph Formats and Attributes

Page 30: Sap Notebook

In SAPscript, paragraphs are formatted using formats and their corresponding attributes. Text processing is simplified by the use of different paragraph attribute groups:

Standard Font Tabs Outline

There are naming conventions for paragraph tags: The paragraph tag can have one or two characters. The first character in the paragraph tag must be a letter, the second a letter,

number, or blank; special characters are not valid. The paragraph format must be identified in the Description field.

2.2.1 Standard Paragraph AttributesIn the Standard attribute group, you find the general attributes that can be defined in paragraph formats:

DescriptionPrecise explanation of your paragraph tag, so that the user can immediately identify it.

Left or right marginAmount of space between the paragraph and the left or right border of the form window.

Indent first lineIndent of the first line of a paragraph. If the value is positive, it is indented to the right, if it is negative, it is indented to the left.If you specify a negative value, then you must place the minus sign after the number: 1- .

Space before and space afterSpace before and space after control the amount of space between paragraphs. The actual space between paragraphs results from the space after the preceding paragraph and the space before the following paragraph.

AlignmentAlignment of a paragraph.

o Left-alignedo LEFTo Right-aligned RIGHTo Centered CENTERo Justified BLOCK

Line spacingSpacing between the lines. The default value is 1 line; the LPI value (lines per inch) in the header data is used to calculate the line spacing.

No blank linesSuppression of blank lines. You can control whether the blank lines of a paragraph should be suppressed in the printout or not:

o No entryo blank lines not suppressedo X blank lines suppressed

Page 31: Sap Notebook

Page protectionCohesion of a paragraph. It is possible to determine whether or not a paragraph can be divided by a page break.

o No entryo no page protection (default)o X all lines of the paragraph are on one page

Next paragraph same pageCohesion of two adjacent paragraphs. Here you can define whether the subsequent paragraph should begin on the same page (that is, at least the first line of the subsequent paragraph must be on the same page).

o No entryo subsequent paragraph is output on the same page or the next page,

depending on the amount of space (default)o X subsequent paragraph begins on the same page2.2.2 Font Attributes for ParagraphsYou can specify font attributes for paragraph formats. They control the font used in the text. You can specify these attributes both for the default font in the header and for particular paragraph formats:

Font familyEnter a font supported in the SAPscript font maintenance.

Font sizeEnter the size of a character font. It is measured in 1/10 point.

Bold/ItalicSpecify whether to use bold-face printing or italics.

UnderlinedMark this attribute to underline entire blocks of text.

When defining a paragraph format, use More to specify these underline attributes: Spacing between the base line and the underline Thickness Intensity

Intensity is expressed in percent: 0 % is a black underline; 100 % is no underline.If you defined default underlining in the header, then the fields for underline attributes are already displayed on the screen.The following selection criteria apply to the font attributes bold, italics, and underlined:

Off attribute is not set Retain inherited On attribute is set

The combination of font family, font size, bold type attribute and italics attribute is referred to as a system font or SAP font. To use the SAPscript font Font. Word processing maintenance, choose Tools2.2.3 Tabs in Paragraph FormatsYou can define as many tab positions as you require for each paragraph format. The text can be aligned in different ways:

Left-aligned with LEFT Right-aligned with RIGHT Centered with CENTER At the sign with SIGN At the comma or decimal point with DECIMAL

Page 32: Sap Notebook

You can control the tab feed in a paragraph with tab positions. The tab stops you define in the paragraph format replace the tab spacing you defined in the header data of the form. However, this depends on the extent to which you have defined tab stops in the paragraph format. If there are fewer tabs in the paragraph formats than in the header data, the tab stops of the header data are used for the rest of the line. The tab stops are represented as, , in the text editor.You can use different units of measurement to define a tab position:

CH Characters CM Centimeters MM Millimeters PT Points TW Twips (1/20 point)

The unit of measurement CH is converted to an absolute unit of measurement using the CPI value (characters per inch) from the header data of the form.

2.2.4 Paragraph and Heading NumberingThe paragraph numbering and marking attributes are used to structure texts into chapters, subchapters, and sections. Numbering is carried out automatically by SAPscript.You can create an outline with the entry options available:

OutlineEnter the name of the highest-level paragraph in an outline hierarchy here. The outline hierarchy is created by assigning this paragraph to all outline paragraphs.

Outline levelEnter the level in the outline hierarchy. The outline levels of the paragraphs are numbered upwards from 1; the highest outline level therefore has the outline number 1.

Number marginSpecify the space between numbering and window border. Note that your numbering may extend into the text area of the paragraph if the difference between the left margin and the number margin is not great enough to hold the numbering characters.

Left/right delimiterSpecify the character that precedes or follows the numbering.

Number chainingSpecify whether you want the paragraph numbering of the paragraph to be preceded by the numbering of all higher paragraphs in the hierarchy.

Example for number chainingwith without3. 3.3.1 1.3.2 2.3.2.1 1.

Character stringSpecify the numbering format. The numbering can be assigned a different font or character format to the rest of the paragraph.

Numbering typeo ARABIC

Arabic numerals: 1, 2, 3.o CHAR Fixed character: letter or numeral, entered in the field

Page 33: Sap Notebook

o LETTER Letters: A-Zo ROMAN Roman numerals: I, II, III, IVDepending upon the numbering type that you select, the following attributes may also apply:

Fixed characterDefine the fixed character to be used for numbering. You should only make an entry in the field Fixed character if you have specified CHAR as the numbering type. Fixed characters include + - and o .

Output lengthEnter the number of characters for Arabic numerals.

Upper caseSpecify for letters or Roman numerals.

2.3 Character Formats and AttributesCharacter formats, as opposed to paragraph attributes, allow you to format entire blocks of text within a paragraph.Character attribute groups can be:

Standard Font

When you define character formats, observe the following naming conventions: The character format can have one or two characters. The first character must be a letter, the second a letter, number, or blank; special

characters are not valid.Enter a simple explanation in the field Description. It is intended to help the user make a selection.

2.3.1 Standard Attributes for Character Formats Marker

Links a search key to the selected character string when the end user uses this character format. Examples include glossary, hypertext, and data element links. Here, selected character strings are assigned the appropriate key.

Bar codeBar code that is required for certain variables and is known to the printer, for example EAN8. The character string is printed as a bar code if the character string concerned is selected.(Tools Word processing Bar code names, such as EAN8, refer to system bar codes. These are defined in the SAPscript font maintenance Font).

ProtectedThe character string is not split by a line break, but printed together on the next line.

HiddenThe character string is not printed. The text is only visible in the text editor.

Superscript/subscriptThe character string is printed half a line higher or lower.The following options are available for defining these attribute types:

o OffAttribute is not set

o Retain Attribute is inheritedo On Attribute is set2.3.2 Font Attributes for Character Formats

Page 34: Sap Notebook

Font attributes can be specified for character formats as well as for paragraph formats. You have the same options as for defining font attributes for paragraph formats.

2.4 WindowsWindows are defined in form maintenance. They represent areas that are positioned on pages – as page windows – and in which at a later time text is printed. You must define at least one window for each form. Otherwise, SAPscript cannot format the text.You can assign window names and window types. However, note that you can define only one main window per form.Use one of these window types:

MAINMain window in which continuous text is printed. This is the window used by dialog users of a print program and form. For example, the body text of a letter would be entered in MAIN.The text in the main window can extend over several pages. If the text fills one page, output continues in the window of the next and subsequent pages, as long as MAIN has been defined for these pages.

VARWindow with variable contents. The text can vary on each page in which the window is positioned. Variable windows are formatted for each page.To every window you can assign text, which is printed in the corresponding window when the form is formatted. To assign text, use text elements, which are stored with the form.To create and maintain text elements with the SAPscript Editor, choose Text elements. Should the text selected for the window exceed the window size, then the text is cut off.

CONSTWindow with constant contents that is formatted only once.Currently, CONST windows are processed in the same way as VAR windows. You should only use windows of type VAR.

2.4.1 Default ParagraphFor a particular window, you can override the default paragraph format that is set in the form header. Enter the default format that should apply in the window in the Default paragraph field in the window definition screen.

2.5 PagesYou must define at least one page for every form. And you must designate a "first" page in the form header. Otherwise text formatting is not possible. In addition, you should inform the system which page is to be used after reaching the end of the first page. If you do not specify a next page, the output of your text ends at the end of the current page.To define a page, give it a name and specify attributes for it:

Name of the next page Page counter modeo INC Increases the counter by 1o HOLD Counter remains unchangedo START Sets the counter to 1You can display the contents of the page counter with the system symbol&PAGE&.

Numbering type of the page countero ARABIC Arabic numeralso LETTER Letters

Page 35: Sap Notebook

o ROMAN Roman numeralsAlthough CHAR is displayed as an entry option for the numbering type of the page counter, internally CHAR is converted to ARABIC.

Output length for page numbering with numerals Upper or lower case for numbering with Roman numerals or letters Resource name

With Resource name, you specify that the paper for this page should be taken from a particular paper tray at the printer.In Resource name, enter the print control that has been defined for switching to the paper tray you want to use. In printer types pre-defined by SAP, these print controls are generally as follows:

o TRY01 Select first paper trayo TRY02 Select second paper tray (if available at the printer)o TRY03 Select third paper tray (if available at the printer)o TRYEN Print envelopes (if available at the printer)o TRYMN Switch the printer to manual paper feed (if available at the

printer). The printer pauses until you feed a sheet of paper into it.o TRYME Switch the printer to manual envelope feed (if available at the

printer). The printer pauses until you feed an envelope into it.You can use all tray selection print controls except TRY03 with suitably equipped printers that are defined with the following SAP device types: HPLJSTND, HPLJ_II, HPLJIIID, HPLJ4, LX4039, and SNI20XX8.You can use TRY01, TRY02, TRY03, and TRYMN on suitably equipped printers that are defined with these device types: KYOF1000, KYOF1200, KYOFS1500.See the spool system (transaction SPAD) to check on how your printers are defined.

Print modeWith Print mode, you can specify single- or double-sided printing for a page. You can choose from the following values:

o ' ' Currently active printing mode continues unchanged.o S The page is printed in simplex mode. That is, the printer should print

on only one side of the paper. If another mode was previously active, then the printer is switched to simplex mode with the start of the page.

o D The page is printed on the first side of a sheet in duplex mode. If another mode was previously active, then the printer is switched to duplex mode with the start of the pageand continues in this mode.

o T The page is printed on the first side of a sheet in tumble duplex mode. That is, the printer prints on both sides. The page on the second side is always inverted, so that the footer of the second page is printed opposite the header of the first page.

o If another mode was previously active, then the printer is switched to tumble duplex mode with the start of the page and continues printing in this mode.

Print modes are currently supported for printers that use the PCL-5 language. These are printers that are defined with the following SAP device types: HPLJ_II, HPLJIIID, HPLJ4, LX4039, SNI20XX8.See the spool system (transaction SPAD) to check on how your printers are defined.The print controls for these functions are SPMSI (begin simplex printing); SPMDU (begin duplex printing); SPMTU (begin tumble duplex printing); SPMFS (print on first side of sheet

Page 36: Sap Notebook

in duplex or tumble duplex mode); and SPMBS (print on second side of sheet in duplex or tumble duplex mode).2.5.1 Defining Follow-On Pages in Duplex Print ModesYou switch to duplex or tumble duplex mode with a form page for which one of these modes is specified. To continue printing in the current mode, for follow-on pages you must define another page in which the Print mode field is empty. Otherwise, the following pages after the mode switch will continue to be printed only on the front sides of new sheets of paper.The reason: When SAPscript sends a page with Print mode D or T to the printer, it not only sets the print mode accordingly. To ensure that the first page in the new mode is correctly output, SAPscript also instructs the printer to output the page on the front side of a sheet. If SAPscript sends a sequence of D or T pages to the printer, the output is printed only on the front side of each sheet.You define a first page named FIRST for a form to be printed in duplex mode. You therefore set the Print mode in FIRST to D.To make the duplex printing work correctly, you must define a second page FOLLOWER in which Print mode is left empty. In the form definition, you specify FOLLOWER as the follow-on page for FIRST and for itself as well.Your text is then printed in duplex mode. FIRST switches the printer to duplex mode and forces printing of the first page on the front side of a new sheet. FOLLOWER accepts the duplex mode and sends no further mode print controls to the printer. The printer therefore alternately prints FOLLOWER pages on the fronts and backs of sheets.2.5.2 Testing Tray Selection and Print Mode SelectionSAP provides predefined SAPscript documents with which you can test whether tray selection and print mode selection are working properly on your printers.For tray selection, print the SAPscript document SAPSCRIPT-TRAYTEST, ID ST, Language D or E.For print mode selection, print the SAPscript document SAPSCRIPT-PRINTMODETEST, ID ST, Language D or E.

2.6 Page WindowsWhen you define page windows, the window names are linked to page names. You must specify the position and size of the window on the assigned page.Define the position of a window by specifying the left margin and upper margin and the size of a window by specifying its width and height.

Left margin Space between the window and left margin of the page Upper margin Space between the window and upper margin of the page Window width Width of the window depending on the page format selected Window height Height of the window depending on the page format selected

Note that the width of the main window must be the same on all pages. All other window types can have different sizes and positions on different pages.To print multiple columns, define several main windows on a page. As text entry is continuous, once the first main window has been filled, output continues in the second main window.

2.7 Text ElementsYou can define text elements (window texts) for each window. On the Form: Text elements.Request screen, choose Edit

Page 37: Sap Notebook

The print program accesses text elements by name, formats them and prints them in the respective window. That is, the program can decide which text elements should be printed in a particular window. It calls these text elements by name to print them. You must therefore change text element names in the print program if you make any changes to text element names in a form.In the layout of a text element, you can use only the paragraph and character formats defined in the form.Example of a text element in an order confirmation:/E ITEM_LINEIL &VBDPA-POSNR&,,&VBDPA-MATNR&,,&VBDPA-ARKTX&/ &'Customerarticlenumber 'VBDPA-IDNKD' '&&'Position/ 'VBDPA-POSEX&This example shows a section of a main window of a form, with an item line of an order confirmation. The /E in the tag column is used to identify the text as a text element, ITEM_LINE is the name of the text element.2.7.1 Default Text ElementAt the start of a window, you can define a text element without the /E command in the paragraph format column. This text is always printed at the start of the window. It is not necessary to insert this text explicitly via a print program.

2.8 Main WindowIn the definition of page windows you can define several main windows per page. However, you must first specify an area for the main windows.This function allows you to output text either in columns as in newspapers, or next to and below each other as in label printing.You can specify the size and position of this area under the group heading Area:

Left margin Amount of space from the left border of the page Right margin Amount of space from the right border of the page Area width Width of the area (required entry) Area height Height of the area (required entry)

To position several main windows in this area, you must assign values to the variables under the group headings Horizontal and Vertical.Under the group heading Horizontal, enter

Spacing Horizontal spacing of the main windows Number Number of main windows (horizontal)

Under the group heading Vertical, enter Spacing Vertical spacing of the main windows Number Number of main windows (vertical)

The units of measurement which can be used in the fields Left margin, Upper margin, Area width, Area height, and Spacing for both horizontal and vertical measurements are:

CH Characters CM Centimeters LN Lines MM Millimeters PT Points

Page 38: Sap Notebook

TW Twips (1/20 point)For the vertical area, CH is calculated using the CPI value in the header data of the form. LN is converted on the basis of the LPI value in the header data of the form. The field Start position under the group heading Positions is a counter for the main windows defined in a page window. You can use this counter to number the columns. Always enter a value greater than or equal to 1 for the counter Start position.If you change the counter of the form main window, the form main window can no longer be distinguished from the main windows of the page window.

3.1 Displaying Versions of FormsVersions. The versionTo display the versions of a form, choose Utilities list includes the following information:

Version and status: New

No active version, not available for use as yet. Active

The current form is the active version, in effect in the System. Revised

The current form is being changed. There are active and edit versions of the form. Translated

The current form must be translated. Current language key Original language of the form. Description of the form.

To display detailed information on a version of the form, put the cursor on the version and choose Form info.

3.2 Including GraphicsYou can include graphics – such as diagrams or charts – in your SAPscript documents. Typically, such graphics are included in documents by way of forms.Graphics are uploaded either in "Baseline TIFF 6.0" format (file extension.tif on PC files) or as printer macros. A printer macro in this case is the sequence of printer instructions needed to print out a diagram.Graphics and printer macros are uploaded with program RSTXLDMC into individual standard text documents. At upload, the graphics or printer macros are converted to the format required by the target printer, either PostScript, PCL-5 for newer Hewlett-Packard and compatible printers, or PRESCRIBE for Kyocera printers. The resulting SAPscript document can be printed only on the target printer type. Online display is not possible.In a form, you might include graphics such as a company logo in the header window. You can accommodate printing on different types of printers with separate includes for each format in which you have uploaded graphics. If you define the includes as text elements, then your print program can select the appropriate include depending upon the device type of the printer that the user selects. You can determine the device type by looking up the printer name in table TSP03 (field PADEST) and evaluating the device type (field PATYPE).For more information, see the report documentation for RSTXLDMC.Using graphics in forms can greatly increase the size of print requests and therefore seriously affect the performance of your printers. Graphics are not recommended for printing time-critical documents.3.2.1 Using Boxes, Lines, and ShadingSAPscript provides these text commands for using boxes or frames, lines, and shading in documents:

Page 39: Sap Notebook

The BOX command for drawing a box or a horizontal or vertical line. The POSITION command for specifying the starting point (the upper left

corner) of a box or line. The SIZE command for specifying the width and height of a box.

3.2.2 Supported PrintersYou can print boxes, lines, and shading on any page printer that uses one of these SAPscript printer drivers in its device-type definition:

HPL2 Hewlett-Packard LaserJet family and compatibles POST PostScript-compatible printers PRES Kyocera printers (Prescribe printer language).

3.2.3 Boxes, Lines, Shading: BOX, POSITION, SIZEUse the BOX, POSITION, and SIZE commands for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading.The SAP printer drivers that are based on page-oriented printers (the HP LaserJet driver HPL2, the Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when printing. Line printers and page-oriented printers not supported in the standard ignore these commands. You can view the resulting printer output in the SAPscript print preview.Syntax:/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY] /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE] /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

3.2.3.1 BOX CommandSyntax/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]Effect: draws a box of the specified size at the specified position. Parameters: For each of XPOS, YPOS, WIDTH, HEIGHT, and FRAME, you must specify both a measurement and a unit of measurement. Specify the INTENSITY parameter as a percentage between 0 and 100.

XPOS, YPOSUpper left corner of the box, relative to the values of the POSITION command.Default: Values specified in the POSITION command.The following calculation is performed internally to determine the absolute output position of a box on the page:X(abs) = XORIGIN + XPOSY(abs) = YORIGIN + YPOS

WIDTHWidth of the box. Default: WIDTH value of the SIZE command.

HEIGHTHeight of the box. Default: HEIGHT value of the SIZE command.

FRAMEThickness of frame. Default: 0 (no frame).

INTENSITYGrayscale of box contents as %.Default: 100 (full black)

Page 40: Sap Notebook

Measurements: You must specify decimal numbers as literal values (like ABAP numeric constants) by enclosing them in inverted commas. Use the period as the decimal point character. See also the examples listed below. Units of measurement: The following units of measurement may be used:

TW (twip) PT (point) IN (inch) MM (millimeter) CM (centimeter) LN (line) CH (character).

The following conversion factors apply: 1 TW = 1/20 PT 1 PT = 1/72 IN 1 IN = 2.54 CM 1 CM = 10 MM 1 CH = height of a character relative to the CPI specification in the form header 1 LN = height of a line relative to the LPI specification in the form header

/: BOX FRAME 10 TW Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT)./: BOX INTENSITY 10 Fills the window background with shading having a gray scale of 10 %./: BOX HEIGHT 0 TW FRAME 10 TW Draws a horizontal line across the complete top edge of the window./: BOX WIDTH 0 TW FRAME 10 TW Draws a vertical line along the complete height of the left hand edge of the window./: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15 /: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW /: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW /: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.3.2.3.2 POSITION CommandSyntax/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started, the POSITION value is set to refer to the upper left corner of the window (default setting).Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words, as a value that specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.

XORIGIN, YORIGINOrigin of the coordinate system.

WINDOWSets the values for the left and upper edges to match those of the current window (default setting).

PAGESets the values for the left and upper edges to match those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).

Page 41: Sap Notebook

/: POSITION WINDOW Sets the origin for the coordinate system to the upper left corner of the window./: POSITION XORIGIN 2 CM YORIGIN '2.5 CM' Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page./: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.3.2.3.3 SIZE CommandSyntax/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started, the SIZE value is set to the same values as the window itself (default setting).Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.

WIDTH, HEIGHTDimensions of the rectangle or line.

WINDOWSets the values for the width and height to the values of the current window (default setting).

PAGESets the values for the width and height to the values of the current output page./: SIZE WINDOWSets WIDTH and HEIGHT to the current window dimensions./: SIZE WIDTH '3.5' CM HEIGHT '7.6' CMSets WIDTH to 3.5 cm and HEIGHT to 7.6 cm./: POSITION WINDOW /: POSITION XORIGIN -20 TW YORIGIN -20 TW /: SIZE WIDTH +40 TW HEIGHT +40 TW /: BOX FRAME 10 TW A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.3.2.4 Pre-Setting BOX Position ArgumentsYou can use the POSITION and SIZE commands to preset some arguments in the BOX command. POSITION presets the start point (upper left corner) of a box or line. SIZE specifies the width and height of a box.You can use POSITION and SIZE to preset arguments, but you can also set the start point and size arguments of a box or line directly in the BOX command.By default, if no positioning is specified, the upper left corner of a box or halftone or the top of a line is aligned with current SAPscript window. That is, the upper left corner of the box, halftone, or line starts at the upper left corner of the current window in the active form. By default, the height and width of a box are set to the height and width of the current window.Use POSITION and SIZE to preset the arguments in a BOX command in the following situations:

The BOX command exceeds the 132-character (1 line in SAPscript) length limitation if you specify all arguments directly in the command. You may exceed this length limit if, for example, you use symbols in a command.

By pre-setting arguments with POSITION and SIZE, you can work around the limitation on the length of a command. You do not need to specify the preset arguments in the BOX command.

Page 42: Sap Notebook

You want to use the enhanced capabilities of POSITION for adjusting the starting point of a box or line.

With BOX, you can specify an offset for the starting point only as a whole number (non-negative integer). This command would print a box starting 1 CM to the right and 1 CM down from the left upper corner of a window:/: BOX XPOS '1' CM YPOS '1' CMWith POSITION; you can adjust the position of a line or box relative to a window much more precisely. In the POSITION command, you can specify positive and negative offsets and use non-integer numbers.Example: The commands shown below position a box slightly to the left and slightly above a window. This leaves a margin between the edge of the box and the text in the window./: POSITION XORIGIN '-.2' CM YORIGIN '-.2' CM/: SIZE WIDTH '+.2' CM HEIGHT '+.2' CM/: BOX FRAME 10 TW(Note that the box must be enlarged to accommodate the shift. If it is not enlarged, then it will not cover all of the window.)You can also use POSITION to set the starting point to the upper left corner of the active page format. Example: POSITION PAGE moves the starting point from the active window to the active page format.

You want to use the relative sizing capabilities of SIZE to adjust the size of a box, line, or halftone.

With BOX, you can make only absolute size specifications. BOX HEIGHT, for example, overrides the default height setting to the height of the current window.With SIZE, you can adjust the size of a box or a line with respect to its previously-set dimensions. The following commands would, for example, draw a frame 1 CM in from the margins of the paper:/: POSITION PAGE/: POSITION XORIGIN 1 CM YORIGIN 1 CM /: SIZE PAGE/: SIZE HEIGHT '-2' CM WIDTH '-2' CM3.2.5 Using the Commands in Texts and FormsSince BOX, POSITION, and SIZE are text commands, you can insert them directly in a text. However, usually you use these commands in forms, where you have better control of how a box or line and the accompanying text fit together. SAPscript does not automatically fill text into a box or otherwise orient text with respect to these graphical elements.Enter the following line as a command in text in a SAPscript document. The command draws a box of 17.5 CM length, 1 CM high, with 10% shading:/: BOX WIDTH '17.5' CM HEIGHT '1' CM INTENSITY 10The left upper corner of the box is located at the left upper corner of the main window defined in the form of the document. The text that you type in is not automatically oriented in accordance with the box. Whether the text fits in the box or not depends on you. If you type in three lines of text, then the bottom line of text is likely to appear below the bottom of the box.In a form, you can orient both text and graphical elements in the windows that you define. You therefore have much better control of how graphics and text fit together.3.2.6 Tips and GuidelinesTo ensure in forms that boxes, lines, and shading fit correctly with text, follow these guidelines:

In your form design, match graphical elements and windows to each other. By default, a box defined in a window has the dimensions and starting point of the window.

Page 43: Sap Notebook

Defining a window for each graphical element that you want to include facilitates using boxes, lines, and shading, since the graphical element and the window have the same dimensions and positioning.Example: If a window is defined with the dimensions 6 CM high and 8 CM wide, then this statement in the text element of the window paints a 10 halftone with the same dimensions. The shading is oriented on the upper left corner of the window./: BOX INTENSITY 10

Use the POSITION command to adjust the position of a box or line relative to a window.

For example, these commands in a form window would allow more room above the first line of text in the window. The box would start 0.2 CM above the top of the window./: POSITION YORIGIN '-0.2' CM/: SIZE HEIGHT '+0.2' CM /: BOX INTENSITY 5 Make sure to increase the size of the box to accommodate an offset. Otherwise, the box will not cover all of the window.In the example above, the SIZE command increases the height of the box by 0.2 CM to accommodate the positioning of the box above the window.

Draw a horizontal line by setting the HEIGHT in a BOX command to 0. Draw a vertical line by setting WIDTH to 0.

/: BOX FRAME 10 TW WIDTH 0 TW HEIGHT '10' CM Vertical line 10 CM long/: BOX FRAME 10 TW WIDTH '10' CM HEIGHT 0 TW Horizontal line 10 CM long

Adjust the tabs in a window to match the position of lines and boxes.For example, you define a table with the commands shown below. The vertical lines in the table are drawn in at 10 CM and 13.5 CM from the left edge of the window:/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW /: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15 /: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW /: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TWIn the paragraph formats that you use to fill the table, you would define tabs at the positions shown below. With these tabs, your input would start right-justified in the first, second, and third columns of the table. You must ensure that your input is not too long to fit in the columns defined with the lines:Format TB Fill tableTabs: 1 9.5 CM RIGHT2 13.0 CM RIGHT3 17.0 CM RIGHT

4 Design ToolsForms are used for the page layout of SAPscript documents. To be able to format a text for output to the screen or printer, you must assign a form first.If no form has been assigned to a text, the system automatically assigns the form SYSTEM, which contains minimal definitions for text formatting.There are two ways of formatting texts using forms:

Use the standard text maintenance to enter and print the text. You can assign any form. You can also enter text via the form, for example, a letter header.

Use an ABAP program to format the text according to an assigned form. The program can either dynamically print individual predefined text modules – text elements – or transfer entire texts to be printed using the form.

Page 44: Sap Notebook

Observe these naming conventions for form names: The name must start with a letter. The name may contain only letters.

The characters * , & / as well as blanks are not valid. The name can be up to 16 characters long.

4.1 Form ComponentsIn the alphanumeric Form Painter, a form has the following components:

Header dataData related to development (created by, development class, and so on) and form information (which elements are used) are both stored in the header data.

Paragraph formatsParagraph formats are required in forms (as in styles) to format texts. However, they are also used for word processing in forms, for example, to format text elements.

Character formatsYou can also use character formats to format texts or paragraphs. Unlike paragraph formats, however, they are used to format text within a paragraph.

WindowsWindows are output areas you position on the individual pages of the form. The system then prints the contents of the windows, the text elements, into these output areas.

PagesMost forms comprise different pages, for example, one page with the customer address, the subsequent page containing the corresponding customer records. This implies that you must define different output areas (windows) on different pages.

Page windowsA page window is the combination of a window and a page. You specify the dimensions of a window and its position on a page.

4.2 Processing in OverviewForm maintenance offers three processing options:

Create/changeChange a form that already exists or create a new one.

DisplayDisplay a specific form.

CatalogDisplay all available forms.

To create a form,1. Enter the form name and fill in the header information.2. Define any paragraph formats and character formats that you need for the form.3. Define page formats for the form.4. Define the windows you want to position on the pages.5. Define text elements in windows. These are the default texts and the texts selected by the program that can be printed in windows.6. Specify how the windows are to be placed on the pages by defining page windows.4.2.1 Defining Header DataThe header data of a form consist of Administration data and Basic settings.The Administration data include Administration information and Language attributes.

In the Administration information group, enter

Page 45: Sap Notebook

Form name Description Development class In the Lang. attributes (Language attributes) group, you find Original language Current language (language key) Information on the translation of the form. Status information about the current form status (active, edited, and so on).

Before entering other header data,7. Define the paragraph formats of the form.8. Define the character formats of the form.9. Return to the header and complete it.4.2.1.1 Completing the Header Data After Defining the AttributesHeader.1. Choose GotoThe Change Form Header screen appears.The Basic data include the groups Set up page and Default values for text formatting.

In the group Set up page, set defaults such as page format and page orientation. In the group Default values for text formatting, set a default paragraph, default

font, and so on.2. Enter values in accordance with the guidelines. The fields Tab stop, Page format, Orientation, Lines/inch, and Characters/inch are assigned default values by the system.3. Enter the format of the pages in the header data of the form. This format can be taken from the spool administration table using the transaction SPAD.The system always uses these values defined in the form header if no other values are specified for the paragraph and character format definition.To activate the form, you must enter the First page and the Default paragraph as Basic settings.4.2.1.2 Passing Data to an External ProgramIn the R/3 system, you can flag a form for external printing. If a form is not explicitly flagged for external printing, the system uses application-dependent settings from Customizing.To flag a form for external printingForms. Word processing 1. Choose ToolsMiscellaneous.2. In the header data, choose AttributesIn the lower part of the screen, you can now set a flag for passing data to an external program. The flag in the form then determines whether to print via the Raw Data Interface (RDI) or not. To overrule this setting, use the function module OPEN_FORM (see Raw Data Interface).4.2.2 Defining Paragraph FormatsBefore entering all header data on the Change Form Header screen, you must create the form by defining paragraph and character formats. The system sends a warning if, in the header data, you specify a paragraph or a first page that has not yet been defined.Paragraphs.1. Choose GotoThis takes you to the input screen for paragraph formats and their standard attributes.Create element.2. Choose EditA dialog box appears.3. Enter the paragraph tag and a short description.The paragraph tag is created. The system sets line spacing, alignment, and units of measurement.Font to define the font attributes for the paragraph4. Choose Attributes tags.5. Enter values in the input-enabled fields in accordance with the guidelines.You can overwrite the default font attributes.

Page 46: Sap Notebook

Tabs to specify the tab position.6. Choose GotoAn input screen appears, where you can define the required tab positions as well as the unit of measurement and the alignment. In the standard version, the alignment is set to LEFT (left-aligned).Outline to define the outline.7. Choose AttributesAdditional values are displayed that have been set by the system.8. Enter values in the input-enabled fields. You can change the values set by the system.9. Repeat the steps above until all paragraph formats are defined.4.2.3 Defining Character FormatsCharacter formats in forms determine how text is formatted within paragraphs. They are a refined form of text layout.Character strings.1. Choose GotoThis takes you to the request screen for standard attributes of character strings.Create element.2. Choose EditA dialog box appears.3. Enter a character tag and description.The character tag is created. The system sets all standard attributes to * . You can overwrite this setting.Font to define the font attributes for the character4. Choose Attributes format. Font attributes provide a more detailed definition.5. Enter values in the input-enabled fields.The fields Bold, Italics, and Underlined are automatically displayed with * . You can overwrite this with your entry.6. Repeat the definition of character tags and their standard and font attributes until all required character formats have been defined.7. Save the character formats.4.2.4 Defining PagesYou must define at least one logical page for every form. Otherwise it is not possible to format texts. To define a page, assign a name and specify attributes.Pages.1. Choose GotoCreate element.2. Choose Edit3. Enter a page name and a short description in the fields Page and Description.Input-enabled fields are displayed in the lower screen area.4. Enter values in accordance with the guidelines for page definition.You can overwrite the default values set in the fields Mode and Numbering type.5. Repeat these steps until all pages are defined.6. Save your entries.4.2.5 Defining WindowsYou must define at least one window for every form. Otherwise it is not possible to format texts. Window definition involves a list of window names and corresponding window types. Units of measurement are not taken into account here.Windows.1. Choose GotoThis takes you to the input screen for windows. A main window (MAIN) is displayed automatically. You can define a default paragraph here.Create element to add new window names and types to the2. Choose Edit list.A dialog box appears.3. Enter a window name and description.Input-enabled fields are displayed in the lower half of the screen. The field Description receives the value from the dialog box, the value for the field Window type is set by the system.By default, the system sets VAR as the window type for windows with variable contents. If you prefer another window type, simply overwrite this value.4. Make your entries or changes.

Page 47: Sap Notebook

You can define one standard paragraph per window in the field Default paragraph.5. Repeat these steps for each of your windows.6. Save your entries.

4.2.6 Using Text Elements in Page WindowsYou can define and edit text elements in windows as well as in page windows. In both cases, the text elements are assigned to the active window. You can create several text elements in a module.Text elements.1. On the screen Form: Change Page Windows choose EditThis takes you to the text editor.2. Enter the name of the text element in the text entry area by the tag column /E .3. Define one line in the text element for each line in the main window. A section of a text element is shown below:/E SPACE_LINE / /E HEADER_TEXT /: INCLUDE 'SD_RVADOR01' OBJECT TEXT ID SDVD PARAGRAPH HT /: INCLUDE OBJECT VBBK ID 0001 PARAGRAPH HT /E ITEM_HEADER IL Item,,Material,,Description IP ,,,,Quantity,,,,Price,,Price unit,,,,,,Value / &ULINE(71)& / /E ITEM_LINE IL &VBDPA-POSNR&,,&VBDPA-MATNR&,,&VBDPA-ARKTX&,,&'Customerarticlenumber 'VBDPA-IDNKD' '&&'Item 'VBDPA-POSEX&As you can see above, each line is defined individually.4. Save the window texts (text elements) and return to the Form:Change Page Windows screen.

4.2.7 Defining Page WindowsTo define a page window, allocate a logical window to a physical page and specify the position and size of the window (the window is logical, because you define it only once in the entire form by specifying name and type, but not its usage). However, the size is limited by the page format selected in the header data.Page windows.1. Choose GotoCreate element.2. Choose EditA list of defined logical windows appears.3. Select the desired window from the list.4. Enter valid values in the fields displayed in the lower half of the screen. The unit of measurement is set by the system.5. Specify the position of the selected window on the page and the dimensions of the window.6. To define page windows for the next page, you must first select the next Page Pages and select the next page. Then choose Goto page. Choose Goto windows and repeat the steps above.7. Save your form.Delete.To delete a selected element, choose Edit4.2.7.1 Filling Page Windows with Text

Page 48: Sap Notebook

When defining page windows, you can request multiple columns. Define an area on a page and specify the position of the main windows in this area, as described in Defining Main Windows in Page Windows.To fill a page window with text, you can also use text elements as described in Using Text Elements in Page Windows.

4.2.8 Using Text Elements in Page WindowsYou can define and edit text elements in windows as well as in page windows. In both cases, the text elements are assigned to the active window. You can create several text elements in a module.Text elements.1. On the screen Form: Change Page Windows choose EditThis takes you to the text editor.2. Enter the name of the text element in the text entry area by the tag column /E .3. Define one line in the text element for each line in the main window. A section of a text element is shown below:/E SPACE_LINE / /E HEADER_TEXT /: INCLUDE 'SD_RVADOR01' OBJECT TEXT ID SDVD PARAGRAPH HT /: INCLUDE OBJECT VBBK ID 0001 PARAGRAPH HT /E ITEM_HEADER IL Item,,Material,,Description IP ,,,,Quantity,,,,Price,,Price unit,,,,,,Value / &ULINE(71)& / /E ITEM_LINE IL &VBDPA-POSNR&,,&VBDPA-MATNR&,,&VBDPA-ARKTX& ,,&'Customerarticlenumber 'VBDPA-IDNKD' '&&'Item 'VBDPA-POSEX&As you can see above, each line is defined individually.4. Save the window texts (text elements) and return to the Form:Change Page Windows screen.

4.2.9 Defining Main Windows in Page WindowsMain windows in page windows allow you to format text in multiple columns. Define an area in the page window, in which to position the main windows.1. Create a page window and assign it to a page.Main windows.2. Choose EditA dialog box appears.3. Enter values in the fields Area width and Area height in accordance with the input guidelines for main windows.4. Enter values in the fields Spacing and Number in the Horizontal group if you want to use multiple columns. You can ignore the fields in the Vertical group.5. Determine how many columns and line areas are required for label printing. Then enter the corresponding values in the fields in the Horizontal and Vertical groups.The value in the field Left margin varies from main window to main window if multiple columns are used. The following applies:

Left margin of current column+ Window width+ Horizontal spacing= Left margin of next column

Page 49: Sap Notebook

In label printing, the field Upper margin also varies from main window to main window:

Upper margin of current main window+ Window height+ Vertical spacing= Upper margin of next main window6. Enter a value in the field Start position.This is a counter. Enter a starting value which is equal to or greater than 1.The main windows are added to the list.7. Save your form.

4.3 Test-Printing a FormYou can test a form without having to call the print program that uses it. Test print. SAPscript presents the print selection screen soChoose Utilities that you can pick the printer type for which the test print should be formatted.The Test print function

Displays or prints all pages and text elements that are defined in the form. Replaces system, standard, and text symbols with their current values. Program

symbols are filled with a test value, the character X.If you test print from the Form: Request screen, SAPscript uses the active version of a form for the test print. If you are currently editing a form, then SAPscript uses this edit version of the form for the test print.Under certain conditions, texts may not be printed in Test print: This is the case, for example, when the name of a text in an INCLUDE statement is defined with a program symbol.

5 Releasing FormsForms must be released for the end user. Otherwise, they are not displayed to the user.CheckChoose FormTo ensure that forms do not contain any errors, check whether all the entries have been made and whether all entries correspond to the input conventions. The status of the check is displayed in the line; the system informs you whether the check routine found any errors.If the check routine was completed without any errors, you only need to activate your form.ActivateChoose FormThe system sends a message stating whether activation was successful.If you attempt to activate your form despite the fact that an error was found during the check or a check was not run, the activation run is terminated. The form is not accessible to the end user.Forms can be processed after activation, whether this involves changes, translations, or the deletion of an unnecessary form.Delete. The system asks you whether youTo delete a form, choose Form really want to delete your form in all languages. After deletion, you return to the request screen. Your processing status is displayed in the OK line.

6 SAPscript Control CommandsThe functionality of the SAPscript editor is made available through a set of commands. These commands give you full editing control over your text. They are executed immediately when called.There is, however, another kind of SAPscript command, namely the control commands. The purpose of these is to allow control of the output formatting. These commands are not

Page 50: Sap Notebook

interpreted by the SAPscript editor, but are passed through to the SAPscript Composer for processing. The Composer is the program that converts text from the form displayed in the editor to the form used for printing. This includes, for example, line and page formatting, the replacement of symbols with their current values and the formatting of text according to the paragraph and character formats specified.

6.1 Syntax of Control CommandsSAPscript control commands are entered and edited in the text editor in the same way as a normal line of text. They do, however, differ from normal lines of text:

Enter the paragraph format /: in the format column to identify a control command.

Enter the command itself in the text line. You will notice that all key words and other parts of the specification not given as literal values enclosed in inverted commas are automatically converted to capital letters.

Make sure that a control command, together with any parameters it requires, does not occupy more than a single line.

Enter only one control command in each line. Note that the editor formatting has no effect on lines containing control

commands.If a control command is unknown or it contains syntax errors, the line containing it is treated as a comment line. It is neither interpreted nor printed.

6.2 Explicit Page Break: NEW-PAGESAPscript automatically inserts a page break when the main window of a page (MAIN) is full. You can use the NEW-PAGE command to force a page break in the text at any point you want one. The text following this command then appears on a new page. The page break is always performed (it is an unconditional page break).The NEW-PAGE command completes the current page. This means that all the windows that are still on the page are printed immediately. If you use the NEW-PAGE command without parameters, the page defined in the current form as the next page will be taken next. If, however, your form contains a number of different pages, then you can specify any one of these as the next page to be used.Syntax:/: NEW-PAGE [page_name]/: NEW-PAGE The current page will be completed and the text in the following lines will be written to the page specified in the form./: NEW-PAGE S1 As above, except that the page S1 will be taken as the next page.

If, in a NEW-PAGE command, you specify a page not contained in the form, the specification is ignored.

Take care that there are no blank lines immediately before a NEW-PAGE command. If an implicit page break occurs within the blank lines, an unexpected blank page may be printed.

6.3 Preventing Page Breaks: PROTECTYou can specify, either in the style or in the form, that a particular paragraph should not be split in two by a page break. If this page protect attribute is set, then the complete paragraph is always printed on one page. This property applies only to that particular paragraph.

Page 51: Sap Notebook

This attribute is not intended to be used to protect all paragraphs against a page break. The point is that a page break is by its very nature a dynamic event and the exact point at which it occurs depends on the current state (length and contents) of the preceding text. It is also possible that you may want to protect only certain parts of a paragraph against a page break. One way to achieve this is to use the NEW-PAGE command immediately before the text concerned starts. Explicitly beginning a new page at this point should ensure that a further page break does not occur within the text. However, this technique is not change-friendly. For example, you format your text with the help of the NEW-PAGE command so that no page breaks occur where they should not. At a later time, you insert or delete some lines. These changes cause all the subsequent text to be moved relative to the printed page, and you must check each NEW-PAGE command you previously inserted to see if it is still in the correct place.To allow you to define the areas to be protected against a page break on an individual basis, SAPscript provides the PROTECT.. ENDPROTECT command pair. If you enclose the text to be protected in these commands, then SAPscript will ensure that each line of this text is printed together on the same page. If the complete text fits in the space remaining on the current page, then it is printed on this page just as it would be if no PROTECT command had been used. If, however, the remaining space is not sufficient for the text, then the PROTECT command has the same effect as a NEW-PAGE command and text is printed on a new page.Thus the PROTECT/ENDPROTECT commands may be regarded as a kind of conditional NEW-PAGE command, the condition being whether or not the lines enclosed between the two commands fit in the space remaining in the current main window.Syntax:/: PROTECT : : /: ENDPROTECTThe text lines to be protected are enclosed between the two commands.

An ENDPROTECT command without a preceding PROTECT command has no effect.

If the terminating ENDPROTECT is missing, SAPscript assumes it at the end of the text.

PROTECT.. ENDPROTECT command pairs cannot be nested. If a second PROTECT command occurs before the first one has been terminated by an ENDPROTECT, it is ignored.

If the text enclosed by a PROTECT.. ENDPROTECT pair is itself too long for a single page, then a page break is generated immediately before the text and the text is printed in the normal way. It is then unavoidable that a page break will occur at some point within the text.

6.4 Next Main Window: NEW-WINDOWEach page can consist of up to 99 main windows. Each main window is assigned a consecutive identifying number (0..98), and the windows are filled in this order. This feature enables SAPscript to print labels and to output multi-column text. When one main window fills up, the next main window on that page is taken, if there is a next one. A page break is inserted after the last main window.You can use the NEW-WINDOW command to call the next main window explicitly, even if the current main window is not yet full. If you are in the last main window of the page, the command has the same effect as the NEW-PAGE command.Syntax:/: NEW-WINDOW

Page 52: Sap Notebook

6.5 Assigning a Value to a Text Symbol: DEFINEText symbols acquire their values as a result of explicit assignment. To  Symbols interactively assign text symbols, in the text editor choose Include Text. This method is available for all text symbols belonging to a text module as well as those of the associated form.Values defined in this way are lost when the transaction is left. If you want to print the text module again, then you must enter the symbol values again. The purpose of the DEFINE command is to provide a means of making this value assignment a permanent part of the text, so that the values are available again when the text module is called again. This command can also be used to re-assign a new value to a text symbol half-way through the text.Syntax:/: DEFINE &symbol_name& = 'value'/: DEFINE &subject& = 'Your letter of 7/3/95'The value assigned can have a maximal length of 60 characters. It may itself contain other symbols. A symbol contained within the value assigned to another symbol is not replaced with its own value at the point at which the DEFINE command is executed. Rather, this replacement is made when the symbol defined in the DEFINE command is called in the text./: DEFINE &symbol1& = 'mail' /: DEFINE &symbol2& = 'SAP&symbol1&' /: DEFINE &symbol1& = 'script' &symbol2& -> SAPscript If, however, the DEFINE command is written using the ':=' character rather than the '=' character, then any symbol contained within the value being assigned is replaced immediately with its current value. The assignment to the target symbol is made only after all symbols in the value string are replaced with their values. The total length of the value string may not exceed 80 characters. The target symbol must be a text symbol, as before./: DEFINE &symbol1& = 'mail' /: DEFINE &symbol2& := 'SAP&symbol1&' /: DEFINE &symbol1& = 'script' &symbol2& -> SAPmail

6.6 Formatting Date Fields: SET DATE MASKTo define the formatting of date fields, use the SET DATE MASK control command. Executing this command causes all subsequent date fields to be printed using the specified format.Syntax:/: SET DATE MASK = 'date_mask'In the date mask, you can use the following codes:

DD: day (two digits) DDD: day name - abbreviated DDDD: day name - written out in full MM: month (two digits) MMM: month name - abbreviated MMMM: month name - written out in full YY: year (two digits) YYYY: year (four digits) LD: day (formatted as for the L option)

Page 53: Sap Notebook

LM: month (formatted as for the L option) LY: year (formatted as for the L option)

All other characters found in a date mask are interpreted as simple text and are copied straight into the output.Assuming the current system date is March 1st, 1997./: SET DATE MASK = 'Foster City, MM/DD/YY' &DATE& -> Foster City, 03/01/97/: SET DATE MASK = 'MMMM DD, YYYY' &DATE& -> March 01, 1997 The date mask may be reset to the default setting by using an empty string:/: SET DATE MASK = ' 'The abbreviated and full forms of the names of the days and months are stored in the language dependent TTDTG table under the following keys:

%%SAPSCRIPT_DDD_dd: abbreviated day name %%SAPSCRIPT_DDDD_dd: full form of day name %%SAPSCRIPT_MMM_mm: abbreviated month name %%SAPSCRIPT_MMMM_mm: full form of month name

dd: day number 01 = Monday,..., 07 = Sundaymm: month number 01 = January,..., 12 = December

6.7 Formatting Time Fields: SET TIME MASKTo format time fields to your needs, use the SET TIME MASK control command. Executing this command causes all subsequent time fields to be printed using the specified format.Syntax:/: SET TIME MASK = 'time_mask'In the time mask, you can use the following codes:

HH hours (two digits) MM minutes (two digits) SS seconds (two digits)

All other characters found in a time mask are interpreted as simple text and are copied straight into the output.Assuming the current time is 10:08:12,/: SET TIME MASK = 'HH:MM'&TIME& -> 10:08/: SET TIME MASK = 'HH hours MM minutes' &TIME& -> 10 hours 08 minutesThe time mask may be reset to the default setting by using an empty string:/: SET TIME MASK = ' '

6.8 Country-Dependent Formatting: SET COUNTRYThe formatting for certain field types depends on the country settings. These field types include, for example, date fields and number fields that include either a decimal point or the ‘thousands’ separator character. The formatting options defined in the user master record are usually the ones used here. To choose a formatting option other than the one specified in the user master record, use the SET COUNTRY control command. The country-dependent formatting options are stored in the T005X table.Syntax:/: SET COUNTRY country_keyYou can enter the country key either as a literal value enclosed in quotes or as a symbol./: SET COUNTRY 'CAN' /: SET COUNTRY &country_key&Use a blank country name to revert to the setting found in the user master record:/: SET COUNTRY ' '

Page 54: Sap Notebook

This SAPscript command actually calls the corresponding ABAP command internally. This guarantees the effect of the SAPscript command to be identical with that of the ABAP command.If the formatting turns out not to be as required, then you should check the settings in table T005X.

6.9 Position of the Leading Sign: SET SIGNThe usual convention in business applications is to show the leading sign to the right of the figure to which it applies. However, it is sometimes necessary to show the leading sign to the left of the figure. To set the sign explicitly, use the SET SIGN control command. Executing this command affects the formatting of all subsequent program symbols that possess a leading sign.Syntax:/: SET SIGN LEFTThe leading sign appears to the left of the number./: SET SIGN RIGHTThe leading sign appears to the right of the number.

6.10 Initializing Numbered Paragraphs: RESETTo reset the numbering of an outline paragraph to its initial value, use the RESET control command. If you do not use the RESET command, then the numbering of all outline paragraphs in a text is continuous. If you specify the name of an outline paragraph in the RESET command, then its paragraph numbering and that of subordinate paragraphs is reinitialized.Syntax:/: RESET paragraph_formatThe paragraph format specifies the outline paragraph to be reset.Assume that the paragraph N1 is defined in the style you are using. This kind of paragraph is intended for enumerated lists and causes a sequential number to be printed.* Proceed as follows if you want to work with the SAP R/3 system: N1 Ensure that you have a PC N1 Switch the PC on N1 Click on the SAP icon using the mouse. * You will then enter the SAP logon screen. In order to log on here, you must carry out the following actions: /: RESET N1 N1 Enter your user name N1 Enter your password N1 Select the application you want to useThis text specification would be output as follows:Proceed as follows if you want to work with the SAP R/3 system: 1. Ensure that you have a PC 2. Switch the PC on 3. Click on the SAP icon using the mouse.You will then enter the SAP logon screen. In order to log on here, you must carry out the following actions: 1. Enter your user name 2. Enter your password 3. Select the application you want to useIf there is no RESET command between the two sections, then the two lists would be numbered in a single sequence:Proceed as follows if you want to work with the SAP R/3 system:1. Ensure that you have a PC 2. Switch the PC on 3. Click on the SAP icon using the mouse.

Page 55: Sap Notebook

You will then enter the SAP logon screen. In order to log on here, you must carry out the following actions: 4. Enter your user name 5. Enter your password 6. Select the application you want to use

6.11 Including Other Texts: INCLUDETo include the contents of another text into the current text, use the INCLUDE control command. SAPscript still treats the text to be included as a separate text. The text is copied over only at the point at which the output is formatted.Thus the use of the INCLUDE command always ensures that the most current version of a text is included into the output, since the text is not read and inserted until the output is formatted.Syntax:/: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l] [PARAGRAPH p] [NEW-PARAGRAPH np]You must specify the name of the text to be inserted. It can be up to 70 characters long. If the name of the text contains spaces, then you must enclose it in quotes as a literal value. You can, alternatively, specify the name via a symbol. All remaining parameters in the INCLUDE command are optional. If an optional parameter is not specified, then SAPscript uses default values as applicable for the calling environment./: INCLUDE MYTEXT The text MYTEXT is included in the language of the calling text./: INCLUDE MYTEXT LANGUAGE 'E' PARAGRAPH 'A1'The text with the name MYTEXT and the language E is included, regardless of the language of the calling text. The paragraph format A1 will be used as the standard paragraph type for this call.Optional parameters:

LANGUAGEIf this parameter is not specified, then the language of the calling text or the form language are used for the text to be included. If the language is specified, then the text will be fetched in this language, regardless of the language of the calling text.

PARAGRAPHThe text to be included is formatted using the style allocated. The PARAGRAPH parameter can be used to redefine the standard paragraph for this style for the current call. All *-paragraphs in the included text will then be formatted using the paragraph specified here.

NEW-PARAGRAPHThe first line of the text to be included will be given this format indicator, as long as it is not a comment or command line. If the optional PARAGRAPH parameter (see above) is not specified, then all *-paragraphs of the included text will also be formatted using the paragraph specified in the NEW-PARAGRAPH command.

OBJECTIn order to completely specify a text, information about the text object is also required. There are a number of restrictions and other rules that depend on the object type of the calling text:

Any kind of text can be included in a form. If no object is specified, then TEXT will be used (standard texts).

In the case of a document text (DOKU object), you can include only document texts. This object type is also assumed if no object is specified in this environment.

Page 56: Sap Notebook

Only hypertexts and document texts can be included in a hypertext (DSYS object). If the OBJECT parameter is missing, then DSYS is used as the default value.

In the other kinds of text you can include only standard texts (TEXT object), document texts or hypertexts. If there is no specification, then the default object is TEXT.

IDThe text ID is a part of the text key, which permits further text objects within a given object. If no ID is specified, then the default include ID is used from the TTXID table for the calling text. If there is no entry in this table, then the text ID of the calling text is used.The following consistency check is applied both to the ID and the object:

All text IDs are allowed in a form. In document texts, only document texts may be included that have text IDs TX

(general texts) or UO (authorization objects) and also other document texts with the same text ID as the calling document text.

In DSYS texts, all DSYS texts can be included, whatever ID they have. Document texts to be included must have one of the IDs TX or UO.

Into the other texts, standard texts with any allowable text ID, DSYS texts with all IDs, and document texts with the IDs TX and UO can be included.

The INCLUDE command returns a status code in the SAPSCRIPT-SUBRC symbol: 0: the text include was successful. 1: the command could not be executed because it contained syntax errors. 2: the rules governing the text to be included were not followed (see above).

This value cannot occur if the command is used in a SAPscript form. 4: the specified text could not be found.

6.12 Changing the Style: STYLEThe STYLE control command allows you to change the style within a text. The new style is in force until another STYLE command is issued. If you specify * as the name of the style, then the system reverts to the original style.Syntax:/: STYLE style [DOMINANT]/: STYLE *A style set with this command has no effect in a text included with INCLUDE. The system takes the paragraph and character formats from the calling text. To use the style set with STYLE in the INCLUDE text as well, you must add DOMINANT to the command.If the INCLUDE text has a style assigned to it, in both cases, the system always takes the paragraph and character formats from the directly assigned style.

6.13 Formatting Addresses: ADDRESSThe ADDRESS - ENDADDRESS control command formats an address according to the postal convention of the recipient country defined in the COUNTRY parameter. The reference fields are described in the structures ADRS1, ADRS2, or ADRS3, depending on the type of address. Either direct values or symbols may be assigned to the parameters.Syntax:/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [LINES l] /: TITLE title /: NAME name1[,name2[,name3[,name4]]] /: PERSON name of natural person [TITLE form of address]/: PERSONNUMBER number of the personen/: DEPARTMENT department/: STREET street name HOUSE house number

Page 57: Sap Notebook

/: LOCATION additional location information/: POBOX po box [CODE post code / zip code] [CITY city]/: POSTCODE post code / zip_code /: CITY city1[,city2] /: NO_UPPERCASE_FOR_CITY/: REGION county / state /: COUNTRY recipient country [LANGUAGE language code]/: COUNTRY_IN_REC_LANG /: LANG_FOR_COUNTRY language key/: FROMCOUNTRY sender country /: ADDRESSNUMBER address number/: ENDADDRESSThe parameter values contain both formatting and address information. The address data are formatted for output according to the data in the following parameters:

TYPE FROMCOUNTRY COUNTRY LANGUAGE PRIORITY DELIVERY LINES

For more information, see the documentation for the SAP function module ADDRESS_INTO_PRINTFORM.If DELIVERY is not specified and if a POBOX is specified, then the POBOX is used in an address instead of a STREET.6.13.1 Parameters

DELIVERYMeans that the address should be formatted as a complete delivery address, using the street name and number rather than the P.O. Box.

TYPESpecifies the type of address.

The following types are possible: 1. Normal address (ADRS1). This is the address of a company or organization. It corresponds to the address structure that is expected in most SAP applications. 2. Private or personal address (ADRS2). This is the address of a natural person, a private or home address. 3. Company addressDienstadresse (ADRS3) with contact person. This is the address of a colleague or contact within a company or organization. The company name should be specified in the TITLE and NAME fields; the ATTN: contact person should be named in PERSON and TITLE.Should you enter another address type or leave the field blank, then type 1 is used for formatting.

PARAGRAPHSpecifies the paragraph format to be used for outputting the address. If this parameter is not given, the address will be output using the default paragraph format.

PRIORITYSpecifies which of the address lines may be omitted should this be necessary. Any combination of the following codes may be specified. The order in which you list the codes determines the order in which address lines are left out.

The codes are as follows: A Title P Mandatory empty line 4 Name4 3 Name3 R Region T Neighborhood, administrative section of a city (CITY2)l D Department L Country name C Post code or zip code 2 Name2 B P.O. Box (Japan only) S Street name and number or

Page 58: Sap Notebook

P.O. Box, depending upon DELIVERY parameter N Name and form of address of natural person (PERSON and TITLE) I Location information in LOCATION O City

LINESSpecifies how many lines may be used for formatting the address. If there are too few lines available to allow all the address data to be formatted, then the data specified in the PRIORITY parameter are omitted. If there is no LINES parameter and if this command is in a form window of a type other than MAIN, then the number of lines available for formatting the address are automatically calculated based on the current output position and the size of the window.

TITLETitle or form of address. Used only with addresses of types 1 and 3.

NAMEUp to four names may be given, separated by commas. Used only with addresses of types 1 and 3.

PERSONName of the addressee. Used only for addresses of type 2 (private or personal address) or type 3 (company contact address). In type 3 addresses, use PERSON for the name of your contact person: ‘Attn: Mr. Jeffries’. The name fields should be used for the company address.

PERSONNUMBERPersonal number. Can be used only for address types 2 or 3 (private or personal address).

TITLE (with PERSON)Title of the addressee. Can be used only for address types 2 or type 3 (private or personal address).

DEPARTMENTDepartment of the addressee. Can be used only for address type 3 (company address).

STREETStreet name.

HOUSEHouse number for the corresponding street.

LOCATIONAdditional location information, such as the building, "Upstairs Apartment" and so on. Appears on its own line in the address.

POBOXP. O. Box

CODEThe post code / zip code of the P. O. Box if this differs from the post code / zip code of the recipient.

CITYThe city in which the destination P.O. Box is located if this differs from the city of the recipient.

POSTCODEPost code / zip code of the recipient.

CITYAddressee’s city. city1 is expected to be the city; city2 is the neighborhood or administrative section, if required.

Page 59: Sap Notebook

NO_UPPERCASE_FOR_CITYDefault = NO_UPPERCASE_FOR_CITY ‘ ‘Usually, the system prints the city and country names of foreign addresses in uppercase ( NO_UPPERCASE_FOR_CITY ‘ ‘ ).You can use this parameter to force the system to output city and country name unchanged (uppercase/lowercase).( NO_UPPERCASE_FOR_CITY ‘X’ )

REGIONThis allows an administrative region, county, province, or state etc. to be specified.

COUNTRYSpecifies the recipient country, i.e. the country according to whose postal conventions the address is to be formatted.

COUNTRY_IN_REC_LANGThis flag tells the system to use the recipient language for the country name.( COUNTRY_IN_REC_LANG ‘X‘ Recipient language is not used: COUNTRY_IN_REC_LANG ‘ ‘ )Default:

LANG_FOR_COUNTRYDefault = SpaceUse this parameter to explicitly set the language in which to print the country name of a foreign address. By default, the system uses the language of the sending country.

LANGUAGELanguage code of the language of the recipient country, if it differs from that of the recipient COUNTRY. Example: addresses in Switzerland. Standard SAP language codes are used; you can display these in the initial SAPscript text processing screen or in table T002.

FROMCOUNTRYSpecifies the language to be used for formatting the name of the recipient country. For most European countries, the recipient country is specified by placing the international car registration letters in front of the post code and separating them from the post code with a hyphen. You must always specify the sender country.

ADDRESSNUMBERThe number is used to index a central address file, from which the desired address is read instead of using the set of the above fields. You can find more information on this facility in the documentation for the function module ADDRESS_INTO_PRINTFORM.

You use this one parameter instead of the set of parameters described before./: ADDRESS /: TITLE 'Firma' /: NAME 'Schneider & Co', 'Finanzberatung' /: STREET 'Kapitalgasse 33' /: POBOX '12345' CODE '68499' /: POSTCODE '68309' /: CITY 'Mannheim' /: COUNTRY 'DE' /: FROMCOUNTRY 'DE' /: ENDADDRESS This produces the following output address:Firma Schneider & Co

Page 60: Sap Notebook

Finanzberatung Postfach 12345 68499 MannheimIf the DELIVERY parameter is specified on the ADDRESS command, then the street name and number will appear in the address in place of the P. O. Box number.Firma Schneider & Co Finanzberatung Kapitalgasse 33 68309 MannheimSAPscript makes an internal call to the ADDRESS_INTO_PRINTFORM function module for formatting the address. If the result is not as expected, you should check the settings for this function module (see the function module documentation).Setting a Header Text in the Main Window: TOP You can use the TOP.. ENDTOP control command to specify lines of text that you want to print always at the top of the main window. These text lines are also known as header texts. For example, you would use header texts in the case of a very long table covering several pages of output to ensure that the table heading information were repeated at the start of each new page of output. Syntax:/: TOP: : /: ENDTOPThe lines of text enclosed between the two control commands will be output from now on at the start of the main window.An existing header text can be disabled by using the TOP.. ENDTOP command pair without enclosing any text lines between the two command lines:/: TOP /: ENDTOPSubsequent pages will contain no header text.

If the main window already contains some output then a newly specified header text takes effect on the next page only.

The same applies to the deletion of a header text. If a header text has already been output on the current page then it cannot be retracted.

Header texts should not be employed in texts that are printed from applications programs, such as reminder texts, order texts. These applications programs can also work with header texts via the form interface, which may lead to unexpected results.

6.14 Setting a Footer Text in the Main Window: BOTTOMYou can specify footer texts for the main window in a similar way to header texts. Footer texts are always printed at the bottom of the window.Syntax:/: BOTTOM : : /: ENDBOTTOMThe lines of text enclosed between the two control commands will be output from now on at the bottom of the main window.An existing footer text can be disabled by using the BOTTOM.. ENDBOTTOM command pair without enclosing any text lines between the two command lines:/: BOTTOM /: ENDBOTTOM

Page 61: Sap Notebook

This and subsequent pages will contain no footer text. Assuming there is still sufficient space in the main window, a newly specified

footer text will also be printed on the current page. Footer texts should not be employed in texts that are printed from applications

programs, such as reminder texts, order texts. These applications programs can also work with footer texts via the form interface, which may lead to unexpected results.

6.15 Conditional Text: IFYou can use the IF control command to specify that text lines should be printed only when certain conditions are met. If the logical expression contained within the IF command is true, then the text lines enclosed by the IF... ENDIF command pair are printed. Otherwise they are ignored.Syntax:/: IF condition : : /: ENDIFThe logical expression can use the following comparison operators:= EQ equal to<>

> GT greater than

<= LE less than or equal to

>= GE greater than or equal to

<> NE not equal to

The following logical operators can be used to combine conditions:

NOT

AND

OR

Evaluation of both the individual logical expressions and of the combinations of expressions is performed strictly from left to right. There are no precedence rules. Bracketed expressions are not supported.

The comparison is always performed on literal values, that is, the symbols are formatted as character strings before they are compared. This is particularly significant in the case of program symbols, because the formatting of these may depend on various parameters. For example, the formatted form of a currency field

Page 62: Sap Notebook

employs a variable number of decimal places and a variable ‘decimal point’ symbol (a period or a comma) depending on the applicable currency key.

You can extend the IF command with the ELSE command to allow text lines to be specified that you want to print in case the condition is false. If the condition is true, the text lines enclosed by the IF and ELSE commands are formatted; otherwise the text lines enclosed by the ELSE and ENDIF commands are formatted.

Syntax:

/: IF condition

:

/: ELSE

:

/: ENDIF

The ELSEIF command allows you to specify multiple cases.

Syntax:

/: IF condition

:

/: ELSEIF condition

:

/: ELSE

:

/: ENDIF

You can use any number of ELSEIF commands within one compound IF.. ENDIF control command. The use of an ELSE command is then optional.

You must not extend a condition over more than one line. Both the IF or ELSEIF command and the attached condition must be completely contained within a single line.

You can nest IF commands.

Page 63: Sap Notebook

You must terminate an IF command with an ENDIF command. If you forget this, there will be no more output following the IF command if the condition is false.

If a syntax error occurs in the interpretation of this command, then the command is not executed. This may have an unexpected effect on the subsequent text output. For example, if the IF statement is incorrect, then all following ELSEIF and ELSE commands will be ignored, since the opening IF command is ‘missing’. This will cause all the text lines attached to the ELSEIF and ELSE commands to be printed.

6.16 Finding a Match: CASE

The CASE command covers a special case of the multiple case IF command. Rather than allowing an arbitrary condition to be tested in each of the individual cases (as in the general multiple case IF command), the CASE command allows a given symbol to be tested against specific values until a matching value is found.

Syntax:

/: CASE symbol

/: WHEN value1

:

/: WHEN value2

:

/: WHEN valuen

:

/: WHEN OTHERS.

:

/: ENDCASE

The symbol in the CASE line is formatted. If its value is found in one of the WHEN lines, then the text lines following this WHEN line are printed. If no matching value is found then the text lines enclosed by the WHEN OTHERS line and the ENDCASE command are printed. The WHEN OTHERS section is optional.

As with the IF command, the comparison is always performed on literal values.

Page 64: Sap Notebook

A CASE command must be terminated by an ENDCASE command.

The WHEN OTHERS section is optional.

6.17 Calling ABAP Subroutines: PERFORM

You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.

PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.

Syntax in a form window:

/: PERFORM

IN PROGRAM

/: USING &INVAR1&

/: USING &INVAR2&

......

/: CHANGING &OUTVAR1&

/: CHANGING &OUTVAR2&

......

/: ENDPERFORM

INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

Page 65: Sap Notebook

OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.

The ABAP subroutine called via the command line stated above must be defined in the ABAP report prog as follows:

FORM TABLES IN_TAB STRUCTURE ITCSY

OUT_TAB STRUCTURE ITCSY.

...

ENDFORM.

The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.

The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.

From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (‘First page’, ‘Next page’, ‘Last page’) is printed as local variable symbol.

Definition in the SAPscript form:

/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO

/: USING &PAGE&

/: USING &NEXTPAGE&

/: CHANGING &BARCODE&

/: ENDPERFORM

/

/ &BARCODE&

Coding of the calling ABAP program:

REPORT QCJPERFO.

Page 66: Sap Notebook

FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

DATA: PAGNUM LIKE SY-TABIX, "page number

NEXTPAGE LIKE SY-TABIX. "number of next page

READ TABLE IN_PAR WITH KEY ‘PAGE’.

CHECK SY-SUBRC = 0.

PAGNUM = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.

CHECK SY-SUBRC = 0.

NEXTPAGE = IN_PAR-VALUE.

READ TABLE IN_PAR WITH KEY ‘BARCODE’.

CHECK SY-SUBRC = 0.

IF PAGNUM = 1.

OUT_PAR-VALUE = ‘|’. "First page

ELSE.

OUT_PAR-VALUE = ‘||’. "Next page

ENDIF.

IF NEXTPAGE = 0.

OUT_PAR-VALUE+2 = ‘L’. "Flag: last page

ENDIF.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDFORM.

6.18 Inserting Print Controls: PRINT-CONTROL

You can use this command to call certain printer functions from a SAPscript text. Although you cannot enter control characters for the printer directly in your text, you can define a print control via the spool maintenance transaction SPAD that contains the printer commands you want. You can then call a print control using the PRINT-CONTROL SAPscript command.

Page 67: Sap Notebook

Syntax:

/: PRINT-CONTROL name

Specify the name of the print control either with or without inverted commas.

The print control printed via PRINT-CONTROL should always be a print control created in the customer name area (Zxxx) for the device type used. Use no Sxxx print controls, since their contents may be changed by SAP at any time with a release or driver modification. To modify SAP device types, refer to Note 3166.

The printer commands in the print control must never effect the current printer settings, since the SAPscript printer driver has no information on any changes triggered by a print control, which would have to be undone by commands of the driver itself. The printer driver assumes that the print control has no effect on any texts or graphics printed afterwards.

Never use PRINT-CONTROL to control print attributes covered by the SAPscript driver. To change such print attributes, use the usual method of defining form and style and the device type accordingly.

The contents of the print control called are transparent to SAPscript. SAPscript cannot check whether the printer commands contained in the control are correct. Therefore, if you experience problems when printing a text containing these commands, you should first try to print the text without the print controls. Then, reintroduce the PRINT-CONTROL commands one by one until the command causing the problem is identified.

You should ensure that the printer control sequences you define leave the printer afterwards in a well-defined state. SAPscript assumes that after completing each text output certain settings (for example, font, current page) are still valid for subsequent printing. If your printer commands change these settings without resetting them again afterwards, the results may be unpredictable.

After executing a PRINT-CONTROL command, SAPscript inserts a space character at the start of the next text line. If you do not want this, you should give this text line the '=' paragraph format.

6.19 Boxes, Lines, Shading: BOX, POSITION, SIZE

Page 68: Sap Notebook

Use the BOX, POSITION, and SIZE commands for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading.

The SAP printer drivers that are based on page-oriented printers (the HP LaserJet driver HPL2, the Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when printing. Line printers and page-oriented printers not supported in the standard ignore these commands. You can view the resulting printer output in the SAPscript print preview.

Syntax:

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

BOX Command

Syntax

/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]

Effect: draws a box of the specified size at the specified position.

Parameters: For each of XPOS, YPOS, WIDTH, HEIGHT, and FRAME, you must specify both a measurement and a unit of measurement. Specify the INTENSITY parameter as a percentage between 0 and 100.

XPOS, YPOS

Upper left corner of the box, relative to the values of the POSITION command.

Default: Values specified in the POSITION command.

The following calculation is performed internally to determine the absolute output position of a box on the page:

X(abs) = XORIGIN + XPOS

Y(abs) = YORIGIN + YPOS

Page 69: Sap Notebook

WIDTH

Width of the box. Default: WIDTH value of the SIZE command.

HEIGHT

Height of the box. Default: HEIGHT value of the SIZE command.

FRAME

Thickness of frame.

Default: 0 (no frame).

INTENSITY

Grayscale of box contents as %.

Default: 100 (full black)

Measurements: You must specify decimal numbers as literal values (like ABAP numeric constants) by enclosing them in inverted commas. Use the period as the decimal point character. See also the examples listed below.

Units of measurement: The following units of measurement may be used:

TW (twip)

PT (point)

IN (inch)

MM (millimeter)

CM (centimeter)

LN (line)

CH (character).

Page 70: Sap Notebook

The following conversion factors apply:

1 TW = 1/20 PT

1 PT = 1/72 IN

1 IN = 2.54 CM

1 CM = 10 MM

1 CH = height of a character relative to the CPI specification in the form header

1 LN = height of a line relative to the LPI specification in the form header

/: BOX FRAME 10 TW

Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT).

/: BOX INTENSITY 10

Fills the window background with shading having a gray scale of 10 %.

/: BOX HEIGHT 0 TW FRAME 10 TW

Draws a horizontal line across the complete top edge of the window.

/: BOX WIDTH 0 TW FRAME 10 TW

Draws a vertical line along the complete height of the left hand edge of the window.

/: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15

/: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

/: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW

Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.

Page 71: Sap Notebook

6.19.2 POSITION Command

Syntax

/: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]

Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started, the POSITION value is set to refer to the upper left corner of the window (default setting).

Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words, as a value that specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.

XORIGIN, YORIGIN

Origin of the coordinate system.

WINDOW

Sets the values for the left and upper edges to match those of the current window (default setting).

PAGE

Sets the values for the left and upper edges to match those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).

/: POSITION WINDOW

Sets the origin for the coordinate system to the upper left corner of the window.

/: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'

Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page.

/: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM

Page 72: Sap Notebook

Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.

6.19.3 SIZE Command

Syntax

/: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started, the SIZE value is set to the same values as the window itself (default setting).

Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.

WIDTH, HEIGHT

Dimensions of the rectangle or line.

WINDOW

Sets the values for the width and height to the values of the current window (default setting).

PAGE

Sets the values for the width and height to the values of the current output page.

/: SIZE WINDOW

Sets WIDTH and HEIGHT to the current window dimensions.

/: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM

Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.

/: POSITION WINDOW

/: POSITION XORIGIN -20 TW YORIGIN -20 TW

Page 73: Sap Notebook

/: SIZE WIDTH +40 TW HEIGHT +40 TW

/: BOX FRAME 10 TW

A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.

6.20 Hexadecimal Data: HEX, ENDHEX

Use this command to send printer commands in a printer language directly to a printer that supports that language. SAPscript does not interpret the data enclosed by the HEX and ENDHEX command pair, but inserts it unchanged into the output stream. This technique allows objects with a pixel-oriented format (for example, graphics) to be printed as part of a SAPscript text. The HEX and ENDHEX command pair enclose the printer commands and data as hexadecimal text, so that the printer formatting routines interpret each successive pair of characters as a single hexadecimal value in the range of 0 to 255. The characters 0 to 9 and A to F for representing the values 10 to 15 are valid hexadecimal characters. The text may also include comment lines (these begin with /* in the format column), which will not be interpreted as hexadecimal data but are simply passed over by the formatting routines.

Syntax:

/: HEX [TYPE printer_language]

The HEX command denotes the start of the hexadecimal data. Subsequent text lines are interpreted as described above. If the TYPE parameter is present, the data will be sent to the printer only if the printer understands the specified printer language. The following printer languages are currently supported: POST (Postscript), PRES (Kyocera Prescribe) and PCL (HP Printer Control Language).

/: HEX [TYPE printer_language] [XPOS x_position] [YPOS y_position]

The output cursor is set to the absolute position indicated by the specified X and Y position parameters before the hexadecimal data is printed. If either the X or the Y position is not specified, then 0 will be assumed for this parameter.

/: HEX [TYPE printer_language] [HEIGHT height] [LEFT left_indentation]

The HEIGHT parameter determines the amount of space to be reserved on the page for the output of the hexadecimal data. Any text following the ENDHEX command will be printed below this point. If the LEFT parameter is also specified, then the output of the hexadecimal data will is indented from the left margin by the specified amount.

Page 74: Sap Notebook

/: HEX TYPE PCL HEIGHT '7.5' CM LEFT '2.25' CM

/* Creator: report ZQVNTE30 date 19940705 time 125129 user SAPSCRIPT

/= 1B2A7230461B2A743735521B2A7231411B2A62304D1B2A62343057FFFFFFFFFFFF

/= FF1B2A62343057FFFFFFFFFFFFC0007D00DFC0F7D0000000000000000000000017

/: ENDHEX

This data is printed only by an HP PCL printer (fro example, HP LaserJet). 7.5 cm of space is allocated on the page for the output of the data and the output cursor is indented 2.25 cm to the right of the form window edge.

You can use the RSTXLDMC program to upload correctly formatted pixel data to the R/3 system and to prepare it as a HEX-ENDHEX control command. This can then be saved as normal SAPscript text.

6.21 Summing a Program Symbol: SUMMING

The SUMMING command is used for accumulating a total value for a program symbol. The command should be specified just once. Then, each time the specified program symbol is formatted, its current value is added into the total symbol. Several program symbols may all be added into a single total symbol.

Syntax:

/: SUMMING program_symbol INTO total_symbol

SAPscript cannot create the field for the total dynamically. The symbol used must be defined in a TABLES structure in the calling program.

For details on summing and carrying forward, see Summing and Carrying Forward is Incorrect.

6.21.1 Summing and Carrying Forward is Incorrect

Assume that for a multiple-page invoice, you want to print the current total as carry forward amount or subtotal on the current page and on the subsequent page. However, the carry forward amount is incorrect or missing.

The following causes are possible:

Page 75: Sap Notebook

You do not use program symbols with Dictionary reference for totalling.

You place the carry forward amount into the BOTTOM area. SAPscript processes the BOTTOM area at the beginning of a page; therefore it is not suited for carry forward amounts.

If you place the carry forwards amount into the TOP area of the main window on the subsequent page, the carry forward amount may be higher than it should be: This happens if the last part of text of the previous page does not fit onto the page, but the text is held together, for example, by a PROTECT command. In this case, a local text symbol must receive the carry forward amount.

You must place the carry forward amount on the current page into a window of type VAR. On the subsequent page, use a local text symbol to print the amount in the TOP area of the main window: 1. At the beginning of the form main text (before printing the first text element), define the amount variable and the total variable (both must be program symbols or Dictionary amount fields). In the example below, we use the SUMMING command to determine that for each output of &SUMTAB-AMOUNT& the system automatically sums up the amount in the total variable &SUMTAB-TOTAL&. At the end of the page, &SUMTAB-TOTAL& contains the carry forward amount of the current page or the grand total, respectively. In this example, we also define a local symbol &LASTPAGE& to print the grand total on the last page.

/: SUMMING &SUMTAB-AMOUNT& INTO &SUMTAB-TOTAL&

/: DEFINE &LASTPAGE& = ‘ ‘

2. At the end of the form main text (when printing the last text element of the main window), set the local textsymbol &LASTPAGE& to a different value, such as ‘X’:

/: DEFINE &LASTPAGE& = ‘X’

3. To print the carry forward amount in the TOP area of the subsequent page including the pre-text 'Carry forward' and a tab, we use the local text symbol &CARRY. The corresponding text element is also defined in the main window:

/E CARRY

* &’Carry forward:,,’CARRY&

(CALL FUNCTION WRITE_FORM EXPORTING ELEMENT = ‘CARRY’ TYPE = ‘TOP’)

Page 76: Sap Notebook

4. Define the carry forward window on the current page as type VAR and position it at the end of the main window of the page. Print the carry forward amount there and define the local text symbol &CARRY& to print the amount again in the TOP area of the subsequent page. Use the local text symbol &LASTPAGE& to print the grand total on the last page. The carry forward window then contains the following text (define it as paragraph T1 with tab):

/: IF &LASTPAGE& = ‘X’

T1 Grand total:,,&SUMTAB-TOTAL&

/: ELSE

T1 Carry forward:,,&SUMTAB-TOTAL&

/: DEFINE &CARRY& = &SUMTAB-TOTAL&

/: ENDIF

7 SAPscript Symbols

Text in the SAP system does not usually exist independently of other objects, but often contains a reference to some other stored object. For example, for a letter this could be the address data in the vendor master record or information in the material master record that is to be included in a purchase order text. You solve this problem by using placeholders for the data rather than entering the actual values into the text. Thus, you can create flexible text modules by using these placeholders at all points where the text needs to be variable. Since much of the data to be inserted in the text reflects the contents of fields in SAP tables, this technique ensures that the text modules always contain the current values of these fields when printed.

In SAPscript, these placeholders are known as symbols. They represent data that will not be added to the text until a later point. This is normally the point at which the output is formatted. All symbols occurring in the text are then replaced with their current values. This replacement is performed only in the output text. The original version of the text module is unaffected.

SAPscript recognizes four different kinds of symbols:

Page 77: Sap Notebook

System symbols

Standard symbols

Program symbols

Text symbols.

The main difference between these is the source of their values. SAPscript provides values for the system symbols. Standard symbols and their values are defined in the TTDTG table. Program symbols represent data supplied by the program that is currently executing. The values for text symbols come either from control commands in the text itself or are supplied dynamically by the Include function in the text editor.

SAPscript automatically recognizes the type of a symbol. First of all, it checks whether the symbol is a system symbol. If not, then it checks whether the symbol name is defined in the data area of the calling program. In this case, it is a program symbol. Otherwise, SAPscript reads table TTDTG. If the symbol is found in this table, then it is a standard symbol. If a symbol is neither a system symbol nor a program symbol nor a standard symbol, then it is a text symbol.

7.1 Syntax of Symbols

Each symbol has a name that is used when the symbol is called. A call to a symbol is normally made in a line of text that also includes other kinds of text. Therefore it is necessary that symbols can be distinguished from normal text, and that the call is structured in such a way that it is possible to identify it as a call to a symbol.

Use the delimiter & both immediately before and after the symbol.

Do not use blank characters in the name of a symbol. Moreover, since the characters '+() are used for defining formatting options, you must not use any of these a symbol name either.

Make sure that no SAPscript editor line break occurs between the symbol delimiters. If necessary, use a long line to avoid this (paragraph format = or /=).

Enclose additional formatting options in round brackets and insert them immediately after the symbol name. The code letters identifying these options must be given in capitals.

Page 78: Sap Notebook

A string that does not satisfy all the above conditions is not interpreted as a symbol but is copied directly into the output text.

Examples of valid symbols:

&symbol&

&MY_symbol&

&KNA1-NAME1&

&DATE&

&KNA1-UMSAT(I)&

Examples of invalid symbols:

&mysymbol closing delimiter missing

&my symbol& name contains blanks

&mysymbol)& name contains an invalid character

&symbol(Z& closing bracket of formatting option missing

&KNA1-UMSAT(i)& formatting option not in capitals

The symbol names themselves are not case-sensitive, that is, SAP script does not distinguish between capital and lower case letters in symbol names. These symbol names are identical:

&mysymbol&

&Mysymbol&

&MYSYMBOL&

A symbol name can contain a maximum of 130 characters. However, only the first 32 characters are used for unique identification.

7.2 System Symbols

You can use system symbols in all kinds of text. SAPscript supplies the values for system symbols. The names of the system symbols are fixed.

7.2.1 Current Date

Page 79: Sap Notebook

&DATE&

The current date is displayed. It is formatted according to the specifications found in the user master data. You can adapt this format to your own requirements by specifying a date mask (SET DATE MASK) or by using a country-specific formatting option (SET COUNTRY).

The current value for this symbol is taken from the SY-DATUM field. This value is not copied every time that the date is called, but only at the following times:

When printing starts (OPEN_FORM, PRINT_TEXT)

When symbols are replaced in the text editor

When a text is exported in the ASCII or RTF format

When the TEXT_SYMBOL_REPLACE function module is called (optional)

7.2.2 Current Day Number

&DAY&

The current day number is printed. The display includes leading zeros.

7.2.3 Current Month Number

&MONTH&

The current month number is printed. The display includes leading zeros.

7.2.4 Current Year Number

&YEAR&

This symbol is used to print the current year as a four digit number.

7.2.5 Current Day Name (Long Form)

&NAME_OF_DAY&

Page 80: Sap Notebook

The name of the current day is written out in full. The language used for the output is determined by the appropriate text language or form language. The names of the days are stored in the TTDTG table under the key %%SAPSCRIPT_DDDD_dd, where dd is the day number (01= Monday,.., 07 = Sunday).

7.2.6 Current Month Name (Long Form)

&NAME_OF_MONTH&

The name of the current month is written out in full. The language used for the output is determined by the appropriate text language or form language. The names of the months are stored in the TTDTG table under the key %%SAPSCRIPT_MMMM_mm, where mm is the month number (01,.., 12).

7.2.7 Current Time

&TIME&

The current time is printed in the form hours:minutes:seconds. Each of the components for hours, minutes, and seconds consists of two digits, using a leading zero if necessary. You can adapt this format to your own requirements by specifying a time mask (SET TIME MASK).

The value for the time field is taken from the SY-UZEIT field. This value can be copied over only at particular times (c.f. DATE ).

7.2.8 Hours Component of Current Time

&HOURS&

The component of the current time referring to hours is printed. The display includes leading zeros.

7.2.9 Minutes Component of Current Time

&MINUTES&

The component of the current time referring to minutes is printed. The display includes leading zeros.

Page 81: Sap Notebook

7.2.10 Seconds Component of Current Time

&SECONDS&

The component of the current time referring to seconds is printed. The display includes leading zeros.

7.2.11 Current Page Number

&PAGE&

You can use this symbol to insert into the text the page number that the current page will have when printed. You can specify the formatting option for the page number in the form for each page type.

7.2.12 Page Number of the Next Page

&NEXTPAGE&

This symbol is used to print the number of the following page. The output format is the same as with &PAGE& .

Note that on the last page of the output, in each window that is not of type MAIN, &NEXTPAGE& has the value 0.

7.2.13 Selected Device Type

&DEVICE&

The &DEVICE& symbol is used to print the type of the output device. This type is passed in the DEVICE parameter when the SAPscript output (OPEN_FORM, PRINT_TEXT) is started, and it specifies the device for which the output should be formatted.

Possible values are:

PRINTER

SCREEN

TELEX

TELEFAX

ABAP (ABAP list display)

Page 82: Sap Notebook

7.2.14 Spaces

&SPACE&

You can use this symbol to generate a string of space characters. You must pass the number of space characters required with the symbol. If you leave out the number, then no spaces are printed.

7.2.15 Underline

&ULINE&

You can use this symbol to insert a string of underline characters into the output text. You must pass the number of underline characters required with the symbol. If you leave out the number, then just one underline character is printed.

7.2.16 Vertical Line

&VLINE&

You can use this symbol to insert a string of vertical line characters into the output text. You must pass the number of vertical line characters required with the symbol. If you leave out the number, then just one vertical line character is printed.

7.3 Program Symbols

The integration of SAPscript allows to link data that is stored in various applications of the SAP system into text modules; for example a form letter to be sent to several customers. The address information of these customers is in the SAP database and must be incorporated into the letter. SAPscript cannot read this data out of the SAP database itself, but has to call another program to do this. The data is then copied into work areas declared with TABLES.

Starting with Release 3.1G, you are no longer restricted to the TABLES statement. You can address any global variable using a program symbol. The system can evaluate the ABAP Dictionary information (output length, number of decimal places, and so on) not only for TABLES fields, but also for INFOTYPES fields and variables with a LIKE reference.

Page 83: Sap Notebook

Example:

DATA: MYCOUNTRY LIKE USR03-LAND1.

The system considers all output characteristics that can be retrieved using the ABAP statement DESCRIBE.

If SAPscript is now called from this program to format a text, it can copy the data out of these work areas.

Symbols that obtain their values from this kind of data area are called program symbols. The value of a program symbol is limited up to a maximum of 255 characters. The name of a program symbol, when using TABLES statements, consists of the table name and the field name, separated by a hyphen. Examples of customer address fields are: &KNA1-NAME1&, &KNA1-ORT01&, &KNA1-PFACH&. Otherwise, the symbol is used in the way it is defined in the print program (for example, &MYCOUNTRY). When SAPscript encounters a symbol, it first checks whether the symbol is a system symbol. If it finds no corresponding entry, it tries to find a table or structure in the calling ABAP program (declared with TABLES). If there is, the symbol is a program symbol and SAPscript next checks in the Dictionary to see whether this table contains the specified field.

If there is no table or structure in the calling ABAP program, SAPscript checks whether the symbol is a standard symbol. If no entry is found in table TTDTG, the system checks the calling program for global definitions (DATA, CONSTANTS, INFOTYPE, PARAMETER). If it finds any definitions, SAPscript processes the symbol as program symbol.

Only if no global definitions are found either, does SAPscript process the symbol as text symbol.

Basically, a defined text symbol remains a text symbol even if in the print program, for example, a DATA statement with the same name is used.

For replacing the variables, the sequence of the variables in the corresponding text is decisive.

Form/text:

....

/: DEFINE &mysymbol& = ‘abc’

* &mysymbol&

....

Page 84: Sap Notebook

Print program:

....

Data: mysymbol(5) value ‘xyz’.

....

In this example, in the form/text instead of &mysymbol& the value of the text symbol defined with DEFINE is printed: abc

Form/text:

....

* &mysymbol&

/: DEFINE &mysymbol& = ‘abc’

....

Print program:

....

Data: mysymbol(5) value ‘xyz’.

....

In this example, in the form/text instead of &mysymbol& the value of the program symbol defined in the print program is printed: xyz

Usually, SAPscript looks for the table work areas and the global variables in the main part of the ABAP program that was started. For example, if you call function modules that you want to use the table work areas, enter the name of the corresponding program in the field TDPROGRAM of the structure you can enter in the OPTIONS parameter at OPEN_FORM. This definition is then valid for all program symbols up to the next CLOSE_FORM. However, you can also specify the name of the program in the PROGRAM parameter of the START_FORM function module. If you do this, it will be valid up to the next END_FORM. If this parameter is not set in START_FORM, then the setting in OPEN_FORM applies.

For formatting a program symbol, SAPscript uses the specifications found in the Dictionary (output length, formatting routine, and so on). Certain data types require additional information out of other fields to format a value. For example, the contents of a currency field can be formatted correctly only when the information from the currency field key is also available. SAPscript itself is responsible for obtaining the necessary information from the Dictionary.

Page 85: Sap Notebook

For printing the program symbols, SAPscript uses the WRITE statement of the ABAP programming language. The effect of this statement is controlled externally via parameters (such as specifications in the user master record, table T005X), depending on the data type. If a program symbol is not printed in the way you expected it, first check whether the control parameters stated above are set correctly.

To fields of the table work areas shown below, you can refer in all SAPscript text modules:

7.3.1 SYST: System Fields in the ABAP Programming Environment

You can refer to all the fields in this table. You should, however, note that some of the fields are specific to a certain environment. They contain values that do not come from your application but have been set by the SAPscript programming environment (for example, SYST-REPID).

7.3.2 USR03: User Address Data

This structure contains information from the user master record for a given user:

Business address

Telecommunication (telephone, telefax)

Other data such as user language, department, cost center.

You can maintain the contents of these fields in the ‘Address’ section of the user maintenance.

If this table exists in the calling program, then SAPscript copies the data from the work area of this program. Otherwise, SAPscript uses the values for the currently active user.

Page 86: Sap Notebook

7.3.3 SAPSCRIPT: General SAPscript Fields

You can print the following fields of structure SAPSCRIPT as program symbols in SAPscript forms:

&SAPSCRIPT-SUBRC&:

Receives a value after executing an INCLUDE statement. The value shows whether the INCLUDE was found (that is, the INCLUDE text exists) or not. You can query this value in an IF statement.

INCLUDE was found: &SAPSCRIPT-SUBRC& = 0

INCLUDE was not found: &SAPSCRIPT-SUBRC& = 4.

&SAPSCRIPT-DRIVER&:

SAPscript formats a text for a specific output device. The initial formatting is independent of the specific language of this device. SAPscript then calls a driver to convert the device-independent format to device-specific control commands. This field contains the name of the driver.

POST Postscript driver

HPL2 HP Laserjet driver for the PCL4/PCL5 languages

PRES Driver for output devices using the PRESCRIBE language

The available drivers are stored in table TSP09.

&SAPSCRIPT-FORMPAGES&: This field contains a number representing the total number of pages of the currently formatted form (any output between START_FORM and END_FORM). The page counter mode (START, INC, HOLD) of the individual pages is ignored. You can use this symbol to formulate information like ‘Page x of y’ for your output.

&SAPSCRIPT-JOBPAGES&: This field contains a number representing the total number of pages of all forms contained in the currently formatted print request, in

Page 87: Sap Notebook

other words, of all forms created using the OPEN_FORM, START_FORM.. ENDFORM, START_FORM.. END_FORM,..., CLOSE_FORM function modules.

When using the SAPSCRIPT-FORMPAGES or SAPSCRIPT-JOBPAGES symbols, SAPscript leads all output pages of the current form or current print request into main memory to replace the symbol by the appropriate value. For large output jobs, this can mean a very large amount of memory.

&SAPSCRIPT-COUNTER_x& (x = 0.. 9): These fields represent ten counter variables that you can use in your text and forms for any counting purposes. You can use the ‘+’ and ‘-’ formatting options to increment or decrement a counter before its value is printed. You can use the DEFINE control command to assign any specific value to a counter.

&SAPSCRIPT-TELELAND&: This field contains the country key of the fax target address when using fax output via SAPscript (field ITCPO-TDTELELAND of parameter OPTIONS of function module OPEN_FORM).

&SAPSCRIPT-TELENUM&: This field contains the local fax number of the fax target address when using fax output via SAPscript (field ITCPO-TDTELENUM of parameter OPTIONS of function module OPEN_FORM).

&SAPSCRIPT-TELENUME&: This field contains the complete fax number of the fax target address when using fax output via SAPscript (field ITCPO-TDTELENUME of parameter OPTIONS of the function module OPEN_FORM).

7.4 Standard Symbols

Standard symbols are defined in table TTDTG. This table contains both the name of each symbol and its value. The value, which is language-dependent, can contain up to 60 characters. SAP supplies this table filled with standard entries. You can extend it with customer-specific symbols.

You can use standard symbols in all kinds of text.

7.5 Text Symbols

Page 88: Sap Notebook

All symbols that do not correspond to one of the three types of symbol described above are text symbols. You define the value of a text symbol yourself in the text module.

There are two ways of doing this:

In Symbols Text. the text editor, choose Include

All the text symbols contained either in the current text or in a form assigned to the text are displayed. You can assign a value of up to 60 characters to a text symbol. Enter this value in the same form as it is to appear in the output.

The effect of assigning a value is temporary, since the values assigned are not stored with the text but are lost as soon as you leave the editor. You use this kind of value assignment if you had a ready-made text containing symbols that you want to print with specific values in place of the symbols, and you want to do this only once without storing the ‘changed’ text.

In the text, use the control command DEFINE.

Since control commands are stored with the text module, any value you assign in this way is preserved when you save the text. You can change the value assigned to a symbol in the text at any time simply by issuing another DEFINE command.

Remember always to use the ' (inverted comma) character to delimit a value. The maximal length for these values is also 60 characters.

A text in the editor contains the following DEFINE commands:

/: DEFINE &mysymbol& = 'xxx xxx xxxxx xxxx'

&mysymbol&

/: DEFINE &mysymbol& = 'yyyyy yyy yyyy'

/ &mysymbol&

The printed text appears like this:

xxx xxx xxxxx xxxx

yyyyy yyy yyyy

Page 89: Sap Notebook

7.6 Formatting Options

The value of a symbol is normally printed using its full length, although trailing spaces are removed. An exception are program symbols of these data types: CURR, DEC, QUAN, INT1 INT2, INT4, PREC, and FLTP. These are formatted right-justified with an output length as specified in the Dictionary.

You can adapt the standard formatting to your own requirements by using one of the additional formatting options available. You supply the parameters for these options together with the symbol itself. Many of these options are abbreviated to a single letter, which has to be given as a capital letter. You can combine two or more options on a single symbol, as long as the result still makes sense.

7.6.1 Offset

Specifying an offset has the effect that a certain number of bytes of the symbol value, starting with the first byte on the left, will not be displayed. If the offset specified is greater than the length of the value, nothing is printed.

Syntax

&symbol+offset&

If <> has the value 123456789, the following will be displayed:

&symbol& -> 123456789

&symbol+3& -> 456789

&symbol+7& -> 89

&symbol+12& ->

&symbol+0& -> 123456789

7.6.2 Output Length

If you need only a part of the symbol value, or the output has to fit into a box or a field on the screen without overlapping the edges of this area, then you can use an output length specification to define how many bytes of the value should be copied.

Syntax

Page 90: Sap Notebook

&symbol(length)&

If <> has the value 123456789.

&symbol(3)& -> 123

&symbol(7)& -> 1234567

You can combine an output length specification with an offset specification. The specified length is then counted from the specified offset position.

&symbol+4(3)& -> 567

If a length specified is greater than the current length of the value, then spaces are appended to the symbol value.

You can use the character * to specify the length of a program symbol. The value of the symbol is then printed using the output length defined in the ABAP Dictionary.

Syntax

&symbol(*)&

The SYST-UNAME field contains the logon name of a user called Einstein . The Dictionary entry for this field contains an output length of 12.

&SYST-UNAME&... -> Einstein...

&SYST-UNAME(9)&... -> Einstein...

&SYST-UNAME(*)&... -> Einstein ...

7.6.3 Omitting the Leading Sign

Program symbols with numeric values can have a leading sign. This sign usually appears to the right of the numeric value, either as a space for positive numbers, or as a minus sign for negative numbers . You can use t he S option to ensure that the value is formatted without the sign .

Syntax

Page 91: Sap Notebook

&symbol(S)&

The ITCDP-TDULPOS field contains the value -100.00. The ABAP Dictionary definition for this field includes a leading sign.

&ITCDP-TDULPOS& -> 100.00-

&ITCDP-TDULPOS(S)& -> 100.00

7.6.4 Leading Sign to the Left

The leading sign is normally displayed to the right of a numeric value, except in the case of a floating point number. This option enables you to specify that the leading sign should be placed to the left of the number.

Syntax

&symbol(<)&

&ITCDP-TDULPOS& -> 100.00-

&ITCDP-TDULPOS(<)& -> -100.00

The SET SIGN LEFT control command specifies that all subsequent symbols with a numeric value should have a left-justified leading sign. If you use this control command, you must no longer repeat the <>

7.6.5 Leading Sign to the Right

The default setting is to print the leading sign to the right of a numeric value. If you used the SET SIGN LEFT control command to specify that the leading sign should be printed in front of the value, you can override this specification for individual symbols. The symbols specified with the > option are then printed with the leading sign to the right.

Syntax:

&symbol(>)&

You can use the SET SIGN RIGHT control command to switch back to the default setting for the output of the leading sign.

Page 92: Sap Notebook

7.6.6 Omitting Leading Zeros

Certain symbol values are printed with leading zeros. If you want to suppress these, use the Z option.

Syntax

&symbol(Z)&

Assuming the current date is 1.1.1994,

&DAY& -> 01

&DAY(Z)& -> 1

7.6.7 Space Compression

The symbol value is viewed as a sequence of ‘words’, each separated from the next by either one or a string of space characters. The C option has the effect of replacing each string of space characters with a single space and shifting the ‘words’ to the left as necessary to close up the gaps. Leading spaces are completely removed. The results are the same as those of the ABAP command CONDENSE. Syntax:

&symbol(C)&

Assuming ' Albert Einstein ' is the symbol value,

&symbol& -> Albert Einstein

&symbol(C)& -> Albert Einstein

7.6.8 Number of Decimal Places

A program symbol of one of the data types DEC, QUAN, and FLTP can contain decimal place data. Use the option below to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.

Page 93: Sap Notebook

Syntax

&symbol(.N)&

The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.

&EKPO-MENGE& -> 1,234.560

&EKPO-MENGE(.1) -> 1,234.6

&EKPO-MENGE&(.4) -> 1,234.5600

&EKPO-MENGE&(.0) -> 1,235

7.6.9 Omitting the Separator for ‘Thousands’

Symbols of the DEC, CURR, INT, and QUAN data types are normally formatted with the a ‘thousands’ separator character. The T option allows you to omit this separator character.

Syntax:

&symbol(T)&

The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.

&EKPO-MENGE& -> 1,234.560

&EKPO-MENGE(T)& -> 1234.560

7.6.10 Specifying an Exponent for Floating Point Numbers

The way a floating point number is formatted depends on whether an exponent is specified. The mantissa is adjusted by shifting the decimal point and, if necessary, introducing leading zeros, according to the exponent chosen. Using an exponent value of 0 means that the exponent representation will not be used for displaying the symbol.

Syntax

&symbol(EN)&

Page 94: Sap Notebook

If you specify an exponent of 0, then the number is displayed without using the exponent representation. This has the same effect as completely omitting the specification of an exponent: &symbol(E0)& has the same effect as &symbol(E)&

In this example, the PLMK-SOLLWERT field is assumed to have the value 123456.78 and to be of data type FLTP.

&PLMK-SOLLWERT& -> +1.23456780000000E+05

&PLMK-SOLLWERT(E3)& -> +123.456780000000E+03

&PLMK-SOLLWERT(E6)& -> +0.12345678000000E+06

&PLMK-SOLLWERT(E0)& -> +123456.780000000

&PLMK-SOLLWERT(E)& -> +123456.780000000

7.6.11 Right-Justified Output

Symbol values other than numeric values are normally formatted left-justified. To specify right-justified formatting, use the R option. You must use this option in conjunction with an output length specification.

Syntax

&symbol(R)&

If symbol has the value 1234.

&symbol& -> 1234

&symbol(8R) -> 1234

For program symbols, the length specification contained in the Dictionary definition may be used instead of an explicit length.

7.6.12 Fill Characters

You can replace leading spaces in a value with a fill character. Use the F option with the character immediately following the F in the specification as the fill character.

Syntax

&symbol(F f )&

Page 95: Sap Notebook

f = fill character

The figure for customer sales in the KNA1-UMSAT field is $700. The Dictionary description of the field specifies an output length 8.

&KNA1-UMSAT& -> 700.00

&KNA1-UMSAT(F*)& -> **700.00

&KNA1-UMSAT(F0)& -> 00700.00

7.6.13 Suppressing Output of Initial Values

Use the I option to suppress the output of symbols that still contain their initial values.

Syntax

&symbol(I)&

Assuming KNA1-UMSAT contains the value 0 and the currency is DEM.

&KNA1-UMSAT& -> 0,00

&KNA1-UMSAT(I)& ->

If the field contains an amount other than 0, this value is printed in the normal way.

&KNA1-UMSAT& -> 700,00

&KNA1-UMSAT(I)& -> 700,00

7.6.14 Ignoring Conversion Routines

SAPscript conversion routines specified in the Dictionary are automatically recognized and used when program symbols are formatted. To suppress conversion, use the K option.

Syntax

&symbol(K)&

7.6.15 Changing the Value of a Counter

Page 96: Sap Notebook

You can increase or decrease the value of a SAPSCRIPT-COUNTER_x (x=0.. 9) counter variable by 1, before the current counter value is printed.

Syntax:

&SAPSCRIPT-COUNTER_x(+)& Increases by 1 the contents of the counter variable x (x=0.. 9)

&SAPSCRIPT-COUNTER_x(-)& Decreases by 1 the contents of the counter variable x (x=0.. 9)

If you want to change the value of a counter variable without actually printing the new value, use this formatting option together with an additional option to set the output length to 0 (see above). If you want to set a counter variable to some specific value, use the DEFINE control command.

Assume that &SAPSCRIPT-COUNTER_1& initially has the value 2.

&SAPSCRIPT-COUNTER_1& -> 2

&SAPSCRIPT-COUNTER_1(+)& -> 3

&SAPSCRIPT-COUNTER_1(-)& -> 2

&SAPSCRIPT-COUNTER_1(-)& -> 1

&SAPSCRIPT-COUNTER_1(+0)& ->

&SAPSCRIPT-COUNTER_1(+)& -> 3

7.6.16 Preceding and Subsequent Texts (Pre-Text / Post-Text)

In addition to using initial values for symbols, you can specify additional texts that are printed only when the value of the symbol is no longer the initial value. You can specify a text to be printed immediately before the symbol value (the pre-text), and a text to be printed immediately after the symbol value (the post-text). If the symbol contains its initial value, these texts are suppressed.

Syntax:

&'pre-text'symbol'post-text'&

Make sure that the symbol, the pre-text, and the post-text all appear on a single line of the editor. You may have to use a long line (paragraph attribute = or /=) in the editor.

Page 97: Sap Notebook

The inverted comma ' is used as a delimiter for these texts. If this character is also part of one of these texts, enter it twice at this point, so that it is not interpreted as a delimiter character. A pre-text or post-text may itself contain symbols in addition to normal text. However, these symbols may not have a pre-text or a post-text.

The KNA1-PFACH field contains a customer P.O. Box number. Since the text "P.O. Box" is not stored in the field along with the value, you would normally write the following for the P.O. Box line of an address:

P.O. Box &KNA1-PFACH&

However, if no P.O. Box has been specified, the text "P.O. Box" would still appear on its own in the address. To prevent this, use pre-text or post-text (in this case, pre-text).

P.O. Box &KNA1-PFACH& -> P.O. Box

&'P.O. Box 'KNA1-PFACH& ->

If a P.O. Box has been specified, then this will be displayed together with the appropriate text in the normal way.

&'P.O. Box 'KNA1-PFACH& -> P.O. Box 123456

7.7 Country-Dependent Formatting

Certain fields are formatted specific to a particular country. These include fields for displaying a date and numeric fields containing either a decimal point or a ‘thousands’ separator character. The formatting applied is usually determined by the definitions contained in the user master record. You can use the SET COUNTRY control command to choose a different formatting operation. The various country-dependent formatting options are stored in table T005X.

Syntax

/: SET COUNTRY country_key

You can specify this country key either by quoting it directly enclosed in inverted commas or by using a symbol.

/: SET COUNTRY 'CAN'

/: SET COUNTRY &KNA1-LAND1&

Page 98: Sap Notebook

You can revert to the settings of the user master record by using the SET COUNTRY control command again with an empty country name.

/: SET COUNTRY ' '

When SAPscript encounters this command it calls the corresponding ABAP command internally. The effect of the SAPscript command is thus identical with that of the ABAP command.

If the formatting turns out other than expected, check the settings in table T005X.

7.7.1 Date Mask

To format date fields, use the SAPscript SET DATE MASK command. Executing this command causes all subsequent date fields to be printed with the specified formatting.

Syntax

/: SET DATE MASK = 'date_mask'

The following templates may be used in the date mask:

DD day (two digits)

DDD name of day (abbreviated)

DDDD name of day (written out in full)

MM month (two digits)

MMM name of month (abbreviated)

MMMM name of month (written out in full)

YY year (two digits)

YYYY year (four digits)

LD day (formatted as for the L option)

LM month (formatted as for the L option)

LY year (formatted as for the L option)

Page 99: Sap Notebook

Any other characters occurring in the mask are interpreted as simple text and are copied directly to the output.

Assuming a current system date of March 1st, 1997.

/: SET DATE MASK = 'Foster City, MM.DD.YY'

&DATE& -> Foster City, 03.01.97

&DATE(Z)& -> Foster City, 3.1.97

/: SET DATE MASK = 'MMMM DD, YYYY'

&DATE& -> March 01, 1997

You can revert to the standard setting by using the SET DATE MASK command again with an empty string in place of the date mask:

/: SET DATE MASK = ' '

7.7.2 Time Mask

You can use the SAPscript SET TIME MASK command to format time fields in a way that differs from the standard setting. Executing this command causes all subsequent time fields to be printed with the specified formatting.

Syntax:

/: SET TIME MASK = 'time_mask'

The following templates may be used in the time mask:

HH hours (two digits)

MM minutes (two digits)

SS seconds (two digits)

Page 100: Sap Notebook

Any other characters occurring in the mask are interpreted as simple text and are copied directly to the output.

Assuming the current time is 10:08:12.

&TIME& -> 10:08:12

/: SET TIME MASK = 'HH:MM'

&TIME& -> 10:08

/: SET TIME MASK = 'HH hours MM minutes'

&TIME& -> 10 hours 08 minutes

&TIME(Z)& -> 10 hours 8 minutes

You can revert to the standard setting by using the SET TIME MASK command again with an empty string in place of the time mask:

/: SET TIME MASK = ' '

7.8 Formatting Conventions

Many allowed combinations of option and symbol type either make no sense or have no effect at all. The formatting process is divided into two stages: primary formatting and end formatting. The purpose of primary formatting is to convert the internal form of a symbol value to a character-based form. The end formatting is then applied to this intermediate form. The following sections describe the formatting process for each kind of symbol and in which of the two stages of conversion the various options are applied.

7.8.1 Primary Formatting of System Symbols

Certain system symbols must first be converted from their internal representation into a character representation before the end formatting can be applied to them. The following system symbols require a primary conversion:

&DAY&, &MONTH&, &YEAR&, &HOURS&, &MINUTES&, &SECONDS& The relevant components are extracted from the system date or system time. Leading zeros are eliminated if the Z formatting option is specified.

&DATE& The default behavior is that the system date is printed according to the setting in the user master record or according to the country-dependent formatting

Page 101: Sap Notebook

specified in a SET COUNTRY command. If a date mask has been defined (using SET DATE MASK), then the formatting specified there is used for the output.

&TIME& The default behavior is that the current system time is printed in the form hours:minutes:seconds If an alternative time mask is specified (using SET TIME MASK) then this mask overrides the default setting.

&PAGE&, &NEXTPAGE& This symbols are initially converted using the options specified in the form of the page definition.

&LDATE& This date representation is always formatted using the JPDAT conversion routine.

All remaining system symbols are treated by the primary conversion as a character string and thus are not converted. The end conversion is started when the primary conversion is complete.

7.8.2 Primary Formatting of Standard Symbols

Standard symbols are treated by the primary formatting as a character string and thus are not converted. The end formatting is started immediately.

7.8.3 Primary Formatting of Program Symbols

Program symbols are initially converted from their internal representation into a character representation. This is done using the ABAP WRITE command together with additional parameters as appropriate for the specified options. The options to which the primary conversion applies depend on the data type.

The formatting is carried out in an internal work field by the ABAP WRITE command.

Page 102: Sap Notebook

This field is chosen according to the data type and length. The various options are handled by appropriate extensions to the WRITE commands:

S

NO-SIGN

Z NO-ZERO

. DECIMALS

E EXPONENT

I A check is made for an initial value by using an IF statement to do an IS INITIAL comparison.

I S Z * K < > E . Length

CHAR x x x

CURR x x 2 x x x x 2

DEC x x 2 x x x x 2

NUMC x x x x

VAR x x x

VARC x x x

LANG x x x

UNIT x x x

DATE x x

DATS x x

TIME x x

TIMS x x

QUAN x x 2 x x x x 2

INT1 x x x 2 x x x 2

INT2 x x x 2 x x x 2

Page 103: Sap Notebook

INT4 x x x 2 x x x 2

PREC x x x 2 x x x 2

CUKY x x x

ACCP x x x

CLNT x x x

FLTP x 1 2 x x x 2

1 ABAP WRITE currently ignores this option for floating point numbers.

2 The value is formatted using the ABAP WRITE command in a work field with the specified length

If a conversion routine is defined in the ABAP Dictionary, then the primary formatting is performed using this routine only. In this case, none of the options listed in this table are applicable unless you deactivate the conversion routine with the K option.

After the primary conversion of a program symbol is completed, the formatted value is then subjected to the end formatting.

7.8.4 Primary Formatting of Text Symbols

Text symbols are treated by the primary formatting as a character string and thus are not converted. The end formatting is started immediately.

7.8.5 End Formatting

In end formatting, the following formatting options are applied to the symbol value in the given order. These are the same for all symbol types.

If the C option is used, a space compression is performed.

If the L option is used, local date formatting is performed.

If an offset is specified, the offset is interpreted.

Page 104: Sap Notebook

If an output length is specified then the length is interpreted.

If a fill character is specified (the F option), these are added to the formatted value.

If pre-texts and post-texts are soecified, they are processed and added to the formatted value.

Posted 10th May 2010 by Blaster Labels: SAP FORMS 0 Add a comment

2.May10

SAP SQL

Performance tuning for Data Selection Statement For all entriesThe for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause. The plus

Large amount of data  Mixing processing and reading of data  Fast internal reprocessing of data  Fast 

The Minus Difficult to program/understand  Memory could be critical (use FREE or PACKAGE size) 

Some steps that might make FOR ALL ENTRIES more efficient: Removing duplicates from the the driver table  Sorting the driver table 

If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:FOR ALL ENTRIES IN i_tab  WHERE mykey >= i_tab-low and        mykey <= i_tab-high.

Nested selectsThe plus:

Page 105: Sap Notebook

Small amount of data  Mixing processing and reading of data  Easy to code - and understand 

The minus: Large amount of data  when mixed processing isn’t needed  Performance killer no. 1

Select using JOINSThe plus

Very large amount of data  Similar to Nested selects - when the accesses are planned by the programmer  In some cases the fastest  Not so memory critical 

The minus Very difficult to program/understand  Mixing processing and reading of data not possible 

Use the selection criteria SELECT * FROM SBOOK.                      CHECK: SBOOK-CARRID = 'LH' AND                          SBOOK-CONNID = '0400'.         ENDSELECT.                              SELECT * FROM SBOOK                        WHERE CARRID = 'LH' AND                        CONNID = '0400'.                 ENDSELECT.                               

Use the aggregated functions C4A = '000'.               SELECT * FROM T100           WHERE SPRSL = 'D' AND            ARBGB = '00'.        CHECK: T100-MSGNR > C4A.   C4A = T100-MSGNR.        ENDSELECT.                  SELECT MAX( MSGNR ) FROM T100 INTO C4A   WHERE SPRSL = 'D' AND                        ARBGB = '00'.                   

Select with viewSELECT * FROM DD01L                       WHERE DOMNAME LIKE 'CHAR%'                    AND AS4LOCAL = 'A'.               SELECT SINGLE * FROM DD01T                WHERE   DOMNAME    = DD01L-DOMNAME          AND AS4LOCAL   = 'A'                    AND AS4VERS    = DD01L-AS4VERS          AND DDLANGUAGE = SY-LANGU.      ENDSELECT.                               SELECT * FROM DD01V                      WHERE DOMNAME LIKE 'CHAR%'            

Page 106: Sap Notebook

       AND DDLANGUAGE = SY-LANGU.      ENDSELECT.                              

Select with index supportSELECT * FROM T100              WHERE     ARBGB = '00'              AND MSGNR = '999'.     ENDSELECT.                      SELECT * FROM T002.                SELECT * FROM T100                 WHERE     SPRSL = T002-SPRAS           AND ARBGB = '00'                 AND MSGNR = '999'.       ENDSELECT.                     ENDSELECT.                        

Select … Into tableREFRESH X006.                  SELECT * FROM T006 INTO X006.    APPEND X006.                 ENDSELECT SELECT * FROM T006 INTO TABLE X006. 

Select with selection listSELECT * FROM DD01L                 WHERE DOMNAME LIKE 'CHAR%'              AND AS4LOCAL = 'A'.       ENDSELECT SELECT DOMNAME FROM DD01L      INTO DD01L-DOMNAME           WHERE DOMNAME LIKE 'CHAR%'         AND AS4LOCAL = 'A'.   ENDSELECT

Key access to multiple linesLOOP AT TAB.            CHECK TAB-K = KVAL.   " ...                ENDLOOP.                LOOP AT TAB WHERE K = KVAL.        " ...                          ENDLOOP.                          

Copying internal tablesREFRESH TAB_DEST.               LOOP AT TAB_SRC INTO TAB_DEST.    APPEND TAB_DEST.              ENDLOOP.                         TAB_DEST[] = TAB_SRC[].

Page 107: Sap Notebook

Modifying a set of linesLOOP AT TAB.                IF TAB-FLAG IS INITIAL.     TAB-FLAG = 'X'.         ENDIF.                    MODIFY TAB.             ENDLOOP.                   TAB-FLAG = 'X'.                   MODIFY TAB TRANSPORTING FLAG                 WHERE FLAG IS INITIAL. 

Deleting a sequence of linesDO 101 TIMES.                  DELETE TAB_DEST INDEX 450. ENDDO.                        DELETE TAB_DEST FROM 450 TO 550. 

Linear search vs. binaryREAD TABLE TAB WITH KEY K = 'X'. READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.

Comparison of internal tablesDESCRIBE TABLE: TAB1 LINES L1,                       TAB2 LINES L2.                                            IF L1 <> L2.                           TAB_DIFFERENT = 'X'.               ELSE.                                  TAB_DIFFERENT = SPACE.               LOOP AT TAB1.                          READ TABLE TAB2 INDEX SY-TABIX.      IF TAB1 <> TAB2.                       TAB_DIFFERENT = 'X'. EXIT.         ENDIF.                             ENDLOOP.                           ENDIF.                                                                    IF TAB_DIFFERENT = SPACE.              " ...                              ENDIF.                                IF TAB1[] = TAB2[].    " ...               ENDIF.                

Modify selected componentsLOOP AT TAB.             TAB-DATE = SY-DATUM.   MODIFY TAB.           ENDLOOP.                 WA-DATE = SY-DATUM.                     

Page 108: Sap Notebook

LOOP AT TAB.                             MODIFY TAB FROM WA TRANSPORTING DATE. ENDLOOP.                                

Appending two internal tablesLOOP AT TAB_SRC.                 APPEND TAB_SRC TO TAB_DEST.  ENDLOOP APPEND LINES OF TAB_SRC TO TAB_DEST.

Deleting a set of linesLOOP AT TAB_DEST WHERE K = KVAL.    DELETE TAB_DEST.                ENDLOOP DELETE TAB_DEST WHERE K = KVAL. 

Tools available in SAP to pin-point a performance problem

The runtime analysis (SE30)SQL Trace (ST05)Tips and Tricks tool The performance database

Optimizing the load of the databaseUsing table bufferingUsing buffered tables improves the performance considerably. Note that in some cases a stament can not be used with a buffered table, so when using these staments the buffer will be bypassed. These staments are:

Select DISTINCT  ORDER BY / GROUP BY / HAVING clause  Any WHERE clasuse that contains a subquery or IS NULL expression  JOIN s  A SELECT... FOR UPDATE 

If you wnat to explicitly bypass the bufer, use the BYPASS BUFFER addition to the SELECT clause.Use the ABAP SORT Clause Instead of ORDER BYThe ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The datbase server will usually be the bottleneck, so sometimes it is better to move thje sort from the datsbase server to the application server.If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT stament to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the datbase server sort it.

Avoid ther SELECT DISTINCT Statement

Page 109: Sap Notebook

As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplciate rows.

Page 110: Sap Notebook

From   sdnDont use nested select statements2) If possible use for all entries in addition3) In the where addition make sure you give all the primary key4) Use Index for the selection criteria.5) You can also use inner joins6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly

ABAP performance depends upon various factors and in devicded in three parts:1. Database2. ABAP3. System

Run Any program using SE30 (performance analys) to improve performance refer to tips and trics section of SE30, Always remember that ABAP perfirmance is improved when there is least load on Database.u can get an interactive grap in SE30 regarding this with a file.also if u find runtime of parts of codes then use :Switch on RTA Dynamically within ABAP Code*To turn runtim analysis on within ABAP code insert the following codeSET RUN TIME ANALYZER ON.*To turn runtim analysis off within ABAP code insert the following codeSET RUN TIME ANALYZER OFF.Always check the driver internal tables is not empty, while using FOR ALL ENTRIESAvoid for all entries in JOINSTry to avoid joins and use FOR ALL ENTRIES.Try to restrict the joins to 1 level only ie only for tablesAvoid using Select *.Avoid having multiple Selects from the same table in the same object.Try to minimize the number of variables to save memory.The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)Avoid creation of index as far as possibleAvoid operators like <>, > , < & like % in where clause conditionsAvoid select/select single statements in loops.Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)

Page 111: Sap Notebook

Avoid using ORDER BY in selectsAvoid Nested SelectsAvoid Nested Loops of Internal TablesTry to use FIELD SYMBOLS.Try to avoid into Corresponding Fields ofAvoid using Select Distinct, Use DELETE ADJACENT

Follow below while coding :

1 Always check the driver internal tables is not empty, while using FOR ALL ENTRIES2 Avoid for all entries in JOINS3 Try to avoid joins and use FOR ALL ENTRIES.4 Try to restrict the joins to 1 level only ie only for 2 tables5 Avoid using Select *.6 Avoid having multiple Selects from the same table in the same object.7 Try to minimize the number of variables to save memory.8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)9 Avoid creation of index as far as possible10 Avoid operators like <>, > , < & like % in where clause conditions11 Avoid select/select single statements in loops.12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)14 Avoid using ORDER BY in selects15 Avoid Nested Selects16 Avoid Nested Loops of Internal Tables17 Try to use FIELD SYMBOLS.18 Try to avoid into Corresponding Fields of19 Avoid using Select Distinct, Use DELETE ADJACENT.

You can use the following points in improving the performance..

Evaluate requirements

Communicate with users to get actual data required so that, default values could be set on Selection Screen. This would avoid extracting whole lot of data, which may not be really needed.

•Match the requirements.

1. Match the alternative source of information (in less populated tables).2. Instead of Using cluster table, find the alternative transparent tables3. Try to match the requirements with the views.4. Check if the logical sequence of table access is correct. It is preferable to sequence

Page 112: Sap Notebook

the database access to go from a table with lesser values to the more populated tables.

•Improve access to Tables

1. As far as possible try to have direct accesses on records by providing full key, so that access would be faster.2. Always specify your conditions in the where-clause instead of checking them yourself with check-statements3. Whenever possible access the tables through primary keys. Also " select single " can be very helpful. Consider the use of the DISTINCT option in the case of many duplicate entries.4. Ensure that you utilise internal tables wherever possible. Avoid doing a large amount of processing within a database select loop.5. Similarly nested database selects are an absolute no-no.

•Reduce Multiple Accesses on databases

1. Avoid multiple accesses on databases.

2. Use specific fields for transferring data into the internal tables. ( use " into corresponding fields of table " flavour of the select statement ). This is especially true if less than half the available fields have to be transmitted.

3. If internal tables have many entries, a linear search through all entries is very time-consuming. Try to keep the table ordered and use binary search ( " Read table " statement with binary search ) . e.g. consider an internal table itab containing values ( 2,10,4,9,6,12,8,3).if record with val = 3 is needed the following READ statement is usedREAD TABLE ITAB WITH KEY VAL = 3.

The read operation is done sequentially here so the required record is accessed in the 8th step.

A better way to do this is :

Sorting the table using :SORT ITAB.READ TABLE ITAB WITH KEY VAL = 3 BINARY SEARCH.

Sorting results in :itab = ( 2,3,4,6,8,9,10,12 )The reqiured record is now read in the 2nd step.

Note that for best results the itab must hold large number of records.

Page 113: Sap Notebook

4.Avoid doing unnecessary processing within a loop.

5.A nested database select can be avoided by using the " for all entries " flavour of the select statement. A word of caution - always ensure that the table which is used for further selections (the " for all entries in table " table contains at least one record). A failure to do this check results in all records being picked up by the select. Similarly, avoid identical where clauses for different lines of ITAB by using a sorted internal table in the SELECT … FOR ALL ENTRIES … and using the ABAP language element DELETE ADJACENT DUPLICATES prior to executing the select statement.

)How do you take care of performance issues in your ABAP programs?

Performance of ABAPs can be improved by minimizing the amount of data to be transferred.The data set must be transferred through the network to the applications, so reducing the amount OF time and also reduces the network traffic.

Some measures that can be taken are:

- Use views defined in the ABAP/4 DDIC (also has the advantage of better reusability).- Use field list (SELECT clause) rather than SELECT *.- Range tables should be avoided (IN operator)- Avoid nested SELECTS.

i)system tools

ii)field symbols and field groups.ans:-Field Symbols : Field symbols are placeholders for existing fields. A Field Symbol does not physically reserve space for a field,but points to a field which is not known until runtime of the program.eg:- FIELD-SYMBOL [].

Field groups : A field group combines several fields under one name.At runtime,the INSERT command is used to define which data fields are assigned to which field group.There should always be a HEADER field group that defines how the extracted data will be sorted,the data is sorted by the fields grouped under the HEADER field group

2)What is the difference between standard and sorted internal tables? (in performance wise)

Ans: Sorted table improve the performance in case of a huge table which has no: of

Page 114: Sap Notebook

records

3)What are steps you follow to improve the performance of a report?

Ans: a) USe select fields statements (not select *)        b) Use views rather than tables        c) Don't use nested Select.

4)What is the role of secondary index in performance?

Ans: sorry i dont know

6)What is the role of ST05 in performance tuning?

Ans: SQL trace

7)What is the role of extended syntax check in performance tuning?

Ans: sorry i dont know

8)Will join conditions in sql queries affect perfomance? how?

Ans : Yes

9)Will sorted internal tables help in performance?

Ans: Yes

10)Will where conditions in a sql query help improve performance?

Ans: No Not at all

11)Does select single *.. / select * .. affect performance? how?

Ans: Select single we use for first hit of the record. so obviously Select single will improve the performance

For all entriesThe for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause. The plus 

Large amount of data Mixing processing and reading of data

Page 115: Sap Notebook

Fast internal reprocessing of data Fast

The Minus  Difficult to program/understand Memory could be critical (use FREE or PACKAGE size)

Some steps that might make FOR ALL ENTRIES more efficient:  Removing duplicates from the driver table Sorting the driver table  If possible, convert the data in the driver table to ranges so a BETWEEN

statement is used instead of and OR statement:               FOR ALL ENTRIES IN i_tab

                  WHERE mykey >= i_tab-low and             mykey <= i_tab-high.

Nested selectsThe plus:         Small amount of data         Mixing processing and reading of data         Easy to code - and understandThe minus:         Large amount of data         when mixed processing isn’t needed         Performance killer no. 1

Select using JOINSThe plus         Very large amount of data         Similar to Nested selects - when the accesses are planned by the programmer         In some cases the fastest         Not so memory criticalThe minus         Very difficult to program/understand         Mixing processing and reading of data not possible

Use the selection criteriaSELECT * FROM SBOOK.                       CHECK: SBOOK-CARRID = 'LH' AND                           SBOOK-CONNID = '0400'.          ENDSELECT.                               SELECT * FROM SBOOK                         WHERE CARRID = 'LH' AND                         CONNID = '0400'.                  ENDSELECT.                                

Use the aggregated functions

Page 116: Sap Notebook

C4A = '000'.                SELECT * FROM T100            WHERE SPRSL = 'D' AND             ARBGB = '00'.         CHECK: T100-MSGNR > C4A.    C4A = T100-MSGNR.        ENDSELECT.                  SELECT MAX( MSGNR ) FROM T100 INTO C4A    WHERE SPRSL = 'D' AND                         ARBGB = '00'.                    

Select with viewSELECT * FROM DD01L                        WHERE DOMNAME LIKE 'CHAR%'                     AND AS4LOCAL = 'A'.                SELECT SINGLE * FROM DD01T                 WHERE   DOMNAME    = DD01L-DOMNAME           AND AS4LOCAL   = 'A'                     AND AS4VERS    = DD01L-AS4VERS           AND DDLANGUAGE = SY-LANGU.       ENDSELECT.                                 SELECT * FROM DD01V                       WHERE DOMNAME LIKE 'CHAR%'                    AND DDLANGUAGE = SY-LANGU.       ENDSELECT.                               

Select with index supportSELECT * FROM T100               WHERE     ARBGB = '00'               AND MSGNR = '999'.      

Page 117: Sap Notebook

ENDSELECT.                        SELECT * FROM T002.                 SELECT * FROM T100                  WHERE     SPRSL = T002-SPRAS            AND ARBGB = '00'                  AND MSGNR = '999'.        ENDSELECT.                      ENDSELECT.                          

Select … Into tableREFRESH X006.                   SELECT * FROM T006 INTO X006.     APPEND X006.                  ENDSELECT   SELECT * FROM T006 INTO TABLE X006.   

Select with selection listSELECT * FROM DD01L                  WHERE DOMNAME LIKE 'CHAR%'               AND AS4LOCAL = 'A'.        ENDSELECT   SELECT DOMNAME FROM DD01L       INTO DD01L-DOMNAME            WHERE DOMNAME LIKE 'CHAR%'          AND AS4LOCAL = 'A'.    ENDSELECT

Page 118: Sap Notebook

 

Key access to multiple linesLOOP AT TAB.             CHECK TAB-K = KVAL.    " ...                 ENDLOOP.                  LOOP AT TAB WHERE K = KVAL.         " ...                           ENDLOOP.                            

Copying internal tablesREFRESH TAB_DEST.                LOOP AT TAB_SRC INTO TAB_DEST.     APPEND TAB_DEST.               ENDLOOP.                           TAB_DEST[] = TAB_SRC[]. 

Modifying a set of linesLOOP AT TAB.                 IF TAB-FLAG IS INITIAL.      TAB-FLAG = 'X'.          ENDIF.                     MODIFY TAB.              ENDLOOP.                     TAB-FLAG = 'X'.                    MODIFY TAB TRANSPORTING FLAG                  WHERE FLAG IS INITIAL.  

Page 119: Sap Notebook

  

Deleting a sequence of linesDO 101 TIMES.                   DELETE TAB_DEST INDEX 450.  ENDDO.                          DELETE TAB_DEST FROM 450 TO 550.   

Linear search vs. binaryREAD TABLE TAB WITH KEY K = 'X'.   READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH. 

Comparison of internal tablesDESCRIBE TABLE: TAB1 LINES L1,                        TAB2 LINES L2.                                              IF L1 <> L2.                            TAB_DIFFERENT = 'X'.                ELSE.                                   TAB_DIFFERENT = SPACE.                LOOP AT TAB1.                           READ TABLE TAB2 INDEX SY-TABIX.       IF TAB1 <> TAB2.                        TAB_DIFFERENT = 'X'. EXIT.          ENDIF.                              ENDLOOP.                            ENDIF.                                                                    

Page 120: Sap Notebook

 IF TAB_DIFFERENT = SPACE.               " ...                               ENDIF.                                  IF TAB1[] = TAB2[].     " ...                ENDIF.                 

Modify selected componentsLOOP AT TAB.              TAB-DATE = SY-DATUM.    MODIFY TAB.            ENDLOOP.                   WA-DATE = SY-DATUM.                      LOOP AT TAB.                              MODIFY TAB FROM WA TRANSPORTING DATE.  ENDLOOP.                                 

Appending two internal tablesLOOP AT TAB_SRC.                  APPEND TAB_SRC TO TAB_DEST.   ENDLOOP   APPEND LINES OF TAB_SRC TO TAB_DEST. 

Deleting a set of linesLOOP AT TAB_DEST WHERE K = KVAL.     DELETE TAB_DEST.                 ENDLOOP   

Page 121: Sap Notebook

DELETE TAB_DEST WHERE K = KVAL.   

Tools available in SAP to pin-point a performance problem

                The runtime analysis (SE30)                 SQL Trace (ST05)                 Tips and Tricks tool                  The performance database 

 

Optimizing the load of the databaseUsing table buffering

Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:

         Select DISTINCT         ORDER BY / GROUP BY / HAVING clause         Any WHERE clause that contains a sub query or IS NULL expression         JOIN s         A SELECT... FOR UPDATEIf you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT

clause.

Use the ABAP SORT Clause Instead of ORDER BYThe ORDER BY clause is executed on the database server while the ABAP SORT statement

is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.

If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.

Avoid the SELECT DISTINCT StatementAs with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of

the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.

Difference between Variant Transaction and Parameter Transaction in SE93

NOTES

Page 122: Sap Notebook

Operations without header line Operations with header line

Operations for all Table Types ( standard table, sorted table, hashed table )

INSERT INTO TABLE . INSERT TABLE ITAB.

COLLECT INTO . COLLECT .

READ TABLE ... INTO . READ TABLE ...

MODIFY TABLE FROM ... MODIFY TABLE ...

------------------------MODIFY FROM ...WHERE ...

---------------------MODIFY ... WHERE ...

DELETE TABLE FROM . DELETE TABLE .

LOOP AT ITAB INTO ... LOOP AT ITAB ...

Operations for Index Tables ( standard and sorted only ) cos Hashed table don’t have indexTips: Don’t use TABLE keyword.

APPEND TO . APPEND .

INSERT INTO ... INSERT ...

MODIFY FROM ... MODIFY ...

BASICS: ( tips: TABLE word is necessary for all except collect ) , ( tips2: modify and delete will only have FROM wa )

Data Class: MASTER DATA, TRANS DATA, ORGANIZATIONAL DATA

(APPL0), (APPL1),(APPL2).

UseIf you choose the data class correctly, your table is automatically assigned to the correct area (table space or DB space) of the database when it is created. Each data class corresponds to a physical area in which all the tables assigned to this data class are stored.There are the following data classes:

●      APPL0 (master data):Data that is seldom changed. An example of master data is the data contained in an address file, such as the name, address and telephone number.

●      APPL1 (transaction data):Data that is frequently changed. An example of transaction data is the goods in a warehouse which change after each purchase order.

●      APPL2 (organizational data):Customizing data that is defined when the system is installed and seldom changed. An example is the table with country codes.Two further data classes, USR and USR1, are provided for the customer. These are for user developments. The tables assigned to these data classes are stored in a table space for user

Page 123: Sap Notebook

developments. In the following figure you can see tables assigned to different data classes. The figure presents the tables in the ABAP Dictionary and in the database.

TABLE CAN HAVE A STRUCTURE INSIDE AND THAT STRUCTURE CAN HAVE ANOTHER STRUCTURE… LIKE THIS U CAN HAVE UPTO 9 INCLUDES

FIELD NAME IN A TABLE CAN BE MAX 16 FIELD NAME IN A STRUCTURE CAN BE MAX 30BUSINESS PARTNERSFor MM -> VENDORRAW MATERIAL TYPE = ROHSEMI FINISHED PRODUCT TYPE = HALBFINISHED PRODUCT MATERIAL TYPE = FERTMM

LFA1 VENDOR DETAILS TABLE ( MM )The one who supplies raw material to company.

~LIFNR VENDOR ACCOUNT NUMBER

~NAME1 VENDOR NAME

~ORT01 VENDOR ADDRESS

EKKO PURCHASE ORDER TABLEBuying raw material from vendor, so purchasing.

~EBELN PURCHASE ORDER NUMBER

~~~LIFNR VENDOR ACCOUNT NUMBER

~AEDAT DATE OF PURCHASE

~NETWR AMOUNT

EKPO PURCHASE ORDER ITEM DETAILSPurchasing a big list of raw materials from vendor.

~EBELP ITEM NUMBER

~EBELN PURCHASE ORDER NUMBER

~MATNR MATERIAL NUMBER

RBKP INVOICE RECEIPT HEADER

Page 124: Sap Notebook

Vendor giving bill to company.

~BELNR INVOICE NO.

~LIFNR VENDOR A/C NO.

~RMWWR INVOICE AMOUNT

RSEG INVOICE RECEIPT ITEM Vendor giving list of items purchased

~BUZEI ITEM NO.

~BELNR INVOICE NO.

~MATNR MATERIAL NO.

EXAMPLE FOR JOIN:Select LFA1~LIFNR EKKO~EBELNEKKO~AEDATINTO TABLE itab FROM LFA1INNER JOIN EKKOON LFA1~LIFNR = EKKO~LIFNRWHERE LFA1~LIFNR IN SO_VENDOR-----------------------------------------------------------------------------------------------------------------------------------------------------------------RSTXPDFT4RSTXLDMC are 2 exe programs used in sapscripts to convert a script to pdf and to upload a TIFF image file for scripts rsptvlyRSTXR3TR: used to allow form to transport across clients ie., from dev to quality.-----------------------------------------------------------------------------------------------------------------------------------------------------------------PREDEFINED OUTPUT TYPES: (refer table TNAPR for more output types)NEU - Purchase orderBA00 - Sales orderLD00 - Delivery applicationRD00 - Bill and invoice-----------------------------------------------------------------------------------------------------------------------------------------------------------------Function module creation tcode SE37-----------------------------------------------------------------------------------------------------------------------------------------------------------------Screen 9000 > Screen 1000 > = < 1010 cannot be used.-----

Page 125: Sap Notebook

Smart Forms Tcode: SMARTFORMAdobe forms tcode: SFPWORKFLOW : SWDDSAP QUERY: SQ02 - An InfoSet describes data sources that are usually defined as joins, SQ03- USERGROUP, Assign infoset into usergroup, then SQ01-SAP query orSQV1 –quick viewerBAPI : SE37 for function module and sw01 for BOR, tcode : BAPI Upload Pic to BDS = SE78BDC : Gui_Upload, GUI_DOWNLOAD , BDC_OPEN_GROUP, BDC_INSERT, BDC_CLOSE_GROUP are the fn modules.BADI: SE24, CL_EXITHANDLER -> GET_INSTANCE method, double click, put break point on a function module called CALL METHOD CL_EXITHANDLER=>GET_CLASS_NAME_BY_INTERFACE’Then run the application and it will stop in the breakpoint, now get the badi name using EXIT_NAME in debugger,Go to SE18, SE19 for editing the badi or creating a new implementation

USEREXIT & EXITS in general:Open the program and in system-> status, Find the package. Goto SMOD and Utilities -> Find, search the package and get all exits.Last 4 characters of program matches with the enhancement name .Go to CMOD , create a project to register the enhancement. Click COMPONENTS button and give the enhancement name. Double click enhancement name and get the exits and the Include prog inside the fn.modules.

Why we need LUW when Database LUW automatically rollsback ?  The successful conclusion of a transaction is concluded by a database commit, but an error triggers a database rollback. Since database updates in one LUW cannot be canceled by a database rollback in a subsequent LUW, all database updates in one transaction must be performed in a single LUW.

Bundling database updatesIn the interests of data integrity, all the database updates for transactions which contain more than one LUW should be bundled together into one singleLUW. To prevent overload here, you can delay the execution of FORM routines and functions in ABAP/4 programs.

o PERFORM form ON COMMIT

By using the addition ON COMMIT, you can delay execution of a subroutine until the next ABAP/4 command COMMIT WORK occurs. All subroutines specified in this way are executed together in the LUW concluded by this COMMIT WORK

Page 126: Sap Notebook

o CALL FUNCTION function IN UPDATE TASK  

With this statement, the function module function is registered so that it can be executed by an update process on encountering the next ABAP/4 command COMMIT WORK. In this case (i.e. asynchronous processing), the dialog process does not wait until the function module has been executed. However, with COMMIT WORK AND WAIT (i.e. synchronous processing), the processing does not continue until the function module has finished. All function modules specified as "Update with immediate start" or "Immediate start, no restart" (in shortV1) are executed together in one LUW. All function modules specified as "Update with delayed start (in short V2 are executed in aseparate LUW. The type V2 is mainly used for less urgent database updates (e.g. of a statistical nature).

o CALL FUNCTION function IN BACKGROUND TASK  

With this statement, the function module function is registered so that it can be executed on encountering the next ABAP/4 commandCOMMIT WORK. In this case (i.e. asynchronous processing), the dialog process does not wait until the function module has been executed. All function modules specified in this way are executed together in one LUW by any dialog process.

By using the addition DESTINATION, you can even run the function module in a different R/3 System (see Transactional Remote Function Call). In this case, all function modules specified in this way for one destination executed together in one LUW.

This technique of bundling database updates allows you to distribute the execution of a transaction across several work processes and even across different R/3 Systems.

The ABAP/4 commands COMMIT WORK and ROLLBACK WORK

When using the bundling technique, you must always signal the conclusion of an update transaction by calling the ABAP/4 command COMMIT WORK once . In addition to the database commit, this triggers all the FORM routines and functions registered by this transaction. While the database commit simply leaves a Logical Unit of Work (LUW) after successful conclusion, the ABAP/4 command COMMIT WORK only triggers part of the processing within a transaction. A transaction cannot be considered as successfully completed until this part has also been successfully executed.Although it is not obligatory, you should signal the conclusion of an update transaction that uses the bundling technique by calling the ABAP/4 command COMMIT WORK. This is not only good programming style, but also relieves you from having to release locked objects explicitly (see SAP Locking).If an error is detected during the transaction, you can use the ABAP/4 command ROLLBACK WORK to roll back the database to its level before the beginning of the transaction.

Handling terminations

If the processing of parts of a transaction is delayed, runtime errors may occur. In this case, you should be aware of the following:If a runtime error occurs or if you call the ABAP/4 command MESSAGE with the message

Page 127: Sap Notebook

type 'A' in a FORM routine form registered with PERFORM form ON COMMIT, the LUW that contains the ABAP/4 command COMMIT WORK is automatically canceled by a database rollback (see LUW). Then, no further registeredFORM routines or functions are executed and the user sees the relevant information about the termination on the screen. The ABAP/4 command ROLLBACK WORK results in a runtime error.If a runtime error occurs or if you call the ABAP/4 command ROLLBACK WORK or MESSAGE with the message type 'A' in a V1 function function registered withCALL FUNCTION function IN UPDATE TASK   , all database updates of already executed V1 functions are automatically canceled by a database rollback (seeLUW). V2 functions and functions registered with CALL FUNCTION IN BACKGROUND TASK are not executed. All database updates of the LUW that contain the ABAP/4 command COMMIT WORK and thus all updates of FORM routines registered with PERFORM ON COMMIT are not canceled.If a runtime error occurs or if you call the ABAP/4 command ROLLBACK WORK or MESSAGE with the message type 'A' in a V2 function function registered withCALL FUNCTION function IN UPDATE TASK, only the database updates of this V2 function are automatically canceled by a database rollback (see LUW). Any existing V2 functions and functions registered with CALL FUNCTION IN BACKGROUND TASK are executed.With V1 and V2 functions, the user sees information about the termination on the screen, provided his/her R/3 System has been set up accordingly. By choosing Tools -> Administration -> Monitoring -> Update, he/she can analyze the termination and - after eliminating the cause of the termination - manually restart all functions of the type 'Update with immediate start' and 'Update with delayed start' that belong to the transaction.If a runtime error occurs or if you call the ABAP/4 command ROLLBACK WORK or MESSAGE with the message type 'A' in a function function registered with CALL FUNCTION function IN BACKGROUND TASK, all the database updates of already executed functions of the same destination are automatically canceled by a database rollback (see LUW). The user sees information about the termination on the screen. If an error is detected during the processing of a function registered in this way, you can decide in the program whether all the functions with the same destination should be executed again after the database rollback (see Transactional Remote Function Call).

Short response times in dialog transactionsThe acceptance of dialogs by users depends entirely on transaction response times. In this context, success rests not only on the short response times of a user's "own" transaction. Since the response times of one transaction affects those of another, you must always take response times of other transactions into account when programming. By their nature, database operations contribute most to the increase of response times in dialog transactions.Distributing a transaction across several work processesBy bundling database updates, you can distribute a transaction across several work processes. Asynchronous execution of the database update in an update or background process shortens response times in the dialog process.

Schematic flow of a transaction:

d p1 b1 d f1 g p2 d f2 b2 d c t1   d   w| LUW1  | LUW2    |  ...  | LUWn   |        | LUW ...|-------|---------|-------|--------|--------|---dialog process-->

                                    d  t2   d     d t3  d

Page 128: Sap Notebook

                                    |  LUW  | ... | LUW |----------update process------------|-------|-----|-----|----->

                                              d t4  d                                              | LUW |----------dialog process----------------------|-----|--------->b1, b2,,Registration of functions for execution in the backgroundc,,,,ABAP/4 command COMMIT WORKd,,,,Database commitf1, f2,,Registration of V1 functions for execution in update processg,,,,Registration of V2 functions for execution in update processp1, p2,,Registration of FORM routinest1,,,,Execution of all registered FORM routinest2,,,,Execution of all registered V1 functionst3,,,,Execution of one registered V2 function per LUWt4,,,,Execution of all registered functions in the backgroundw,,,,Wait until all V1 functions have finished in case of,,,,COMMIT WORK AND WAIT

HOW CAN YOU DEBUG SMARTFORM ?

How to Debug SmartForms - Debugging SAP SmartForm in ABAP ?

Debugging SmartForms using Function ModuleIf you want to debug Smartform document in non-modifiable client, then you can try debugging Smartforms Function Module using soft break point.First you need to find the function module name of the target SmartForm for debugging.If you do not know how to get the function module name of the SAP Smart Form, please read the Smart Form tutorial titled How to Find SAP SmartForms Function Module Name.Without knowing the function module name, we can not debug SmartForms in non-modifiable clients.

After you find the function module name, we can now display the ABAP source codes of the SSF FM (Function Module) using the SAP Transaction SE37.

Within the ABAP codes of Smartform FM you can put a soft break-point any where suitable for your debugging Smartforms purposes.

It is better to copy the node name or some parts of the ABAP code in the SAP Smartform and search the text within the SE37 displayed source code of the Smartforms function module (FM).You can place a soft break point in the source code using Ctrl+Shift+12 key combination or

using the Stop icon  .Let's assume that you want to debug Smartforms codes within program lines named '%CODE10' as seen in the followin Smartform screenshot,

First click on the Search button  , and not use the Ctrl+F since searc button has far

Page 129: Sap Notebook

more powerful functionalities than ordinary Ctrl+F search.Enter the text you are searching in the Find text area.You can search for the node name '%CODE10' as well as for a part of your SmartForm code.What is important here in this Search is be sure that you selected the option "In main program".Otherwise your search will take place only for a limited part of the Smartform function module codes.

When the place of the target code block is found, you can run the SAP Smart Form and start to debug Smartform document.

Debug Smart Form using Break-PointIf you are in a modifiable client, or where you can alter the codes of your SAP SmartForms, then there is an other alternative method that you can debug Smart Forms.One way of debugging Smartform documents is placing break points within the Smart Form program lines like shown in below ABAP code :BREAK SAPUserName.* where SAPUserName is your ABAP Developer user* ORBREAK-POINT.* will stop program execution for all SmartForm callers

Smart Form Trace with SFTRACE or SMARTFORM_TRACEAn other SAP tool that might help ABAP developers troubleshoot with Smart Forms and to debug SmartForm can be the Smart Form Trace.You can activate Smart Form Trace for tracing Smartform execution process using the

Page 130: Sap Notebook

SAP transactionSFTRACE or SMARTFORM_TRACE codes.

Posted 7th May 2010 by Blaster Labels: Explain 0 Add a comment

2.May7

Difference between sy-tabix and sy-index Sy-tabix: contains the relative row number of the current record/ no of records in itabSy-index: index number of record which is currently executed in the loop.Posted 7th May 2010 by Blaster Labels: difference between type 0 Add a comment

3.May7

Tcodes for interview SM12 LOCK MANAGEMENTSM3O VIEW MAINTENANCESM31 TABLE MAINTENANCESM34 MAINTAIN DATA IN VIEW CLUSTERSM35 RECORDING BATCH INPUTSM36 BACKGROUND JOB CREATIONSM37 MONITOR BACKGROUND JOBS

SE03 TRANSPORT ORGANIZERSE11 ABAP DICTIONARYSE15/SE84 = REPOSITORY BROWSERSE16 DATA BROWSERSE18 BADI DEFINITIONSE19 BADI IMPLEMENTATIONSE24 CLASS BUILDERSE36 LDBSE37 FUNCTION BUILDERSE38 ABAP EDITORSE41 MENU PAINTERSE51 SCREEN PAINTERSE71 FORM PAINTERSE80 OBJECT NAVIGATORSE81 APPLICATION HIERARCHYSE91 MESSAGESSE93 CREATE TCODESE95 SAP NOTES

SU20 - AUTHORIZATION FIELDS CREATESU21 - AUTHORIZATION OBJECT + CLASS CREATE

Page 131: Sap Notebook

SU53 - DISPLAY AUTHORIZATION FOR USERS

ST05 - SQL TRACESPRO - CUSTOMIZINGSNRO - NUMBER RANGE OBJECTSCDO - CHANGE DOCUMENT OBJECTSHD0 - TRANSACTION VARIANTSHDB - RECORDING - BDC

CMOD - CUSTOMER ENAHANCEMENTSSMOD - SAP ENHANCEMENTSPFTC - FLOW TASK MAINTENANCE IN WORKFLOWSNOTE - NOTE ASSISTANTSHMA - SHARED MEMORY AREA

SPAU - WHO CHANGED THE REPOSITORY OBJECTS AND WHO TRANSPORTEDSPDD - MODIFICATION ASSISTANT

SWDD - WORKFLOWSO10 - STANDARD TEXT - SCRIPTSSW01 - BOR TO CREATE BAPI

BAPI - BAPI EXPLORER TO VIEW BAPI

SMARTFORMS - CREATE SMARTFORMSLSMW - LEGACY SYSTEM MIGRATION WORKBENCH

SQ01 - ABAP QUERY / SQL QUERY REPORTINGSQ02 - INFOSETSQ03 - USERGROUPSPosted 7th May 2010 by Blaster Labels: TCODES 0 Add a comment

4.5.

May7

sap script important programs SAPScript Important ProgramsHere are some useful programs for SAPSCRIPT development/search ...RSTXFCAT  -  Program to find out SAP Scirpt names (Search Program)RSTXCDM1 -  SAPscript: Sample Program for Form PrintingRSTXCNVR -   Converting SAPscript standard text to RAW format (ASCII)RSTXCPDF   -  Routines for Converting OTF Format to PDF FormatRSTXDBUG   - Activate/Deactivate Form DebuggerRSTXFCAT    - Find FormsRSTXFCPY    - Copy Forms Between ClientsRSTXFCOM  - Comparison of Two FormsRSTXFCON   - SAPscript: Conversion of Page Format for FormsRSTXFINF     - Comprehensive Information about a Specific Form

Page 132: Sap Notebook

RSTXHTML   - Conversion of SAPscript Texts (ITF) to HTMLRSTXICON    - List of SAP icons and their names and SAP numbers RSTXSYMB   - List of SAP symbols and their names as well as SAP numberRSTXR3TR     - Transport Program For SAPscript Transport ObjectsRSTXSCAT    - Find StylesRSTXSF01     - TrueType font installation for SAPscript/SmartFormsRSTXTCAT    - Find Standard TextsPosted 7th May 2010 by Blaster

SAP ABAP interview question and answers Big Set

What is SAP?SAP is the name of the company founded in 1972 under the German name (Systems, Applications, and Products in Data Processing) is the leading ERP (Enterprise Resource Planning) software package.

SAP Basics feature* Configuration of the SAP moduleso Transaction SPRO – this is the main tree for all the configuration.

* Function Keyo F1 – Helpo F3 - Backo F4 – Possible entries or matchcode for the field you are accessingo F5 – Selection screeno F7 – Previous screeno F8 – Next screeno F9 – Technical infoo CTRL+X – Cuto CTRL+C – Copyo CTRL+V – Paste

* Navigationo /n Skip to the next record if you are processing one batch input sessiono /bend Cancel a batch input foreground processo /nend Close all R/3 sessions and logoffo /nxxx x Call the transaction xxxx in the same sessiono /O Generate a session listo /Oxxx x Call the transaction xxxx in an additional sessiono /i Delete the current sessiono /h Turn the debug mode ono /$TAB Reset all buffers (for System Administrators)o /$SYNC Synchronize instances buffers (for System Administrators)

In 4.x, you can have long SAP transaction code up to a maximum of 20 character

Different types of ERP ?SAP, BAAN, JD Edwards, Oracle Financials, Siebel, PeopleSoft. Among all the ERP’s most of the companies implemented or trying to implement SAP because of number of advantages over other ERP packages.

What is ERP?

Page 133: Sap Notebook

ERP is a package with the techniques and concepts for the integrated management of business as a whole, for effective use of management resources, to improve the efficiency of an enterprise. Initially, ERP was targeted for manufacturing industry mainly for planning and managing core business like production and financial market. As the growth and merits of ERP package ERP software is designed for basic process of a company from manufacturing to small shops with a target of integrating information across the company.

What is IDES?International Demonstration and Education System. A sample application provided for faster learning and implementation.

What is WORKFLOW and its importance?Business Work Flow: Tool for automatic control and execution of cross-application processes. This involves coordinating the persons involved, the work steps required, the data, which needs to be processed (business objects). The main advantage is reduction in throughput times and the costs involved in managing business processes. Transparency and quality are enhanced by its use.

What is SAP R/3?A third generation set of highly integrated software modules that performs common business function based on multinational leading practice. Takes care of any enterprise however diverse in operation, spread over the world. In R/3 system all the three servers like presentation, application server and database server are located at different system.

What are presentation, application and database servers in SAP R/3?The application layer of an R/3 System is made up of the application servers and the message server. Application programs in an R/3 System are run on application servers. The application servers communicate with the presentation components, the database, and also with each other, using the message server. All the data are stored in a centralized server. This server is called database server.

Name some drawbacks of SAP ?Interfaces are huge problem, Determine where master data resides, Expensive, very complex, demands highly trained staff, lengthy implementation time.

What is BEx?BEx stands for Business Explorer. Bex enables end user to locate reports, view reports, analyze information and can execute queries. The queries in workbook can be saved to their respective roles in the Bex browser. Bex has the following components: Bex Browser, Bex analyzer, Bex Map, Bex Web.

What are variables?Variables are parameters of a query that are set in the parameter query definition and are not filled with values until the queries are inserted into workbooks. There are different types of variables which are used in different application: Characteristics variables, Hierarchies and hierarchy node, Texts, Formulas, Processing types, User entry/Default type, Replacement Path.

Can you create a table with fields not referring to data elements?YES. We can directly give the data type , length and decimals using BUILT-IN TYPE button.

Page 134: Sap Notebook

What are the different types of data dictionary objects? Tables, Structures, Views, Domains, Data elements, Lock objects, Match code objects, Search Helps and Type groups.

What should be the approach for writing a BDC program?STEP 1: CONVERTING THE LEGACY SYSTEM DATA TO A FLAT FILE to internal table CALLED “CONVERSION”.STEP 2: TRANSFERING THE FLAT FILE INTO SAP SYSTEM CALLED “SAP DATA TRANSFER”.STEP 3: DEPENDING UPON THE BDC TYPEi)call transaction(Write the program explicity)ii) create sessions (sessions are created and processed.if success data will transfer).

What is the alternative to batch input session?Call transaction.

How many types of tables exists and what are they in data dictionary?3 types of tablesi)Transparent tables – Exists with the same structure both in dictionary as well as in database exactly with the same data and fields. Both Opensql and Nativesql can be used. ii)Pool tables iii)Cluster tables – These are logical tables that are arranged as records of transparent tables. one cannot use native sql on these tables (only open sql).They are not managable directly using database system tools.

What is a batch input session?BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored in session ie data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.

How to upload data using CATT ? Computer Aided Testing ToolThese are the steps to be followed to Upload data through CATT: Creation of the CATT test case, recording the sample data input. Download the source file template. Modification of the source file. Upload the data from the source file.

What is Smart Forms?Smart Forms allows you to create forms using a graphical design tool with robust functionality, color, and more. Can convert the report to PDF and can be sent through email or can take a print out also.

How can I make a differentiation between dependent and independent data?Client dependent or independent transfer requirements include client specific or cross client objects in the change requests. Workbench objects like SAPscripts are client specific, some entries in customizing are client independent. If a table has MANDT which specifies the client then the data related to that table are client dependent.

If you display the object list for one change request, and then for each object the object attributes, you will find the flag client specific. If one object in the task list has this flag on, then that transport will be client dependent.

Page 135: Sap Notebook

What is the difference between macro and subroutine?

What is the differences between structure and table in data dictionary in ABAP?Structure and table both are 2/2 matrices but there are many differences between table and structure.1. Table can store the data physically but a structure do not store data.2. Table can have primary key but a structure do not have.3. Table can have the technical attribute but a structure do not have.

What is an ABAP?ABAP (Advanced Business Application Programming) is a high level programming language created by the German software company SAP. It is currently positioned as the language for programming SAP’s Web Application Server, part of its NetWeaver platform for building business applications.

What is an ABAP data dictionary?ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.

What are domains and data element?Domains:Domain is the central object for describing the technical characteristics of an attribute of an business objects. It describes the value range of the field. Data Element: It is used to describe the semantic definition of the table fields like description the field. Data element describes how a field can be displayed to end-user.

What is foreign key relationship?A relationship which can be defined between tables and must be explicitly defined at field level. Foreign keys are used to ensure the consistency of data. Data entered should be checked against existing data to ensure that there are now contradiction. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

Describe data class ( APPL0, APPL1, APPL2)Master data: It is the data which is seldom changed.Transaction data: It is the data which is often changed.Organization data: It is a customizing data which is entered in the system when the system is configured and is then rarely changed.

What are indexes?Indexes are described as a copy of a database table reduced to specific fields. This data exists in sorted form. This sorting form ease fast access to the field of the tables. In order that other fields are also read, a pointer to the associated record of the actual table are included in the index. The indexes are activated along with the table and are created automatically with it in the database.

Difference between transparent tables and pooled tables.Transparent tables: Transparent tables in the dictionary has a one-to-one relation with the table in database.Table in the database has the same name as in the dictionary.Its structure corresponds to single database field.  Transparent table holds application data.

Page 136: Sap Notebook

Pooled tables. Pooled tables in the dictionary has a many-to-one relation with the table in database.Table in the database has the different name as in the dictionary.Pooled table are stored in table pool at the database level.

What is an ABAP/4 Query or SAP Query reporting?ABAP/4 Query is a powerful tool to generate simple reports without any coding.ABAP/4 Query can generate the following 3 simple reports:Basic List: It is the simple reports.Statistics: Reports with statistical functions like Average, Percentages.Ranked Lists: For analytical reports. – For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.

What is BDC programming?Transferring of large/external/legacy data into SAP system using Batch Input programming. Batch input is a automatic procedure referred to as BDC(Batch Data Communications). The central component of the transfer is a queue file which receives the data via a batch input programs and groups associated data into sessions.

What are the functional modules used in sequence in BDC?These are the 3 functional modules which are used in a sequence to perform a data transfer successfully using BDC programming: BDC_OPEN_GROUP – Parameters like Name of the client, sessions and user name are specified in this functional modules. BDC_INSERT – It is used to insert the data for one transaction into a session. BDC_CLOSE_GROUP – This is used to close the batch input session.

What are internal tables?Internal tables are a standard Data Object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organizing the contents of database tables according to users need.

What is the difference between collect and sum?SUM.When processing an internal table in a block starting with LOOP and concluded by ENDLOOP , SUM calculates the control totals of all fields of type I , F and P (see also ABAP/4 number types ) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area).

When you use SUM in a LOOP with an explicitly specified output area, this output area must be compatible with the line type of the internal table.When using LOOP to process a sorted extract (see SORT ), the control total of F at the end of the group appears in the field SUM(f) – - if f is type I , F or P .

COLLECT.COLLECT is used to create unique or compressed datasets. The key fields are the default key fields of the internal table itab . If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.

Page 137: Sap Notebook

If, besides its default key fields, the internal table contains number fields,the contents of these number fields are added together if the internal table already contains an entry with the same key fields.

If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.

If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .

After COLLECT , the system field SY-TABIX contains the index of the – existing or new – table entry with default key fields which match those of the entry to be processed.

COLLECT can create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use.

If you process a table with COLLECT , you should also use COLLECT to fill it. Only by doing this can you guarantee that the internal table will actually be unique or compressed, as described above and COLLECT will run very efficiently.

If you use COLLECT with an explicitly specified work area, it must be compatible with the line type of the internal table.                                                                                                                            

Q. What is sequence of event triggered in report?

1) Initialization2) At Selection-Screen3) Start-of-Selection4) Get5) Get Late6) End-of-Selection7) Top-of-Page8) End-of-Page9) At Line Selection10) At User Command11) At PF (nn)

What are events in ABAP reports?Answer1:For Classical Reports,1.Initialization2. At Selection-Screen3. Start-of-selection4. End-of-selection5. Top-of-page6. End-of-page7.At User Command

Page 138: Sap Notebook

8.At PF (nn)

For Interactive Reports,1) Initialization2) At Selection-Screen3) Start-of-Selection4) Get5) Get Late6) End-of-Selection7) Top-of-Page8) End-of-Page9) At Line Selection10) At User Command11) At PF (nn)

What are Control Break Statements? 

1.at first2.at new3. at end4. at last.

What are standard layouts sets in the SAP Script? There are four standard layouts in the SAP Script:1) Header2) Logo3) Main Window4) Footer

What are the various types of selection screen event?SELECTION-SCREEN BEGIN OF BLOCK ABC WITH FRAME TITLE T01.

SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW.CALL SELECTION-SCREEN 500 STARTING AT 10 10.

What is the difference between Table and Template?Table is a dynamic and template is a static

When do we use End-of-selection?End-of-selection event are mostly used‚ when we are writing HR-ABAP code. In the HR-ABAP code, data is retrived in the Start-of-selection event and Printing on the list and all will be done in End-of-selection event.

In events start-of-selection is default event. When we have to use this event explicitly? and Why?The default event in the ABAP is Start-of-selection.We have to call explicitly this event when you are writing other than ths event‚  that is when you write AT SELECTION-SCREEN EVENTS OR INITIALIZATION EVENT etc,you have to explicitely mention the Start-of-selection event while you are writing the logic.

Page 139: Sap Notebook

Before these events called, all the code you have written come into this default Start-of-selection screen event.

What is the differences between ABAP and OOABAP. In which situation we use OOABAP?OOABAP is used to develop BSP/PCUI applications and also anthing involved object oriented like BADIs, SmartForms..etc.where as ABAP is used to develop traditional programs in R/3.

What is table buffer? Which type of tables used this buffer?buffer is nothing but a memory area. table is buffered means that table information is available on application server. when you call data from database table it will come from application server.transperent and pooled tables are buffered. cluster tables can not buffered.

What is the use of pretty printer ?Exactly where can we link the functional module to abap coding.Pretty Printer is used to format the ABAP Code we write in ABAP Editor ,like KEY WORDS in Capitals and remaining are in small letters which is also depend on system settings.-------------------------------------------------------------------------We can call the function module in the ABAP Code .Press the Pattern button on Appl. tool bar then u will get box where u write the function module NAME which u want to call in the code by selecting the radio button CALL FUNCTION. In this way we link function module to ABAP Code.

What is the difference between SAP memory and ABAP memory?Answer1:data sending between main sessions using get parameter and set parameter is sap memorydata sending between internal sessions using import or export parameters is abap memory

Answer2:sap memory is a global memory whereas abap memory is local memory.

For example, we have four programs in abap memory and assigned some varibles to a particular program in abap memory then those varibles can’t be used by anyother program in abap memory i.e., the variables are only for that program and also local to that memory,whereas sap memory can access all the abap memory or else it can perform any kind of modifications.

Answer3:SAP memory is available to the user during the entire terminal session.ABAP memory is available to the user during life time of external session.-------------------------------------------------------------------------What is the difference between Type and Like?Answer1:TYPE, you assign datatype directly to the data object while declaring.LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.

Answer2:

Page 140: Sap Notebook

Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.

Answer3:type refers the existing data typelike refers the existing data object-------------------------------------------------------------------------What is Tcode SE16. For what is it used. Explain briefly?Answer1:SE16 is a T-code for Data BrowserGenerally used to search the fields of SAP Tables . and respective data.

What are different ABAP/4 editors? What are the differences?The 2 editors are se38 and se80 both have the abap editor in place. In se38 you can go create programs and view online reports and basically do all thedevelopmet of objects in this editor.

In se80 ( object navigator) there are additional features such as creating packages,module pool , function group ,classes, programs ( where you can create ur programs) and BSP applications .-------------------------------------------------------------------------What is difference between dialog program and a report?Report is a excecutable programDialog is a module pool program.It has to be executed via a transaction only.Dialog programming is used for customization ofscreens

How do you connect to the remote server if you are working from the office for the client in remote place.WAS web application server or ITS are generally used for this purpose. If you are sitting at your office with a server which is in the system and the other server is at the clients place you can generate IDOC, intermidiate documents which carry the data you want to transfer or the documents you want to transfer, these IDOC are interpretted by the system at the recieving end with the message class with which it is bound with. If you want to logon a system which is very distant..then remote login can be used this depends on the internet speed.

Explain about roll area , Dispatcher, ABAP-Processor.Dispatcher recieves the request from client and assigns the request to one of the work process.Roll area: Each workprocess works in a particular memory known as Role Area, which consists of User context and session data.ABAP- Processor :is an interpretor which can execute logic

------------------------------------------------------------------------- Which one is not an exit comand ? (Exit, cancel, stop, back)STOP.Effect :The statement STOP is only to be used in executable programs

EXIT.Effect :If the EXIT statement is executed outside of a loop, it will immediately terminate the current processing block.

Page 141: Sap Notebook

BACK.Effect : This statement positions the list cursor on the first position of the first line in a logical unit.

So “Cancel” is not an exit command

What is Field symbol ?You can use field symbols to make the program more dynamic. In this example the name of a table control is substituted by a field symbol. Thus you cal call the form with any internal table, using the name of the table control as a parameter.

fieldsymbol has the same concept as pointer in c,fieldsymbol don’t point to a data type like char, num instead of that it points to the memory block. the syntax for fieldsymbol is

-------------------------------------------------------------------------What is lock object ?LockObjects used to synchornize access of several users using same data.-------------------------------------------------------------------------Why BAPI need then BDC ?BAPI”S provide the standard interface to other applications apart from SAP and within differnt vesions of SAP too. Also it is OOD bases so dosen”t depends on screen flow. BDC gets failed if we make changes for screen changes through IMG customization

What is a collect statement? How is it different from append?APPEND :IT IS USED TO GET THE RECORD FROM THE INTERNAL TABLE HEADER TO THE BODY AREAIT ALLOWS DUPLICATION

COLLECT:IT IS USED TO A GET A RECORD FROM HEADER TO THE BODY AREA BUT IT WILL NOT ALLOW ANY DUPLICATION EXCEPT IF THERE IS ANY NUMERIC FIELS IT ADDS THAT FIELDS DATA BUT NOT AS A NEW RECORD

On ABAP: Did you set up a workflow? Are you familiar with all steps for setting up a workflow?Yes.Execute the Txn SWDD(Creating a new Workflow).In the header of the Workflow, define the Business Object and Event you refer to for triggering the Wf.Create the Steps required for your workflow(Activity).Inside the Activity, Create the task and assign the Business Object and the related method for that business object.Activate the Workflow.

In the select’ statement what is group by?The GROUP-BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. 

Page 142: Sap Notebook

SELECT     carrid    MIN( price )     MAX( price )  INTO     (carrid, minimum, maximum)  FROM     sflight  GROUP BY carrid.  WRITE: / carrid, minimum, maximum.ENDSELECT.

From Excel to ABAP – Is batch mode possible ?DATA w_file TYPE string.* Convert the file path into stringw_file = p_input.

* Internal Table should have same field sequence as EXCEL File.

CLEAR t_upload.REFRESH t_upload.

* Call function to upload the data into internal tableCALL FUNCTION ‘GUI_UPLOAD’EXPORTINGfilename = w_filefiletype = ‘ASC’has_field_separator = ‘X’TABLESdata_tab = t_upload

* Delete the first row of heading from the uploaded tableDELETE t_upload INDEX 1.ENDIF. ” IF sy-subrc EQ 0.

What are the advantages and disadvantages of using views in ABAP programming ?

Advantages: view is used to retrieve the data very fastly from the database tables*memory wastage is reduced*faster than joins to retrieve the data from database tables

disadvantages:view is not a container,it will not hold the data*view memory is not permanent memory

How data is stored in cluster table?A cluster table contains data from multiple DDIC tables.It stores data as a name value pair ( varkey, vardata)

How to create client independent tables?client independent tables:the table in which the first field is not mandt is the client independent tables*mandt is the field with mandt as the data element*automatically client which we login is populated to mandt

Page 143: Sap Notebook

What type of user exits ?1.function exit2.menu exit3.screen exit.4.field exit.

How can you debug a script form?SE71 - give the form name  then go to utilities = > activate debugger

How do we debug sapscript? Use RstxDBUG orFirst put Break point in Print program where ever you want to stop the execution.After in SE71 give your form name and go to Utilities = > Active De-bugger.Then go to your transcation like VF03(for Invoice or Credit memo) etc to see the print preview or print the form execute it.When you execute it the the form Debugging will get activated and you can see your Form execution step by step.

What are the different types of data dictionary objects?Answer1Data Dictionary Objects* Tables* Views* Domain* Data Element* Type Groups* Search Helps/Matchcode Objects* Lock objects* Structure type* Table Types

A table is buffered. By select statement I don’t want to get the data from table buffer. I want to get the data from database. How?SELECT… FROM * tablename   BYPASSING BUFFER. ..

What are user exits? What are customer exits? User exit is a part of Modification.Customer Exit is a part of Enhancement. Customer exit has Function exit, menu exit and screen exit.

User exit -developed for SD (include names will be UserExit_name which has empty subroutines)A user exit is a three character code that instructs the system to access a program during system processing.SXX: S is for standard exits that are delivered by SAP.   XX represents the 2-digit exit number.UXX: U is for user exits that are defined by the user.  XX represents the 2-digit exit number

What is the difference between start_form and open_form in scripts? Why is it necessary to close a form always once it is opened?

Start_form– is used to initialize the layout.Open_form — is used to initialize the spool request.

Page 144: Sap Notebook

You must end form printing by using the function module CLOSE_FORM. Otherwise, the system does not print or display anything.--------------------------------------------------------------------What is difference between  At New Field and ON Change?In case if you want calculate sub total for same values in a field you can use the atnew statement.ie:For example in a table sflight, there are 2 fields carrid ( airline id) and seatsmax( seat available). In case if you want calculate the total number of seats available for each carrrid.

In the same scenario if you use onchange of it will not return the total seats for each carrid, instead it will return the total seat count for the entire table( ie: for all the carrids in the table.

Another diffrence is atnew can be used only between loop and end loop whereas on change of can also be used in select- endselect , do -enddo.

 Another diffrence is while using atnew in case if you code any write statements between atnew and end at the value for the numeric fields will be returned as 0 and that of no numeric fields will be returned as *(asteriks). But in on change of the orginal values will be returned.----------------------------------------------------------------------Select single * and select upto 1 row diffrence.The select single * from stmt selects only one row form the database table and puts it in to the work area(internal table).The select upto N rows stmt selects all the rows from the database table but writes only the specified number of rows specified by the n into the internal table. If its given as upto 1 rows only 1 row is written in to the internal table.-------------------------------------------------------------------When you create sales report, What you can see in that report ? What are those field names or data element names?

vbak-auart, “ORDER TYPEvbak-audat, “DOCUMENT DATEvbak-kunnr, “CUSTOMERvbak-bstnk, “PURCHASEORDERNOvbak-submi, “collective novbrp-posnr, “ITEMvbrp-matnr, “MATERIAL NUMBERvbrp-arktx, “DESCRIPTIONvbrp-fkimg, “ORDER QTYvbrp-vkbur, “SALESOFFICEvbrp-aubel, “SALES DOCUMENTvbrk-netwr, “NETPRICEvbrk-vbeln, “BILLINGDOCNOvbrk-knumv, “DOC.CONDITIONkna1-name1, “CUSTOMERNAMEvbrp-werks, “PLANTvbrk-kunrg, “PAYERkna1-name1, “PAYER NAMEvbpa-kunnr, “EMPLOYEENOvbrk-netwr, “DISCOUNTvbrk-netwr,”NETAMTvbrk-netwr,”INVAMT

Page 145: Sap Notebook

vbrk-fkart, “billing typevbrk-netwr, “CSTkonv-kbetr, “CST PERvbrk-netwr, “LSTkonv-kbetr, “LST PERvbrk-netwr, “EDkonv-kbetr, “ED PERvbrk-netwr, “Ecskonv-kbetr, “Ecs PERvbrk-netwr, “SURCHARGEvbrk-fkdat, “BILLINGDATEkna1-name1, “EMPLOYEENAMEvbak-bstdk, “PODATElikp-bolnr, “Bill Of Ladinglikp-traty, “Means of Transport Typelikp-traid, “Means of Transport IDvbpa-kunnr, “Bill To Partykna1-name1, “Bill To Party Namevbrk-netwr, “Net Amount Basic Amount – Discount

How to assign multiple transaction codes in a session method to BDC_Insert function module?Call function ‘ BDC_Insert’exportingtr. code = ‘ enter tr.code1 here’table = ‘give an internal table related totr.code1 here’call function ‘BDC_INSERT’exportingtr.code = ‘ enter 2nd tr code’tables = ‘ 2nd internal table’-----------------------------------------------------“Check” and “Continue”. What is the difference?Check statement, checks the condition with in a loop and if it satisfies the condition, the control moves to next statement in the loop. Otherwise, it terminates the loop.

Continue statement, acts like goto statement. If the condition is true, it processes the remaining statements and if the condition is false, then the control moves to the top of loop.----------------------------------------------------At-Line selection, At user-command etc..,In at line-selection system defined fcode will be generatedIn at user-command we need to define the fcode and fkey manually then only it will triggers.----------------------------------------------------“Exit” and “Stop”. What is the difference?exit statments is exits the current loop. and moving to next loopbut stop statement move to end of selection. it’s not check all other loops.----------------------------------------------------What is the reserve command?RESERVEIf insufficient space is there for listing output reserve statement encounters NEW-PAGE.But before going to new page it processes END-OF-PAGE.----------------------------------------------------

Page 146: Sap Notebook

How can validate input values in selection screen and which event was fired?Answer1:We can Validate Selection Screen With the Help of the Following Events, the Event Follows the Same hierachy.

AT SELECTION-SCREEN ONAT SELECTION-SCREEN ON BLOCKAT SELECTION-SCREEN OUTPUTAT SELECTION-SCREEN.

Answer2:At selection-screen onselect stmt —————— where = .if sy-subrc = 0.validation success for LOw value in selection screenAt selection-screen onselect stmt——————– where =if sy-subrc NE 0.validation failure on high value in the selection field.elsesuccess.endif----------------------------------------------------BDC Transaction code? = bdc recordingTransaction code for bdc :SHDB----------------------------------------------------How to navigate basic list to secondary list?We can Navigate from basic list to secondary list with the help the event called AT LINE-SELECTION. for every Secondary List the System Field SY-LSIND increases by 1. So there will be Totally 21 list possible in SAP.

One Basic List 20 Secondary List.----------------------------------------------------Which is the First character of creating LockObject?LockObjects always starts with character ‘E’.----------------------------------------------------

How many types of standard SAP Internal Tables?1)standered table2)index table3)hashed table4)sorted table----------------------------------------------------What is the Difference Between Tablecontrols and Step Loops?Table controls have both horizontal and vertical scrollers and cursor control logic is designed implicitly.Step loops have only horizontal scrollers and cursor control logic is to be designed by the user explicitly.----------------------------------------------------What are the Events in Dialog Programs?Events in Dialog Programming are:PBO-Process Before OutputPAI-Process AFter Input

Page 147: Sap Notebook

POH-Process on Help RequestPOV-Process on Value Request----------------------------------------------------How many ways you can create Table?two ways.1.Top-to-bottom approach: first fields are defined and later domain and data element are defined.2.Bottom-to-top approach:  first domain and data element are defined and later fields are defined.----------------------------------------------------What are the Cluster Tables?Cluster tables contain continuous text, for example, documentation. Several cluster tables can be combined to form a table cluster. Several logical lines of different tables are combined to form a physical record in this table type. This permits object-by-object storage or object-by-object access. In order to combine tables in clusters, at least parts of the keys must agree. Several cluster tables are stored in one corresponding table on the database.----------------------------------------------------What are function modules in LDB?Function modules in LDB’s aregetputget late----------------------------------------------------What are Difference Between Classical Batch Input and Call Transaction?Answer1:1.In Batch input many transactions can be executed, where as in Call transcation only one transactioin can be executed.2.BI is Synchronous process, Ct is both Asynchronous and Synchronous.3.BI Sessions cannot be runed parallel.4.Log file is generated automaticly in BI, errors can be found through BDCMSGCOLL.5.batch input works for multiple applications where as call transactions doen’t work6.batch input has sy-subrc check with the database where as call transaction doesn’t have so call transaction is fast.----------------------------------------------------How can you call the Sessions?using transaction code SM35----------------------------------------------------Can you call Report in SAP Script?Yes, we can.Just write in Line editor:/:perform f_display_report————–———SUBMIT REPORT-———-/:endperformTHIS PERFORM WOULD BE DECLARED IN THE PRINT PROGRAMME IN WHICH YOU CAN ALWAYS WRITE STATEMENT---------------------------------------------------------------------How to Upload Logo to Layout Set and what is Program Name?You can also upload a Logo in BMP format – it has to be saved as “%^ Colours if it is a colour Bitmap.If you don’t save a colour Bitmap as 256 Colours then it will be uploaded in Black.This can be done in Smart Forms, SAPScript or Transaction SE78

Page 148: Sap Notebook

-//-//-What are the SET Parameter and GET Parameter?To use parameter IDs, you need to “set” (store) values in the global memory area and then “get” (retrieve) values from this parameter ID memory area. §IIn the case of an online program, you will “set” values from screen fields and you will “get” these values for screen fields. §YYou can perform this “set/get” function two ways: § Use the ABAP statements “SET PARAMETER ID” and “GET PARAMETER ID”. § Use the field attributes “SPA” and “GPA” . §RRemember that parameter IDs can only be used with ABAP Dictionary fields because parameter IDs are linked to data elements. The appropriate data elements must have a parameter IDs for this “set/get” function to work.

What are Text Elements?Text elements makes program easier to maintain program texts in different languages.These are used for maintainig list headers,selectiontexts in programs

What is an Interactive Report?An Interactive report allows the user to participate in retrieving and present data at each level.while classical report doesn’t have access to interact

What are Layout set Elements?layout set elements are1.header 2.peragraph formats 3. character formats 4. windows 5. pages 6.page windows

Distinguish between setscreen and call screen?In the case of setscreen the entire processing of the current screen takes place and then the system branches out to next screen.if u want to branch out to the next screen without processing the current screen then LEAVE SCREEN should be used along with SET SCREEN.

CALL SCREEN is usually used for pop up screens.

What is ABAP Memory and SAP Memory?Answer1;SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters .

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory.

Answer2;1. SAP memory is for cross-transaction Applications and ABAP/4 memory is transaction-specific.

2. The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its contents are retained across transaction boundaries as well as external and internal sessions. The contents of the ABAP/4 memory

Page 149: Sap Notebook

are retained only during the lifetime of an external session. You can retain or pass data across internal sessions.

3. The SET PARAMETER and GET PARAMETER statements allow you to write to, or read from, the SAP memory. The EXPORT TO MEMORY and IMPORT FROM MEMORY statements allow you to write data to, or read data from, the ABAP memory.

Explain Check Table and Value Table ?check tabke works at table level and value table works at domain level.check table is nothing but master table that u will create with valid set of values.value table it provides the list of values and it will automatically proposed as a check table while creating foreing key relationship

How many types of Standard Internal Tables?- STANDARD TABLE:The key is, by default, set to NON-UNIQUE. You may not usethe UNIQUE addition.

- SORTED TABLE:Unlike stadard tables, sorted table have no default settingfor the uniqueness attribute. If you do not specify eitherUNIQUE or NON-UNIQUE, the system defines a generic tabletype, where uniqueness is irrelevant. You can use generictypes to specify the type of generic subroutine parameters.

- HASHED TABLE:Hashed tables have no default setting. You must use theUNIQUE addition with hashed tables. You may not useNON-UNIQUE.

What is Refresh in Internal Table?‘Refresh’ is the keyworld which clears the contents of an internal table body.

What is the Difference Between Collect and Sum?COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area.If the system finds an entry, the numeric fields that are not part of the table key (see ABAP number types) are added to the sum total of the existing entries. If it does not find an entry, the system creates a new entry instead.The way in which the system finds the entries depends on the type of the internal table:

- STANDARD TABLE:The system creates a temporary hash administration for the table to find the entries. This means that the runtime required to find them does not depend on the number of table entries. The administration is temporary, since it is invalidated by operations like DELETE, INSERT, MODIFY, SORT, …). A subsequent COLLECT is then no longer independent of the table size, because the system has to use a linear search to find entries. For this reason, you should only use COLLECT to fill standard tables.

- SORTED TABLE:The system uses a binary search to find the entries. There is a logarithmic relationship between the number of table entries and the search time.

Page 150: Sap Notebook

What are the ways of creating Tables?There are two ways to create table1) top-down approach2) bottom-up approach

What are Function Modules?Answer1:Function modules is a extranal subroutine.we can call it to outside the program.its a mini program. its used for redues the coding,easy to find error.

Answer2:Function modules is like a small program (is not a suboutine because sub-routines are not standalone objects-i.e we cannot execute them alone) which are similar to ‘functions’ in C.

We can pass the varible and get the return values even with out knowing what is happening in its code.

They are standalone programs-i.e.we can debug and execute them alone unlike subroutines and macros and includes.

What is CAT?“CAT” Computer Aided Test Tool. Used to create test cases for application testing purposes.

What is LDB?Logical Database is an ABAP program which retrieves data from various tablesWhich are interrelated and provides a read only view of the data.

What are the EVENTS in Report Program? What are EVENTS In Interactive Report and Explain?Classical Report Events areLOAD OF PROGRAM.INITIALIZATION.AT SELECTION-SCREEN.START-OF-SELECTION.TOP-OF-PAGE.END-OF-PAGE.END-OF-SELECTION.

Interactive events areAT LINE-SELECTION.AT USER-COMMAND.TOP-OF-PAGE DURING LINE-SELECTION.

AT LINE-SELECTION:Allows the user to interact with the lists.AT USER-COMMAND:USed for handling Push buttons.SET PF-STATUS:Provides User Interface.

What are the various techniques of BDC?call transactionsession methoddirect input method

What is SQL Trace?

Page 151: Sap Notebook

SQL Tracer is a tool used to measure the performance of ABAP program.T.code :st05

What is LUW?It is a span of time during which database records are updated eithercommit or rollback.

Have you worked with reading and writing data on to files?YES, open dataset for output. read dataset from itab. close dataset .

Have you created tables in SAP? What are client dependent and independent tables? How do you create independent tables?Tables which are having MANDT field is called as client dependent tables. Tables which are not having MANDT field is called as client dependent tables.

Have you used SM30 and SM31 transactions?sm30 is used to view the ‘ Call Up View Maintenance ‘ and SM31 is to view the ‘ Table maintenance ‘ with

How many dictionary objects are there and list allAvailable Dictionary Objects are Domains, Viwes, Match Codes, Lock Objects, Structures, Data Elements, Intenal Types.

What is the difference between transparent and non transparent database tables?Transparent tables have 1 – 1 cardinality b/w Data Dictionary and Database, and non transparent ( Cluster and Pooled) tables have Many – 1 cardinality.

Transparent table can access with using OPen & NAtive SQL stmts where as Nontransparent only OPen Sql.

Transparent trables can store Table relevent data and non transparent tables can store system data/ application data based on the transparent tables

What is meant by BDC. How many methods of BDC are there?BDC -> BATCH DATA COMMUNICATION.METHODS OF BDC-> Direct Input method, Batch Input Session method, Call transaction method.

What are the difference between table controls and step loops in dialog programming?1. Function modules use a special screen to define the parameters where as subroutines use the same ABAP/4 editor to define its parameters.2. Tables work area can be commonly shared by calling program and subroutine where as function modules do not share commonly.3. Calling a function module syntax (Call function.) is different from calling a subroutine syntax (perform….).4. With raise statement user can exit from a function module where as exit is used in subroutines.

What is ALE, IDOC , EDI , RFC. Explain briefly.ALE: application linking enablingIDOC: intermediatary documentsEDI: electronic data interchangeRFC: remote function call

Page 152: Sap Notebook

What is a binary search?Binary Search is used in internal table for searching the records. its means record searched one by one from top & bottom both side.so its a easy nd fast way to find the record.bt pointer searching is better.

Types of User Exits, what kind of work is done on these exits?File Exit, Menu Exit, Function Exit.

How will you find out where the user exits are available?CMOD : This transaction allows you to create a PROJECT by identifying its ENHANCEMENT(S). After determining all of the ENHANCEMENTS that are part of the PROJECT, you will have to activate the PROJECT. You will still need to code your user-exit; therefore, you may want to wait until this step is completed before activating the PROJECT.

§SMOD : This transaction allows you to create an ENHANCEMENT, which you will include in a PROJECT, by identifying its COMPONENT(S). In the case where SAP has already created an ENHANCEMENT for its pre-defined user-exits, you will not need to use transaction SMOD; instead, you should just use transaction CMOD.

Have you created any transactions?Yes,We can use TC SE93 for creating our own transaction code.

Difference between Table-Controls and Step-loops?Table controls are modified / mproved versions of step loops.in controls we can do,horizontal scrolling,vertical scrolling,scrolling in a perticular field,resize the table,can save the settings for future use,can make selective columns editable,….etcthese things are not possible with step loops.step loops are controlled by loop-endloop statements.

Import and ExportABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.

How many interactive reports did you write?In an Interactive Report, user can define maximum 20 secondary lists.

What is an “Unpack commandUNPACK field1TO field2 .Unpacks the packed field field1 and places it in the field field2 with leading zeros. If field2 is too short, it is truncated on the left.

Page 153: Sap Notebook

What is the difference between updated project and end to end project. explainAnswer1:Some organisations select to implement SAP module by module, thus gets updated as per their convenience / schedule. This is called as updated project.

Some organisations simply plan all integrated functional modules and decide to go-live with all functional modules and take their entire operations on SAP. This is called as End to End SAP implementation project.

Answer2:Upgrade Project is a project where in SAP is already in place and it is the version upgrade from a lower end to a higher version.

End to End project is a project where SAP is implemented for the first time.

The other way is to assign that item to the vendor and maintain info records and update it by using ME11. This can also be done manualy.

Answer2:This is not possible. Price comaprison session only gives you the idea which supplier has given the best price for a particular material.you have to raise the po ME21N transaction only.

Answer3:The vendor who has got best price will have a unique quotation number. USe ME21N transaction and create PO with respect RFQ from Overview tab .

What is the difference between internal table and structure?There are there types of structure:-1. Flat structure( elementary fields)2. Nested structure ( type reference to other structure)3. deep structure ( type reference to database tables)

Explain row type and line type conceptline type refers to the structure of an internal table,whereas row type is the actual part that contains the data and it refers to the table body.creating internal table using line type and row type concept is for reusability purpose.Line type and Row type are defined at DDIC LEVEL.

Can any one give me brief explanation about internal tables, and work area ?*An internal table is a run time instance. It get created when program starts execution.*It get destroyed when program terminates. It has two different parts: HeaderLine(optional) and Body(Compulsory).*Any value that comes to or goes from interanal table, that travels through headerline.

How to eliminate duplicate entries in internal tables?Answer1:SORT itab.DELETE ADJACENT DUPLICATES FROM itab COMPARING ALL FIELDS.

Page 154: Sap Notebook

Answer2:The following syntax:SORT itab .delete adjcent duplicates from itab comparing .

Size of the internal tables?The size of the internal tables are set using the ‘occurs n’ clause. Here n refers to a integer number that specifies the size. Usually its given as ‘occurs 0′ which creates an itab with the memmory space of 8kb.

What is the basic difference internal tables and database tables? How can we differentiate by looking at the tables? Handling of internal tablesThe basic difference is database tables are stored in DB serverand the internal tables are virtual tables these are created run time onlyInternal tables are created dynamically, the memory of internal tables is notpermant memory, for internal tables the memory will be created in the application server and it is external memory and terminates after the program termination.What is the difference between updated project and end to end project. explainAnswer1:Some organisations select to implement SAP module by module, thus gets updated as per their convenience / schedule. This is called as updated project.

Some organisations simply plan all integrated functional modules and decide to go-live with all functional modules and take their entire operations on SAP. This is called as End to End SAP implementation project.

Answer2:Upgrade Project is a project where in SAP is already in place and it is the version upgrade from a lower end to a higher version.

End to End project is a project where SAP is implemented for the first time.

Describe how to setup a printer in SAP or where they would look to research why a user/users can not print?SPAD, SP01, SM50, SU01 …

Have you used performance tuning? What major steps will you use for these?First of all tuning can be done in three ways: disk i/o ,sql tunning , memory tunning,Before tunning u have to get the status of your database usingOracle utility called statpack , tkprof, then you should go for tunning

Posted 6th May 2010 by Blaster Labels: Big set ABAP Interview questions 0 Add a comment

6.May6

Difference between check table and value table?

Page 155: Sap Notebook

Difference between a check table and a value tableValue Table ( wont be used in search help)This is maintained at Domain Level.When ever you create a domain , you can entered allowed values.   For example  you go to Domain   SHKZG - Debit/credit indicator.  Here only allowed values is H or S.When ever you use this Domain, the system will forces you to enter only these values.This is a sort of master check . To be maintained as a customization object. This mean that if you want to enter values to this table you have to create a development request & transport the same.Check table(used in search help)For example you have Employee master table & Employee Transaction table.When ever an employee Transacts we need to check whether that employee exists , so we can refer to the employee master table.This is nothing but a Parent & Child relationship .  Here data can be maintained at client level , no development involved.As per DBMS what we call foregin key table, is called as check table in SAP.

There is 1 more important Difference in Value Table and Check Table is that:

1. The contents of the check will be used as an input help(F4 Help) for a particular field on which a check table is assigned.    But the contents of Value Table are never used in Input Help.Posted 6th May 2010 by Blaster Labels: difference between type 0 Add a comment

7.8.

May6

How can you bypass buffer in SAP

 Statements Bypassing the Buffer  More complex queries get passed onto the database server instead of using the table buffer. Such queries are the following:

        Any SELECT with a  sub query or with  joins

        Any  set function (COUNT, MIN, MAX, SUM, AVG)

         GROUP BY

         HAVING

         SELECT DISTINCT

         ORDER BY (other than PRIMARY KEY) – the data stored in the buffer is always ordered by the primary key. Any other ordering must be performed by the database.

The SELECT statements bypass the buffer:

Page 156: Sap Notebook

       The BYPASSING BUFFER addition in the FROM clause2        The DISTINCT addition in the SELECT clause        Aggregate expressions in the SELECT clause        Joins in the FROM clause        The IS NULLcondition in the WHERE clause        Subqueries in the WHERE clause        The ORDER BY clause        The GROUP BY clause        The FOR UPDATEaddition--------------------------------------------------------------------------------------------------------------

Also

Queries Bypassing the Buffer     SELECT /*@ SAP BYPASSING BUFFER */ * FROM MYTAB    WHERE KEY1 = ? AND KEY2 = ?SELECT * FROM MYTAB WHERE KEY1 = ?

SELECT * FROM MYTAB    WHERE KEY1 = ? AND KEY2 = ? OR KEY1 = ?

SELECT MAX(DATA) FROM MYTAB WHERE KEY1 = ? KEY2 = ?

SELECT * FROM MYTAB    WHERE KEY1 = ? AND KEY2 = ? AND DATA =   (SELECT DATA FROM MYTAB WHERE KEY1 = ? AND KEY2 = ?)

Posted 6th May 2010 by Blaster Labels: Explain 0 Add a comment

9.May6

Difference between Data class and delivery class? Data Class

The data class determines the physical area of the database (tablespace) in which the table is created.

You set the data class in the technical settings for the table.

There are 5 data classes only three of which are appropriate for application tables:

· APPL0- Master data (data frequently accessed but rarely updated).

· APPL1- Transaction data (data that is changed frequently).

· APPL2- Organizational data (customizing data that is entered when system is configured and then rarely changed).

The other two types are:

· USR - Customer Data class

Page 157: Sap Notebook

· USR1 – Customer data class - Intended for customer’s own developments.

Delivery Class

· The delivery class controls the degree to which the SAP or the customer is responsible for table maintenance.

· Whether SAP provides the table with or without contents.

· Determines the table type.

· Determines how the table behaves when it is first installed, at upgrade, when it is transported, and when a client copy is performed.

There are the following development classes: A,S,C,L

* A: Application table (master and transaction data).* C: Customer table, data is only maintained by the customer.* L: Table for storing temporary data.* G: Customer table, SAP may insert new data records but may not overwrite or delete existing ones. The customer namespace must be defined in table TRESC. To define the customer namespace use report RDDKOR54. You can start it directly from the table maintenance by choosing Customer namespace definition on the Attributes tab.* E: System table with its own namespace for customer entries. The customer namespace must be defined in table TRESC. To define the customer namespace use report RDDKOR54. You can start it directly from the table maintenance by choosing Customer namespace definition on the Attributes tab.* S: System table, data changes have the status of program changes.* W: System table (e.g. table of the development environment) whose data is transported with its own transport objects (e.g. R3TR PROG, R3TR TABL, etc.)Posted 6th May 2010 by Blaster Labels: difference between type

Types of index in SAP

What is meant by Primary Index and Secondary Index

Explain the what is primary and secondary index.

The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

You can also create further indexes on a table. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access.

Different indexes on the same table are distinguished with a three-place index identifier.Lets say you have an ODS and the Primary Key is defined as Document No, Cal_day. These two fields insure that the records are unqiue, but lets lay you frequently want to run queries where you selct data based on the Business Area and Document Type. In this case, we could create a secondary index on Bus Area, Doc Type. Then when the

Page 158: Sap Notebook

query runs, instead of having to read every record, it can use the index to select records that contain just the Bus Area and Doc type values you are looking for.

To request the DB to use the secondary index you created:

SELECT * FROM SPFLI  %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'

Basic ABAP interview questions and answers

1. What is SAP R/3? The third generation set of highly integrated software modules that perform business fns. based on multi national leading practices.

2. Primary key field is the the database table column which helps in identifying the records uniquely in master table.

Foreign key field is the database table column of a details table which is dependent on the primary key field of a parent table . 

3. What is a report? Report is Printing data as per customer requirement.

4. What is sap script? Is a text Text processing system which is used to print the business document such as sales order , purchase order etc.

5. What is subroutine pool in sap script? When it is used? It contains the definitions of the subroutines. It is also used to detch additional data to print from the layout when the additional data has to be printed without changing the standard driver program.

6. We cannot create a layout in SAP script without using MainWindow.

7. We can keep Mainwindow on the same page in a layout for 99 times.

8. Types of Windows: Main window, Variable window, Constant Window.

9. SAP scripts are CLIENT IN-DEPENDENT. 

10. Which table has all Print program names and Form Names? TNAPR

11. List the Fn. Modules used in Scripts: Open_Form , Start_Form

Page 159: Sap Notebook

12. Sap Script Components: Paragraph format, Character formats

13. Wat is page in sap script? Page is a container for windows.

14. What is window in script? The page which contains the window are called page windows are the window pages.

15. What is Character Format in script? A line can be printed in different format but by using character format within the same paragraph.

16. What is Symbol and types of symbols in script? Printing data on Layout is always done through Symbols. It starts and ends with &

17. Types of symbols in scripts? SYSTEM symbols, STANDARD symbols, PROGRAM symbols, TEXT symbols.

18. System Symbols? &DATE&, &YEAR&, &PAGE&

19. Standard Symbols? &DSM& can be found in table TTDTG

20. Program Symbols? Are variables from the driver program.&wa_kna1-kunnr&

21. Text symbols? Are defined in the layout itself.

22. How to debug SAP SCRIPTS? Execute the program RstxDBUG.

23. Text elements? Are used to identify the block of statements from page windows.

24. Different ways of uploading logos in scripts? Can upload only TIFF and BMP into Business Document Server tcode: SE78 OR use transaction RSTX LDMC to upload the image through program.  

25. Text elements in Scripts:  

26. Symbol &SAPSCRIPT-FROMPAGES& gives the total number of pages of currently formatted print request.

27. Symbol &SAPSCRIPT-SUBRC& gives the value after executing the INCLUDE statement

28. Symbol & SAPSCRIPT-JOBPAGES& gives the total number of pages of currently formatted form.

29. How Language Translation in script can be done ? Create a text as Standard Text through SO10 then Insert=>text=>standard.

30. Explain ADDRESS-ENDADDRESS control command? This control command formats an address according to the postal convention of the recipient country defined in the country parameter.

31. How to read data from standard TEXT in abap? CALL FM : READ TEXT

32. How you upload / download scripts to pc? Execute RSTXSCRP

Page 160: Sap Notebook

33. Tcodes for Scripts: SE71 - Form painter, SE72: Style maintenance, SE63: Language translation, SE78: Graphics management, SO10: Create Standard Text module.

34. Copy Forms between Clients - SapScripts? RSTXFCPY

35. COMPARISON OF 2 FORMS? RSTXFCOM

36. TRANSPORT PROGRAM FOR SAP SCRIPT? RSTX3TR

37. Transport the standard text ? RSTXTRAN

38. SAPSCRIPT SPOOL REQUEST TO PDF ? RSTXPDF4

39. How to print the footer note only on the last page? Use this /:IF&NEXTPAGE&EO 0

40. We cannot have 2 different orientation for the same layout.

41. How to develop Sap Scipts in different languages? In SE63 click Translation=>Long Texts=> Forms

42. Width of the Page windows of type Main on the same page should be same.

43. Tcode NACE : Tracks the Standard Layout and standard program used for standard business documents and also the place to configure or link the new layout to the driver program if the standard layout is copied and changed.

44. How to convert Script to smartforms? Use tcode SMARTFORMS or use UTILITIES=>MIGRATE SCRIPTS TO SMART FORMS

45. Shading in the sap script boxes ? Use INTENSIFY in the BOX command 

46. 2 conditional stmts we can use in scripts: IF..ELSE..ENDIF, CASE..ENDCASE.

47. Customizing INCLUDE is used to include the structure to CUSTOM TABLE, whereas APPEND STRUCTURES is used for STANDARD TABLE.

48. Append structures are NOT RE-USABLE.

49. Rules for Foreign key: Domain should be same for both Primary and secondary key. And the Check table field should be primary key.

50. Explain Index in DDIC (Data Dictionary): Its used to search DB faster. Copy of DB with less fields in sorted form. It has pointer to the record in actual table.

51. Table maintenance generator ? is used to create TABLE MAINTENANCE PROGRAM to add modify or delete records in db. It has 2 screens OVERVIEW SCREEN, SINGLE SCREEN

52. TYPE GROUP? A group to holds the Type definitions instead of defining in abap program.

53. DATA CLASS? Determines the tablespace ( physical area) of the table.

54. SIZE CATEGORY? probable space requirement of the table in db

55. DELIVERY CLASS? The delivery class controls the transport of table data for installation, upgrade, client copy and when transporting between customer systems. The delivery class is also used in the extended table maintenance. A: Application table (master and transaction data).C: Customer table, S: System table

56. Technical Settings, Indexes and append structures are important for a table.

Page 161: Sap Notebook

57. Customer Namespace must be defined in the table TRESC.

58. Buffering table: resides in Application server and not DB, thus improves performance.Cluster table cannot be buffered. Full buffering, Generic buffering, Single record buffering

59. View? is a Logical view of one or more tables. The data is not physically stored in view, instead derived from one or more tables.

60. Types of view: Database view, projection view, maintenance view, Help view.

61. Projection view: retreives just some fields from a single table.

62. Help View : Is used for search help

63. Database view: is used for inner join view of one or more tables

64. Maintenance view:Helps in creating and maintaining data of the application and will be distributed among several tables.

65. What is Module pool Program? Transaction in R/3 system is an operation that let users to make necessary changes to the database in a consistent way. The entire R/3 system is nothing but set of business transactions. The data transfer from old system to R/3 db or modifying data or deleting data is done through transaction only.

66. Different steps in the transaction? - Interactive phase and Update phase.

67. Different types of LUW ? Sap LUW and DB LUW

68. What is DB LUW or Db transaction.?DBLUW is a mechanism used by the db to ensure that its data are consistent. The DB LUW is either fully executed or not at all.

69. SAP LUW can have several database LUW. So a set of DB is either committed or rolled back. The special abap command COMMIT WORK marks the end of SAP LUW.

70. Various validations? 

71. Client Server technology belongs to which type of architecture? 2 tier

72. In SD module wats ATP? Availablity to promise

73. Wat are the choices available in SAP db? Oracle, Sybase, Infomix.

74. What are different people involved in Sap products & People? DEVELOPMENT TEAM, OPERATIONS STAFF, CONFIGURATION TEAM, BUSINESS END USERS, 

75. What are the different interfaces in SAP architecture? User interface, Communication interface, system interface.

76. Different logics available in client server architecture? Presentation logic, application logic and DB logic.

77. What are the different steps in operating process models? Capital resources, Logistics Process, Material resources and capacity resources.

78. Different stages in manufacturing/ distribution model.? Financial accounting, cost accounting, fixed assets and human resource.

79. In the financial operating model where the data will be stored? Document database.

Page 162: Sap Notebook

80. What are the different features of SD?  Real-time Available to promise ATP & scheduling, Comprehensive flexible pricing architecture, Highly customizing order processing.

81. Limitations of SD? Complexities of multiple levels of approval, limited channel partner data available, limited functionality for service.

82. What are the key areas in MM? Purchasing ( procurement), materials requirement planning MRP, inventory management.

83. Different type of procurement? Standard, Subcontracting & consignment, Stock transfer & external service.

84. Types of purchasing documents?  Purchase requisition & request for quotation, Quotation & purchase order, Outline agreement.

85. How can you handle errors in BDC- Call transaction? LOOP AT It_data Populate IT_BDCTAB table CALL TRANSACTION using IT_BDCDATA MODE A/N/EUPDATE S/AMESSAGES INTO IT_BDCMSGCOLL

86. Display modes for call transaction? E- display only errors, N-Background processing, A - Display all screen. Update can be Synchronous S, Asynchronous A, Local update L.

87. How to run background sessions? Schedule RSBDCSUB Using SM36 

88. What is the function of OK CODE /N? Terminate current batch input and mark as incorrect

89. What is the function of OK CODE /bdel? Delete current batch input from session.

90. What is the function of OK CODE /bbeg? Restart in a transaction.

91. What is the function of OK CODE /bend? Terminate batch input processing and mark session as incorrect.

92. What is the function of OK CODE /bda? change display mode to process the on screen instead of displaying only.

93. What is the function of OK CODE /bde? Change display mode to display only instead of processing the session ON.

94. What is BDCRECXT? is a standard program generated from recording which contains all the re-usable declarations and also the re-usable subroutine definitions for all the BDC programs.

95. How to print a session log file? Execute RSBDCLOG

96. How to export the session? In SM35 => utilities => export session

97. How to solve the screen resolution ( Standard screen size) while working with table control in bdc? It is to consider the default screen resolution WA_OPT_UPDMODE = 'S'. WA_OPT_DESIZE='X' WA_OPT_DISMODE = 'N'.

Page 163: Sap Notebook

98. Steps in session method? create session, insert tcode, close session, process or run the session.

99. List out the sap supplied programs to load master data? RMDATIND (mat mas), RFBIDE00(cust mas), RFBIKR00 ( vendor mas), RVINVB00( sales order), RM06BB10 ( purchase requisition)

100. SY-SUBRC = return code

101. SY-LANGU = user log on language

102. SY-MANDT = Client 800 or client 700 like that.

103. SY-HOST = server

104. SY-UNAME = logon user name

105. SY-DALTO = Local date

106. SY-DATUM = server date

107. SY-TIMLO = LOCAL TIME

108. SY-UZEIT = SERVER TIME

109. SY-DYNNR = SCREEN NUMBER OR DYNPRO NUMBER

110. SY-REPID = Current abap program name

111. SY-TCODE = Current server code

112. SY-ULINE = draw horizontal line

113. SY-VLINE = draw vertical line

114. SY-INDEX = number of current loop pass

115. SY-TABIX = current line of internal table

116. SY-DBCNT = number of table entries process

117. SY-UCOMM = function code 

118. SY-LINCT = page length of the list

119. SY-LSIND = LIST INDEX

120. SY-LINNO = Current line number

121. SY-DBSYS = Central database

122. SY-OPSYS = operating system

123. SY-SAPRL = Sap release

124. SY-SID = system ID or system name

125. What are the 2 ways to restrict the value range for a domain ? Specify fixed values, or by stipulating value table.

126. How to transfer Itab1 data into itab2 (same structure)? ITAB2 EQUALS TO ITAB1

127. Difference between SELECT SINGLE AND SELECT UPTO 1 ROWS? 

128. how many sequence of events triggered in report? 12

Page 164: Sap Notebook

129. How many times the event INITIALIZATION & TOP OF PAGE triggers in 20 pages list? Initialization will trigger only once, top of page 20 times.

130. What is message class? is to maintain all the messages either success or failure or error with 3 digit number between 000-999

131. Types of messages? S,E,X, A, I, W.

132. Text elements? Allows you to store texts without hardcoding in program and can be maintained outside the program.

133. FOR ALL ENTRIES? We can use FOR ALL ENTRIES to replace NESTED SELECT LOOPS by operations on internal tables. It will improve the performance for large set of selected data.

134. Inner Join Vs Outer join ? In a inner join, a line form the left hand db table or join is only included in the selection if there is one or more lines in the right hand db table that meet the ON condition. The left Outer join just read lines from left hand db table or join even if there is no corresponding line in the right hand table.

135. Interactive report? Summary in the first list and after user interaction it gives a detailed info.

136. Types of user interaction in reports? LINE SELECTION & User commands

137. What system variables you will use mostly in Interactive reports? SY-LSIND, SY-UCOMM, SY-LISEL (selected line contents)

138. When will a user trigger Sy-ucomm ? Whenever the user interacts with any of the application on the toolbar. Also the function code of the selected button will be saved in the system variable Sy-ucomm.

139. Which master data to be used in Purchasing ? Material master data, Service master data, Vendor master data, purchasing master data.

140. What is purchase order? It represents a formal request to the vendor to supply goods or services under certain conditions

141. What are the factors determined by the consumption based planning? Quantity required to order.

142. What is Forecast - Based planned is based on ? Material consumption

143. What are conversion routines / exits? Non-standard conversions from display format to sap internal format and viceversa are implemented using conversion routines.

144. What type of objects you create using Dictionary? Tables, views, domains, data elements, structures, search helps, lock objects, type groups.

145. Check table? Is an independent table to which the relationship is defined using foreign keys. 

146. Value table is the table attached to a field at domain level where the entry to the field can be only from value table. Value table is the default check table.

147. What type of views u can use in abap program? Only PROJECTION VIEW AND DATABASE VIEW. 

Page 165: Sap Notebook

148. Which table stores the programs, packages, tables, development class? TADIR = stores the programs TAble DIRectory, TDEVC = Table DEVelopment Class packages, DD021 = Database tables, DD02T = Database tables short text.

149. What is the size of internal tables? Intial size is 8 kb and can be extended till 2 GB.

150. Difference between Field group and internal table? Field group is also known as Work area. It can store only single value whereas internal table stores multiple values.

151. How to eliminate duplicate entries in Itab? (to compare just 2 identical key fields) DELETE ADJACENT DUPLICATES  FROM ITAB or DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

152. COLLECT statement? Is used to summarize the numerical records of the column. (like grand total.)

153. How to print from 5th record to 10th record in itab? LOOP AT ITAB 5 TO 10. WRITE ITAB. ENDLOOP.

154. Can you sort the sorted internal table again ? NO

155. Explain OCCURS keyword.? It is used to declare only the standard itab before sap4 ver to allocate memory for the internal table.

156. Types of Itab? Standard, Sorted, Hashed.

157. How do you determine a table is client dependent or independent ? The MANDT field determines this.

158. What is TABLES key word in TABLES KNA1? Defines a Work Area field with the same name.

159. How can you print 3rd record from ITAB ? READ TABLE ITAB INDEX 3

160. Locking object? Are used to synchronize access to the same data by more than one user.

161. Disadvantage of Asynchronous update? Its not recommended for Large amount of data processing as it receives no completion message from the update module. Still you can check with SM12 for any problems but its not convinient.

162. Major difference in Session and call transaction ? In session method we can process multiple transactions in the same session whereas in call transaction we can process only a single transaction.

163. Recording? SHDB is the tcode to read all steps while executing the session method.

164. What is an ABAP data dictionary?- ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.

165. What are domains ?- Domain is the central object for describing the technical characteristics of an attribute of an business objects. It describes the value range of the field. 

Page 166: Sap Notebook

166. What are and data element? Data Element: is used to describe the semantic definition of the table fields like description of the field. Data element describes how a field can be displayed to end-user.

167. What is foreign key relationship?- A relationship which can be defined between tables and must be explicitly defined at field level. Foreign keys are used to ensure the consistency of data. Data entered should be checked against existing data to ensure that there are now contradiction. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

168. Describe data classes.- Master data: It is the data which is seldomly changed. Transaction data: It is the data which is often changed. Organization data: It is a customizing data which is entered in the system when the system is configured and is then rarely changed. System data:It is the data which R/3 system needs for itself.

169. What are indexes?- Indexes are described as a copy of a database table reduced to specific fields in sorted form. This sorting form ease fast access to the field of the tables. In order that other fields are also read, a pointer to the associated record of the actual table are included in the index. The indexes are activated along with the table and are created automatically with it in the database.

170. Difference between transparent tables and pooled tables.- Transparent tables: Transparent tables in the dictionary has a one-to-one relation with the table in database. Its structure corresponds to single database field. Table in the database has the same name as in the dictionary. Transparent table holds application data. Pooled tables. Pooled tables in the dictionary has a many-to-one relation with the table in database. Table in the database has the different name as in the dictionary. Pooled table are stored in table pool at the database level.

171. What is an ABAP/4 Query?- ABAP/4 Query is a powerful tool to generate simple reports without any coding. ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.

172. What is BDC programming?- Transferring of large/external/legacy data into SAP system using Batch Input programming. Batch input is a automatic procedure referred to as BDC(Batch Data Communications).The central component of the

Page 167: Sap Notebook

transfer is a queue file which receives the data vie a batch input programs and groups associated data into “sessions”.

173. What are the functional modules used in sequence in BDC?- These are the 3 functional modules which are used in a sequence to perform a data transfer successfully using BDC programming: BDC_OPEN_GROUP - Parameters like Name of the client, sessions and user name are specified in this functional modules. BDC_INSERT - It is used to insert the data for one transaction into a session. BDC_CLOSE_GROUP - This is used to close the batch input session.

174. What are internal tables?- Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables.

175. What is ITS? What are the merits of ITS?- ITS is a Internet Transaction Server. ITS forms an interface between HTTP server and R/3 system, which converts screen provided data by the R/3 system into HTML documents and vice-versa.

Merits of ITS: A complete web transaction can be developed and tested in R/3 system. All transaction components, including those used by the ITS outside the R/3 system at runtime, can be stored in the R/3 system. The advantage of automatic language processing in the R/3 system can be utilized to language-dependent HTML documents at runtime.

176. What is DynPro?- DynPro is a Dynamic Programming which is a screen + associated flow logic of Screen.

177. What are screen painter and menu painter?- Screen painter: Screen painter is a tool to design and maintain screen and its elements. It allows user to create GUI screens for the transactions. Attributes, layout, filed attributes and flow logic are the elements of Screen painter.

Menu painter: Menu painter is a tool to design the interface components. Menu bars, Toolbar, menu lists, F-key settings, functions, Status and titles are the components of Menu painters. Screen painter and menu painter both are the graphical interface of an ABAP/4 applications.

178. What are the components of SAP scripts?- SAP scripts is a word processing tool of SAP which has the following components: Standard text. It is like a standard normal documents.

Page 168: Sap Notebook

Layout sets. - Layout set consists of the following components: Windows and pages, Paragraph formats, Character formats. Creating forms in the R/3 system. Every layout set consists of Header, paragraph, and character string. ABAP/4 program.

179. What is ALV programming in ABAP? When is this grid used in ABAP?- ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.

180. What are the events in ABAP/4 language?- Initialization, At selection-screen, Start-of-selection, end-of-selection, top-of-page, end-of-page, At line-selection, At user-command, At PF, Get, At New, At LAST, AT END, AT FIRST.

181. What is CTS and what do you know about it?- The Change and Transport System (CTS) is a tool that helps you to organize development projects in the ABAP Workbench and in Customizing, and then transport the changes between the SAP Systems and clients in your system landscape. This documentation provides you with an overview of how to manage changes with the CTS and essential information on setting up your system and client landscape and deciding on a transport strategy. Read and follow this documentation when planning your development project.

182. What are logical databases? What are the advantages/ dis-advantages of logical databases?- To read data from a database tables we use logical database. A logical database provides read-only access to a group of related tables to an ABAP/4 program. Advantages: i)check functions which check that user input is complete, correct,and plausible. ii)Meaningful data selection. iii)central authorization checks for database accesses. iv)good read access performance while retaining the hierarchical data view determined by the application logic. dis advantages: i)If you donot specify a logical database in the program attributes,the GET events never occur. ii)There is no ENDGET command,so the code block associated with an event ends with the next event statement (such as another GET or an END-OF-SELECTION).

183. What is a batch input session?- BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored

Page 169: Sap Notebook

in session ie data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.

184. How to upload data using CATT ?- These are the steps to be followed to Upload data through CATT: Creation of the CATT test case & recording the sample data input. Download of the source file template. Modification of the source file. Upload of the data from the source file.

185. What is Smart Forms?- Smart Forms allows you to create forms using a graphical design tool with robust functionality, color, and more. Additionally, all new forms developed at SAP will be created with the new Smart Form solution.

186. How can I make a differentiation between dependent and independent data?- Client dependent or independent transfer requirements include client specific or cross client objects in the change requests. Workbench objects like SAPscripts are client specific, some entries in customizing are client independent. If you display the object list for one change request, and then for each object the object attributes, you will find the flag client specific. If one object in the task list has this flag on, then that transport will be client dependent.

187. What is the difference between macro and subroutine?- Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs . A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I’ve never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.

SQL Last min tips

What is the differences between select single * and selct up to 1 row?Select Single * will pickup only one matching record from the database into the buffer, and returns the same to the internal table.

Select upto 1 rows will pickup all the records matching the condition into the buffer, but return the top record to the internal table.

For this reason, performance wise select upto 1 row is better than select single.

According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.

select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most

Page 170: Sap Notebook

suitable index.

The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

Mainly:   to read data from

The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

Mainly: to check if entries exist.

Last min refresh TCODES

Transaction Variant = SHD0Create Transaction Code = SE93

sap script symbols

Using SAPscript SymbolsYou can use SAPscript symbols to include program or system data or predefined texts in your document.To use a symbol, enter the name of the symbol in your text enclosed in & characters :&DATE&You can insert a symbol anywhere in your text. When you print or display your document, SAPscript substitutes the current value of the symbol for the symbol name in your document.If you do not know the name of a symbol, choose Include  Symbols to find the symbols available and select one. In this case, you can also specify how to process and format the symbol (pushbutton OPTIONS).

You can use the DATE symbol to have the current date inserted in your document when the document is displayed or printed. You set symbols off from normal text by enclosing the symbol name in ampersands (&):For example, Walldorf, &DATE& is displayed or printed as Walldorf, 08.08.1998. The exact date formatting depends on the option set in System  User profile  Fixed values.If you choose Include  Symbol to insert a symbol into your text, the system automatically supplies the & characters.

Using the Four Types of SymbolsSAPscript offers four types of symbols that draw their values from different sources. These symbols are system symbols, program symbols, standard SAPscript symbols, and local text symbols. You access each type of symbol

Page 171: Sap Notebook

by way of a different Include submenu.Here is more information on each type of symbol:

o System symbols draw their values from global SAP System variables.

System symbol Contains

DATE current date

DAY day from current date

DEVICE output device: PRINTER, SCREEN, TELEX, FAX

HOURS hours from time of day

MINUTES minutes from time of day

MONTH month from current date

NAME_OF_MONTH name of the month from current date

NEXTPAGE page number of the next page

PAGE page number of a SAPscript text

SECONDS seconds from time of day

SPACE blank

TIME time of day

ULINE underline

VLINE vertical line

YEAR year from current date

Sap   Script

Sap   Script

INTRODUCTION: SAP Script is the SAP System's own text-processing system.Also called as Word processing tool of SAP. SAP Script is tightly integrated into the SAP System Note: Entering and formatting text in SAP script is a little bit different than traditional text-processing programs on a PC. The main difference: the text that you enter is not in its final format. SAP script applies your formatting to text only when a document is printed, print-previewed, or displayed on-line in the SAP SystemSap Script

How does a SAP Script work ? Every Script has a driver / print program attached or calling it. In case you are creating an entirely new script ,you also need to create the driver program. This program can be executed directly or attached to attached to certain events viz. Creation of Purchase Order , Sales Order , Hiring an Employee. Standard SAP scripts can be modified by copying them in the customer name space and making the required changes.Sap ScriptComponents of a   SAP   Scripts  1. Standard Text This is like a normal document.You can create letters , articles bascially any static text. This can be created from transaction SO10.

Page 172: Sap Notebook

2. Layout Set This also called as Form created from Transaction SE71. 3. Print Program This program retrieves desired data from the database , calls the Form, supplies data to the Form and finally closes the Layout Set ( Form ).Sap ScriptSupplies data Driver Program Layout set Gets printedDefinesForms Sap ScriptSap ScriptName House name Postal Code CityWINDOWName House name Postal Code CityPage window Particular area in the page where the window is printed outPageStandard TextTransaction SO10Standard TextAfter creating a Standard Text assign it a Style.Standard TextIf you want text in your standard text to appear as per attributes of character string , you need to enclose the text TEXT.Layout SetOBJECTS OF LAYOUT SET • Header • Paragraph and Character format • Windows and Text Elements • Pages • Page WindowsHeaderHeader data is found both in style and layout set maintenance. In style maintenance, it is used primarily to present information designed to make it easier for the end user to select a style. The header data in layout set maintenance, on the other hand, is used for information and control purposes.Header

HEADER INFORMATION GLOBAL DATAParagraphIn SAP Script, paragraphs are formatted using formats and their corresponding attributes. Word processing is simplified by the use of different paragraph attribute groups: • Standard • Font • Tabs • OutlineParagraphParagraph FormatCharacter FormatCharacter formats • Allow you to format entire blocks of text within a paragraph •Which will override the paragraph format •Character formats are defined in character strings Eg: &VBDKA-TDNAME& ,, &VBDKA-TFGEU&

Windows and Text ElementsWINDOWS We can combine information contained in a document into certain groups and make each group appear on the printed page in an individual area. SAP Scripts calls such a group a window • To refer a window via program each window must have a unique name • We can assign text to each windows via text elements TEXT ELEMENTS Text elements can be defined in layout set maintenance for each window. The text elements are accessed by name by a print program, formatted, and output in the respective window. The /E in the tag column is used to identify the text as a text elementWindowsWindows are defined in layout set maintenance. They represent areas which are positioned on pages -- as page windows -- and in which text is later output. At least one window must be

Page 173: Sap Notebook

defined for each layout set. If not, a text cannot be formatted by SAP Script. The following window types can be used: • main • variable • constantWindowsWINDOWSWindowsMAIN Main window in which continuous text is output. The text in the main window can extend over several pages. If the text fills one page, output continues in the window of the next and subsequent pages, as long as MAIN has been defined for these pages. VAR Window with variable contents. The text can vary on each page in which the window is positioned. Variable windows are formatted for each page. CONST Window with constant contents which is only formatted once.PagesAt least one page must be defined for every layout set. You must also designate a "first" page in the layout set header. Otherwise text formatting is not possible.PagesPAGESPage WindowsWhen you define page windows, the window names are linked to page names. To do this, you need to specify the position and size of the window on the assigned page. Width of the main window must be the same on all pages.Page Windows Sap ScriptPAGE WINDOWSSap ScriptCOMPONENTS OF SCRIPT • Text Elements • Style • Layout setText ElementsThe text elements are related to a window . The print program calls the respective text elements of the window TYPES OF TEXT ELEMENTS •TEXT ELEMENTS WITH OUT NAMES •TEXT ELEMENTS WITH NAMEText ElementsNAMED TEXT ELEMENTS • We recognize named text elements by paragraph format /E • The name can be up to 40 characters • The different windows can have same named text elements • To out put named text elements we have to call the function module WRITE_FORMStyleA style defines the set of paragraph and character formats that are available for formatting a document. If a style is selected, then it provides the character and paragraph formats for your document. Any formats defined in the layout set selected for a document are then ignored.Layout Set• Layout sets are used to control the page layout and also the text formatting in your documents. • If a document is formatted for output to the screen or to a printer, then a layout set must be specified for it. • If no other layout set is specified for a document, then the SYSTEM layout set is assigned to the document by default.Layout SetLAYOUT SET CONTROL OPEN_FORM CLOSE_FORM - Initializes the SAP script composer and opens the specified layout set - Closes the layout set ( if close_form is missing in the program nothing will be printed)WRITE_FORM , WRITE_FORM_LINES, CONTROL_FORM - To output data( this can be used as many times between OPEN_FORM and CLOSE_FORM) PAGE CONTROL IN LAYOUT SETS •STATIC DEFINITION- Specify the starting page in header and for each page specify the subsequent page •DYNAMIC DEFINITION - Specify START PAGE when you call START_FORMSymbolsSYMBOLS Symbols are constants that can be inserted in a document. They save the user unnecessary work when replacing sections of text, phrases, etc. Possible symbol types are: • System symbols • Standard symbols • Program symbols • Text symbols.

Page 174: Sap Notebook

SymbolsTHE SYNTAX OF SYMBOLS • The delimiter & must be used both immediately before and after the symbol. •The name of a symbol may not contain spaces. • A SAP Script editor line break should not occur between the symbol delimiters. • If additional formatting options are required, these should be enclosed in round brackets and inserted immediately after the symbol name. • The code letters identifying these options must be given in capitals.SymbolsSYSTEM SYMBOLS SAP script provides values for the system symbols Example &date& &time& &month& &year& &uline& &vline& &page& STANDARD SYMBOLS • • • • • Standard symbols are defined in the TTDTG table. This table contains both the name of each symbol and its value. The value, which is language-dependent, can contain up to 60 chars. This table is delivered complete with standard entries supplied bySAP. It may be extended with customer-specific symbolsSymbolsPROGRAM SYMBOL SAP Script cannot read this data out of the SAP database itself, but has to call on another program to do this. The data are then copied into work areas declared using TABLES. If SAP Script is now called from this program in order to format a text, it can copy the data out of these work areas.Symbols which obtain their values from this kind of data area are called program symbols. Note • The value of a program symbol is limited up to a maximum of 255 chars. • The name of a program symbol consists of the table name and the field name separated by a hyphen.SymbolsTEXT SYMBOLS All symbols which do not correspond to one of the three types of symbol described above are text symbols. You define the value of a text symbol yourself in the text module. There are two ways of doing this: • Use the menu entries in the text editor • Use the control command DEFINE for e.g /: DEFINE &mysymbol& = ‘XXXX’ / &mysymbol& /: DEFINE &mysymbol& = ‘YYYY’ / &mysymbol&would print XXXX YYYYControl CommandsControl Command is a type of SAP script command which are used to control output formatting. The Syntax of Control Commands • The paragraph format /: must be entered in the format column to identify a control. • You enter the command itself in the text line. • A control command, together with any parameters it requires, may not occupy more than a single line • A maximum of one control command may appear in each lineControl CommandsSYNTAX OF CONTROL COMMANDS • In tag column, indicate control commands with paragraph format /: • Enter complete control commands and necessary parameters on one line • Enter only one control command per line • Editor formatting does not affect lines with control commandsControl CommandsSOME IMPORTANT CONTROL COMMANDS: /: NEW-PAGE /: PROTECT & /: ENDPROTECT/: SET DATE MASK = 'date_mask’ /: SET TIME MASK = 'time_mask’ /: RESET paragraph_format /: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l ] [PARAGRAPH p] [NEW-PARAGRAPH np](Cont…..Next page)Control Commands/: TOP : /: ENDTOP /: BOTTOM : /: ENDBOTTOM /: IF condition : /: ENDIFControl CommandsSET DATE MASK command The formatting for date fields can be defined with the SAPscript SET DATE MASK command. Executing this command causes all subsequent date fields to be output using the specified formatting. Syntax /: SET DATE MASK = 'date_mask' The following

Page 175: Sap Notebook

templates may be used in the date mask: For day : DD / DDD / DDDD For month : MM / MMM / MMMM For year : YY / YYYYControl CommandsSET TIME MASK command You can use the SAPscript SET TIME MASK command to format time fields in a way that differs from the standard setting. Executing this command causes all subsequent time fields to be output using the specified formatting. Syntax: /: SET TIME MASK = 'time_mask' The following templates may be used in the time mask: HH hours (two digits) MM minutes (two digits) SS seconds (two digits)Control CommandsBOXES, LINES, SHADING: BOX, POSITION, SIZE The BOX, POSITION and SIZE commands for drawing boxes, lines and shadowing can be used for specifying that within a layout set particular windows or passages of text within a window are to be output in a frame or with shadowing. Syntax 1. /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY] 2. /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE] 3. /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]Control CommandsADDRESS The command formats an address according to the postal standards of the destination country defined in the parameter COUNTRY sap scripts calls function module ADDRESS_INTO_PRINTFORM to format the address /: ADDRESS[DELIVERY] [PARAGRAPH a] [PRIORITY p] [LINES l] /: TITLE title /: NAME name1[,name 2[,name 3[,name 4]]] /:STREET street /:POBOX po box[CODE zip code] /:CITY town1[,town 2] /:REGION region /:COUNTRY country /: FROMCOUNTRY from country /: ENDADDRESSControl CommandsBOTTOM /ENDBOTTOM /:BOTTOM The text lines between the two commands are output at the bottom of MAIN window /:ENDBOTTOM /:DEFINE &symbolname& = ‘value’ Text symbol receive their value through an explicit assignment. This assignment can be done interactively in the editor via include-symbolstext. The assigned value may have a maximum of 60 charactersIncorporating GraphicsFor e.g Company Logo 1. .bmp / .jpg file has to be converted to .tiff file 2. Upload the file as text module using ABAP/4 report “RSTXLDMC” specify BMON or BCOL 3. System generates a suggested name for the text e.g ZHEX-MACRO-LOGO Use ID “ST” and logon language. 4. Include ZHEX-MACRO-LOGO object Text ID ST in the Layout.Example of Print ProgramCalling an Script from a program created in SE38 REPORT ZSCRIPT . TABLES: SPFLI. DATA: I_SPFLI LIKE SPFLI OCCURS 0 WITH HEADER LINE. SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE I_SPFLI. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM = 'ZTEST11'. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'HEADER_ITEM' * FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN'. (Contd….. Next Page)Example of Print ProgramCALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'ADDRESS_LIST' * FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'WINDOW1'. LOOP AT I_SPFLI. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'LINE_ITEM' * FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN'. ENDLOOP. CALL FUNCTION 'CLOSE_FORM'.Example of Print ProgramOutput of the programExampleDetails of Layout Set Header DataExamplePagesExampleWindowsExamplePage Windows

Page 176: Sap Notebook

ExampleMain Window DetailsFormatting OptionsOffset - specifying an offset of ‘n’ , n left most characters are not displayed. E.g &symbol& ---> 1234576789 &symbol+3& ----> 456789 Output Length &symbol(3)& ----> 123 &symbol(7)& ----> 1234567 Time Mask &Time& Normally 10:08:12 (hh) : (mm): (ss) /: Set Time Mask = ‘HH:MM’ &Time& = 10:08 /: Set Time Mask = ‘HH hours MM minutes’ &Time& = 10 hours 08 minutes &Time(Z)& = 10 hours 8 minutesExampleDate Mask /: Set Date Mask = ‘DDMMYY’ &Date& = 01 05 01 /: Set Date Mask = ‘MMMM DD,YYYY’ &Date& = May 01,2001 Fill Character Leading spaces in a value can be replaced with a fill character. The ‘F’ option is used and character to be filled is specified. E.g &KNA1-UMSAT& = 700.00 &KNA1-UMSAT(F*)& = **700.00 Space Compression &symbol(C)& It has a effect of replacing each string of space characters with a single space and shifting the words to left as necessary to close up gaps. Also Leading spaces are completely removed. Omitting Leading Zeros &symbol(Z)& &Day& = 01 &DAY(Z)& = 1

Basic notes for BDC

PreDefined structures used in BDC

BDCDATA - Program - DynPro - DynBegin ( if new screen begins then X else space) - Fnam - FvalBDCMSGCOLL ( used to store log file ( error records ) after validation )----------- - MsgTyp ( error like I , E, W , A ) - MsgNr ( error number like 000, 001... )

BDC CAN BE DONE IN FOLLOWING WAYS:1. recording ( Session method (default log file and can process huge data) / call transaction method (ASYNC, so faster))2. Lsmw3. Direct input method

SESSION METHOD: (RSBDCSUB Or RSBDCBTC)-For background uploading)

PreDefined fn module are1. BDC_OPEN_GROUP

Page 177: Sap Notebook

2. BDC_INSERT3. BDC_CLOSE_GROUP

1. BDC_OPEN_GROUP: - CLIENT ( SY-MANDT ) - GROUP (Session group name ) - USER ( SY-UNAME )

2. BDC_INSERT - TCODE ( application tcode ) - DYNPROTAB ( bdcdata itab )============================================================Sequence:DATA:JTAB Like BDCDATA OCCURS 0 WITH HEADER LINE.OrJTAB TYPE TABLE OF BDCDATA, WA TYPE BDCDATA.

=> CALL FUNCTION GUI_UPLOAD (into itab ) Exporting: filename='abc.txt', filetype='Asc', Has Field seperator = 'X' Tables: data_tab= Itab=> CALL FUNCTION BDC_OPEN_GROUP Exporting: Client=SY-MANDT,Group='ses',User=SY-UNAME

Loop at itab into wa refresh Jtab. perform subI using 'Yapplication' 100. perform Sub2 using 'lfa1-lifnr' wa-lifnr. perform Sub2 using 'lfa1-land1' wa-land1. perform Sub2 using 'lfa1-name1' wa-name1.

* [FOR SESSION METHOD - BACKGROUND PROCESSING (OPTIONAL)]* Perform Sub2 Using 'BDC_OKCODE' 'INSERT'.* Perform SubI using 'Yapplication' 100.* Perform Sub2 Using 'BDC_OKCODE' 'EXIT'.*-----------------------------------* [FOR CALL TRANSACTION* Perform Sub2 Using 'BDC_OKCODE' 'INSERT'. "To press enter automtcly

Page 178: Sap Notebook

* CALL TRANSACTION 'Yapplication' USING Jtab MODE 'N' MESSAGES INTO KbdcMsgColl.

CALL FUNCTION 'BDC_INSERT' Exporting tcode = 'yapplication' Tables dynprotab = Jtab. EndLoop.

CALL FUNCTION 'BDC_CLOSE_GROUP'.* [FOR SESSION METHOD - BACKGROUND PROCESSING (OPTIONAL)]* SUBMIT RSBDCSUB VIA SELECTION-SCREEN.

Form SubI using M E. Clear Jtab. " Or clear WA. Jtab-Program = M "JWA-PROGRAM Jtab-DynPro = E Jtab-DynBegin = 'X' Append Jtab.Endform.

Form Sub2 Using N L. Clear Jtab. Jtab-Fnam=N Jtab-Fval=L Append Jtab.Endform.

Tcode: SM35 Batch input session================================================================

SAP ALV ADVANCED LIST VIEWER

IF YOU WANT TO KNOW THE BASICS OF ALV THEN SEE THESE LINKS

SAP ALV Tutorial : SAP ALV programming techniques

Introduction to Field Catalog ( SLIS_T_FIELDCAT_ALV )

Page 179: Sap Notebook

Example: Field catalog – KEY, COL_POS

Multi-line ALV using ROW_POS in field catalog