Sap Script

10
SAPSCRIPT SE71 Logic : 1.Creating Pages 2. Creating Windows on that page 3. Setting attributes(Left , Right margins, width) to that windows, Using Page Windows 4.Creating Paragraphs for the windows , using Paragraph Formats. 5. Using “Windows” or “Page Windows” , the coding is applied. Steps: STEP1: New Form-> Create Fig 1: In “Administration Data”: give Description STEP 2: In the “Basic Settings”(shown in Fig2), Select the Page Format (DINA4 is by defa). 1

Transcript of Sap Script

Page 1: Sap Script

SAPSCRIPT SE71

Logic : 1.Creating Pages 2. Creating Windows on that page 3. Setting attributes(Left , Right margins, width) to that windows, Using Page Windows 4.Creating Paragraphs for the windows , using Paragraph Formats. 5. Using “Windows” or “Page Windows” , the coding is applied. Steps: STEP1: New Form-> Create

Fig 1: In “Administration Data”: give Description STEP 2: In the “Basic Settings”(shown in Fig2), Select the Page Format (DINA4 is by defa).

1

Page 2: Sap Script

Fig2: STEP 3: Now click on PAGES button , to create Page. Now U’ll get the flwg window(Fig3):

Fig 3: 2

Page 3: Sap Script

STEP 4: In Fig3, Edit->Create Element, give the name & Description for the new Page. “Next Page” is the name of the Next Page , that will displayed after the “Page”, in the page sequence. To define, “Next Page”, u must have created atleast 2 pages. STEP 5: Now V’ve to create Windows for the Page. Click on “Windows” button Now U’ll get the flwg window(Fig4):

Fig 4: By Default, System will create a Main window. In addition to this window, V can create our own windows using, Edit->Create Element, give tbe name & Descrption for the NewWindow.. Window Type sud b “VAR”. STEP 6: Now V’ve to define Attributes(Margins, Width) for Each window. & V’ve to specify , that which window sud b displayed on which page. Edit->Create Element, Now a popup will b displaied with the existing window names, select ur desired window &give the flwg: Window Width, Height, Left & Upper Margins. Like this, V can put as many windows as U want , on this specified Page(The Page is mentioned on the top left of the “Pages Windows” window).

3

Page 4: Sap Script

Fig 5: STEP 7: Now V’ve to create Paragraphs.

Fig6: 4

Page 5: Sap Script

Click on “Paragraph Formats” button. The windo will b displd. as in the Fig6. Edit->Create Element, now give the new name & descn. for the new Para format. Give the Margins, Alignment for this Paragraph. “No Blank Lines”- If its on, then the blank lines r suppressed in the output. Moreover, V cud set Font , Tabs & Outlines for this para. STEP 8: Now Save. & Press F5 or click the Header, -> Basic Settings(Fig. Shown in Fig2.) Here, V must specify the Default page in “First Page”. & Default paragraph in “Default Paragr.” .. Now Save. STEP 9: Now hv to write codings. Go to “Page Windows” , Dbclick on the window name, to which u wud write the codings.-> Press F9. Now the flwg window will appear.

Fig 7: a. In this window, First V’ve to define Element name , using the symbol “/E”. This text element is the interface to connect the ABAP

pgm with SAPSCRIPT. b. To declare fields, &<int.table name>-<field name>&. Its field symbol is “*”. c. To use IF conditions , symbol is “/:” . Eg:

/: IF &itab-matnr& EQ ‘0000000001’ /: &itab-maktx& , &itab-ersda& /: &ULINE(71)& /: ENDIF

Now Save. 5

Page 6: Sap Script

STEP 10: SE38-> new program (This will call the SAPScript Form). The Structure of the pgm is: <type declaration> <parameter declaration> <Select query> LOOP AT <it> CALL FUNCTION 'OPEN_FORM' EXPORTING device = 'PRINTER' or ‘ABAP’ (Note: If ‘ABAP’ is used, the “dialog=’X’ sud b comented) dialog = 'X' form = '<name of sapscriptform>'. CALL FUNCTION 'WRITE_FORM' EXPORTING element = '<nameof element>' (Note:with this element name,abap’ll identify which window to b called) function = 'SET' type = 'BODY' window = '<name of main window>'. CALL FUNCTION 'WRITE_FORM' EXPORTING element = '<nameof element>' (Note:with this element name,abap’ll identify which window to b called) function = 'SET' type = 'BODY' window = '<name of window2>'. CALL FUNCTION 'WRITE_FORM' EXPORTING element = '<nameof element>' (Note:with this element name,abap’ll identify which window to b called) function = 'SET' type = 'BODY' window = '<name of window3>'. ……. ……. ……. CALL FUNCTION 'CLOSE_FORM'. ENDLOOP. 6

Page 7: Sap Script

SAP SCRIPT COMMANDS

Calling ABAP Subroutines: PERFORM Syntax in a form window: /: PERFORM <form> IN PROGRAM <prog> /: 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. OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings. [The relevent form sud be called from ABAP Prgm only.] Eg: 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. 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 OUT_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. Formatting Addresses: ADDRESS The 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 Setting a Footer Text in the Main Window: BOTTOM You 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. 7

Page 8: Sap Script

Syntax: /: BOTTOM : : /: ENDBOTTOM The 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 To copy one or more standard texts, forms, or styles from one client to another client, In the Starting Screen of SS, Utilities-> Copy from Client &SPACE& Generating 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. &symbol(C)& Leading spaces are completely removed. The results are the same as those of the ABAP command CONDENSE Assuming ' Albert Einstein ' is the symbol value, &symbol& -> Albert Einstein &symbol(C)& -> Albert Einstein Conditional Text: IF Syntax: /: IF condition : : /: ENDIF Setting a Footer Text in the Main Window: BOTTOM /: BOTTOM : : /: ENDBOTTOM Assigning a Value to a Text Symbol: DEFINE Syntax: /: DEFINE &symbol_name& = 'value' Explicit Page Break: NEW-PAGE SAPscript automatically inserts a page break when the main window of a page (MAIN) is full. Next Main Window: NEW-WINDOW Each 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 Preventing Page Breaks: PROTECT If this page protect attribute is set, then the complete paragraph is always printed on one page. That particular paragraph will not be split in two by a page break. This property applies only to that particular paragraph. 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 8

Page 9: Sap Script

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 : : /: ENDPROTECT The text lines to be protected are enclosed between the two commands. 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 summing symbol used for totalling and the accompanying program symbol(s) must be declared with TABLES in the ABAP program. Otherwise, only zero is added. Declaring the symbol with the DATA statement is not sufficient (global data). Displaying Versions Utilities → Versions. Now it will display the Client name &Description. Click on Client No.. ->click on FORM INFO button. Now to view all the informations about a form 9

Page 10: Sap Script

10