Tuesday, 18 March 2014

Module Pool Programming

Module Pool Programming (Part 1)

Steps of creating module pool application:

1. Go to SE51 in screen painter
2. We give program name, screen number, radio buttons, checkboxes, etc.
3. For processing on that we can use PBO and PAI modules based on our requirements in our main program
4. And lets suppose if we have created a screen 100 and want to call it in our main program than we use CALL SCREEN 100 and it would call the same screen
5. Afterwards we can assign a transaction code to our program in transaction code SE93

Key Points related to Module Pool Programming:

1.    Module pool can be considered as follows:
Collection of screens + Flow logic (Code behind the screen) + Code within main ABAP program.
2.    Screen is an interface through which user can interact with SAP.
3.    Module pool program is classified as Type M and these can’t be executed directly. (Executed by Transaction codes)
4.    For Module pool programming the screen design is done through Graphical Screen Painter (SE51) and GUI design is done from Menu Painter (SE41).
5.    In Module Pool screen can be Normal Screen (has min, max, close option), Sub screen (Screen within a screen), Modal Dialog Box (only close option).
6.    Screen Numbers:
         1000 – Selection Screen
   >= 9000 – Custom Screen
9000-9500 – SAP Partners
      >9500 – Customer Screen
7.    Screen painter.
Screen painter = screen attributes + screen layout + field attributes + flow logic.
8.    Menu Painter.
Menu painter = menu bar + standard tool bar + title bar.
9.    Function codes are assigned to screen attributes to make them interactive.
10. Flow Logic.
Dynpro processor controls the flow logic on screen. By default the flow logic has two specific events which are specific only for module pool programming
PBO and PAI. Apart from these it can have POV and POH.
11. PBO.
Process Before Output is triggered before the screen gets displayed.
It has one module which sets the status bar and title bar.
Module Status_ Output.
          Set PF_Status ‘XXXXXX’.
          Set Title Bar ‘XXXX’.
End module.
12. PAI.
Process After Input  is triggered after the user does some interaction.
It has one module.
Module User Command_ Input.
Inside this the system field SY-UCOMM holds the function code from interactive screens element and according the value different coding options are provided inside CASE –END CASE.
13. POV.
Process On Value request (F4 help).
Field Module on input.
14. POH.
Process On Help request (F1 Help)
Field Module on request.
15. Steps For Programming:
- create the main program
- create top include
- create first screen
- Define attributes
- Define graphical user interface
- Assign field attributes via field list
- Define flow logic using dialog flow logic syntax
- create follow up screens
(Same steps as first screen)
16. PBO module statements are followed by OUTPUT and PAI module statements are followed by INPUT.
17. Field names must be identical to screen field names for values to pass between the dialog processor and ABAP/4 processor at runtime.
18.  Message statements can be used in PAI.
19. Field statement keeps a single field open after an error or warning message is issued.
20. To keep multiple fields open for i/p after error/warning we use
Chain- - -End Chain.
21. All fields of current screen are stored in screen table. Use Modify Screen statement to modify attributes.
22. For table control there must be a loop statement in both PBO and PAI. It is because loop statement causes screen fields to be copied back and forth between ABAP program and the Screen Field.
At the time of PBO, the transport of the table control fields from the ABAP program to the screen takes place after every loop run in the flow logic. The remaining screen fields are filled, as usual, at the end of PBO processing.
At PAI time, first all the screen fields that do not belong to any table control and not listed in any FIELD statement are transported to identically-named fields of the ABAP program. The contents of the table control fields are transported, row by row at the beginning of the corresponding loop run, into the identically-names fields of the ABAP program. The fields that are listed in the FIELD statements are transported, as usual, directly from the corresponding FIELD statement.
Within the loops, two system fields are of importance.
sy-stepl contains the current line of the table control counted from the uppermost displayed line
sy-loopc contains the current number of table control rows on the screen


23. To call sub screen we use CALL SUBSCREEN statement in the PBO of main screen and also in PAI.
In PBO:
Call Subscreen including sy-repid .
In PAI:
Call Subscreen .
24.  For search help on a screen we can use a predefined search help on the search tab of dictionary attribute of the field.
25. For select options, create sub-screen area in your screen layout where you want to create the select options. In the top include of your module pool program declare a selection screen as a sub-screen
e.g.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
Select-options s_matnr for mara-matnr.
SELECTION-SCREEN END OF SCREEN.
 In the PBO and PAI of the main screen where the select options needs to be created do a
call subscreen of the above screen (100).
CALL SUBCREEN sub_area INCLUDING.
This call subscreen statement is necessary for transport of values between screen and
program. All validations of the selection screen fields e.g. the s_matnr field created above should be done in selection screen events like AT SELECTION-SCREEN etc. and not in PAI. These selection screen validations etc. should be done in the top include only
.




    What is a transaction?

-          A transaction is dialog program that change data objects in a consistent way.

    What are the requirements a dialog program must fulfill?

A dialog program must fulfill the following requirements

-          A user friendly user interface.

-          Format and consistence checks for the data entered by the user.

-          Easy correction of input errors.

-          Access to data by storing it in the data bases.

3. What are the basic components of dialog program?

-          Screens (Dynpros)

-          Each dialog in an SAP system is controlled by dynpros.A dynpros consists of a screen

And its flow logic and controls exactly one dialog step.

-          ABAP/4 module Pool.

Each dynpro refers to exactly one ABAP/4 dialog program .Such a dialog program is also       called a module pool ,since it
consists of interactive modules.

4.What is PBO and PAI events?

PBO- Process Before Output-It determines the flow logic before displaying the screen.

PAI-Process After Input-It determines the flow logic after the display of the screen and after receiving inputs from the User.

5. What is dynpro?What are its components ?

-          A dynpro (Dynamic Program) consists of a screen and its flow logic and controls exactly one dialog steps.

-          The different components of the dynpro are :

Flow Logic: calls of the ABAP/4 modules for a screen .

Screen layout: Positions of the text, fields, push-buttons and so on for a screen

Screen Attributes: Number of the screen, number of the subsequent screen, and others

Fields attributes: Definition of the attributes of the individual fields on a screen.

6. What is a ABAP/4 module pool?

-Each dynpro refers to exactly one ABAP/4 dialog program.Such a dialog program is also called

a module pool ,since it consists on interactive modules.

7..Can we use WRITE statements in screen fields?if not how is data transferred from field data to screen fields?

-We cannot write field data to the screen using the
WRITE statement.The system instead transfers data by comparing screen fields names with ABAP/4  variable names.If both names are the same,it

transfers screen fields values to ABAP/4 programs fields and Vice Versa.This happens immediately after displaying the screen.

8.Can we use flow logic control key words in ABAP/4 and vice-verse?

-          The flow control of a dynpro consists os a few statements that syntactically resemble ABAP/4  statements .However ,we cannot
use flow control keywords in ABAP/4 and vice-versa.

9.What is GUI status? How to create /Edit GUI status?

-A GUI status is a subset of the interface elements used for a certain screen.The status comprises

those elements that are currently needed by the transaction .The GUI status for a transaction may be composed of the following
elements:

-Title bar.

-Mneu bar.

-Application tool bar

-Push buttons.

To create and edit GUI status and GUI title,we use the Menu Painter.

10. How does the interaction between  the Dynpro and the ABAP/4 Modules takes place?

-A transaction is a collection os screens and ABAP/4 routines, controlled and executed by a Dialog processor. The Dialog processor
processes screen after the screen, thereby triggering the appropriate

ABAP/4 processing of each screen .For each screen,the system executes the flow logic that contains the corresponding ABAP/4
processing.The controls passes from screen flow logic to ABAP/4 code and back.

11. How does the Dialog handle user requests?

-          when an action is performed ,the system
triggers the PROCESS AFTER INPUT event.The data passed includes field screen data data entered by the user and a function code. A  function code is a technical name that has been allocated in a screen Painter or Menu Painter to a meny entry,a push button,the ENTER key or a function Key of a screen.An internal work field(ok-code)in the PAI module evaluates the function code,and the appropriate action is taken.

    What is to be defined for a push button fields in the screen attributes?

-          A function code has to be defined in the screen attributes for the push buttons in a screen.

    How are the function code handles in Flow Logic?

           – When the User selects a function in a transaction ,the system copies the function code into a           specially
designated work field called OK_CODE.This field is Global in ABAP/4 Module Pool.The OK_CODE can then be evaluated in the corresponding PAI module. The function code is always passed in Exactly the same way , regardless of Whether it comes from a screen’s pushbutton,a menu option ,function key or other GUI element.

14.What controls the screen flow?

-          The SET SCREEN and LEAVE SCREEN statements controls screen flow.

    The Function code currently active is ascertained by what Variable?

-          The function code currently active in  a
Program can be ascertained from the SY-UCOMM  Variable.

    The function code currently  active is ascertained by what variable ?

-          By SY-UCOMM Variable.

    What are the “field” and “chain” Statements?

-          The FIELD and CHAIN flow logic statements let
you Program Your own checks.FIELD and CHAIN tell the system Which fields you are checking and Whether the System should Perform Checks in the flow logic or call
an ABAP/4 Module.

    What is an “on input filed” statements?

-          ON INPUT

The ABAP/4 module is called only if a field contains the Value other than the initial Value.This initial Value is determined by the
filed’s Dta Type: blanks for character Fields

,Zeroes for numerics. If the  user changes the Fields Value back t o its initial value,ON INPUT does not trigger a call.

    What is an “on request Field” statement?

-          ON REQUEST

The ABAP/4 Module is called only if the user has entered the value in the field value since the last screen display .The Value
counts as changed Even if the User simply types in the value that was already there .In general ,the ON REQUEST condition is triggered through any

Form of” MANUAL INPUT’.

    What is an on”*-input filed” statement?

ON *-INPUT

-          The ABAP/4 module is called if the user has
entered the “*” in the first  character of the field, and the field has the attribute  *-entry in the screen Painter.You can use this option in Exceptional
cases where you want to check only fields with certain Kinds of Input.

    What are conditional chain statement?

ON CHAIN-INPUT similar to ON INPUT.

The ABAP/4 module is called if any one of the fields in the chain contains a value other than its initial value(blank or nulls).

ON CHAIN-REQUEST

This condition functions just like ON REQUEST, but the ABAP/4 module is called if any one of the fields in the chain changes value.

    What is “at exit-command:?

The flowlogic Keyword at EXIT-COMMAND is a special addition to the MODULE statement in the Flow Logic .AT EXIT-COMMAND lets you
call a module before the system executes the automatic fields checks.

    Which Function type has to be used for using “at exit-command” ?

-          To Use AT EXIT – COMMAND ,We must assign a function Type “E” to the relevant function in the MENU Painter OR Screen Painter
.

    What are the different message types available in the ABAP/4 ?

-          There are 5 types of message types available.

-          E: ERROR

-          W-WARNING

-          I –INFORMATION

-          A-ABNORMAL TERMINATION.

-          S-SUCCESS

    Of the two “ next screen “ attributes the attributes that has more priority is ——————-.

Dynamic.

    Navigation to a subsequent screen can be specified statically/dynamically. (TRUE/FALSE).

TRUE.

    Dynamic screen sequence  for a  screen can be set using ————- and —————– commands

     Set Screen, Call screen.

27. The commands through Which an ABAP/4 Module can “branch to “ or “call” the next screen are

   1.————,2————–,3—————,4————.

-          Set screen<scr no>,Call screen<scr no> ,Leave
screen, Leave to screen <scr no>.

28. What is difference between SET SCREEN and CALL SCREEN ?

-          With SET SCREEN the current screen simply
specifies the next screen in the chain , control branches to this next screen  as sonn as th e current screen has been processed .Return from next screen to
current screen is not automatic .It does not interrupt  processing of the current screen.If we want to branch  to the next  screen without finishing  the
current one ,use LEAVE SCREEN.



-          With CALL SCREEN , the current (calling) chain
is suspended , and a next screen (screen chain) is called .The called can then return to the suspended chain with the statement LEAVE SCREEN TO SCREEN 0
.Sometime we might want  to let an user call a pop up screen from the main application screen to let him enter secondary information.After they have
completed their enteries, the users should be able to close the popup and return directly to the place where they left off in the main screen.Here comes CALL
SCREEN into picture .This statement lets us insert such a sequence intp the current one.

29. Can we specify the next screen number with a variable (*Yes/No)?

-          Yes



30.    The field SY-DYNR refers to————–



Number of the current screen.



31.    What is dialog Module?

-       A dialog Module is a callable sequence of screens that does not belong to a particular transaction.Dialog modules have
their module pools , and can be called by any transaction.



32.    The Syntex used to call a screen as dialog box (pop up)is———



CALL SCREEN <screen number.>

STARTING AT <start column><start line>

ENDING AT <end column> <end line>



33.    What is “call mode”?

-          In the ABAP/4  WORLD each stackable sequence
of screens is a “call mode”, This is IMP because of the way u return from the given  sequence .To terminate a call mode and return to a suspended chain set
the “next screen” to 0 and leave to it:

LEAVE TO SCREEN 0 or (SET SCREEN 0 and LEAVE SCREEN) .When u return to     the suspended chain execution resumes with the
statement  directly following the original CALL SCREEN statement.The original sequence of screens in a transaction (that is , without having stacked any
additional call modes),you returned from the transaction altogether.





34.    The max number of  calling modes stacked at one time is?

-          NINE



35.    What is LUW  or Data base Transaction ?



-          A “LUW”(logical unit of work) is the span of
time during which any database updates must be performed in an “all or nothing” manner .Either they are all performed (committed),or they are all thrown  away
(rolled back).In the ABAP/4 world , LUWs and

-          Transactions can have several meanings:



LUW (or “database LUW” or “database transaction”)



This is the set of updates terminated by a database commit. A LUW lasts, at most, from one screen change to the next (because the
SAP system triggers database commits automatically at every screen change).



36.    What is SAP LUW or Update Transaction?

Update transaction (or “SAP LUW”)

This is a set of updates terminated by an ABAP/4 commit.  A SAP LUW may last much longer than a database LUW, since most update
processing extends over multiple transaction screens.  The programmer terminates an update transaction by issuing a COMMIT WORK statement.



37.    What happens if only one of the commands SET SCREEN and LEAVE SCREEN is used without using the other?

If we use SET SCREEN without LEAVE SCREEN, the program finishes processing for the current screen before branching to <scr
no>.  If we use LEAVE SCREEN without a SET SCREEN before it, the current screen process will be terminated and branch directly to the screen specified as the
default next-screen in the screen attributes.



38.    What is the significance of the screen number ‘0’?

In “calling mode”, the special screen number 0 (LEAVE TO SCREEN 0) causes the system to jump back to the previous call level.  That
is, if you have called a screen sequence with CALL SCREEN leaving to screen 0 terminates the sequence and returns to the calling screen.  If you have not
called a screen sequence, LEAVE TO SCREEN 0 terminates the transaction.



39.    What does the ‘SUPPRESS DIALOG’ do?

Suppressing of entire screens is possible with this command.  This command allows us to perform screen processing “in the
background”.  Suppresing screens is useful when we are branching to list-mode from a transaction dialog step.



40.    What is the significance of the memory table ‘SCREEN’?

At runtime, attributes for each screen field are stored in the memory table called ‘SCREEN’.  We need not declare this table in
our program.  The system maintains the table for us internally and updates it with every screen change.



41.    What are the fields in the memory table ‘SCREEN’?

Name                     Length
Description



NAME                     30                     Name
of the screen field

GROUP1                 3                      Field
belongs to field group 1

GROUP2                 3                      Field
belongs to field group 2

GROUP3                 3                      Field
belongs to field group 3

GROUP4                 3                      Field
belongs to field group4

ACTIVE                  1                      Field
is visible and ready for input.

REQUIRED              1                      Field
input is mandatory.

INPUT                    1                      Field
is ready for input.

OUTPUT                 1                      Field
is display only.

INTENSIFIED          1                      Field is
highlighted

INVISIBLE              1                      Field
is suppressed.

LENGTH                 1                      Field
output length is reduced.

DISPLAY_3D          1                      Field is
displayed with 3D frames.

VALUE_HELP         1                      Field is
displayed with value help.



42.    Why grouping of fields is required? What is the max no of modification groups for each field?

If the same attribute need to be changed for several fields at the same time these fields can be grouped together.  We can specify up
to four modification groups for each field.



43.    What are the attributes of a field that can be activated or deactivated during runtime?

Input, Output, Mandatory, Active, Highlighted, Invisible.



44.    What is a screen group? How it is useful?

Screen group is a field in the Screen Attributes of a screen.  Here we can define a string of up to four characters which is available
at the screen runtime in the SY-DNGR field.  Rather than maintaining field selection separately for each screen of a program, we can combine logically
associated screens together in a screen group.



45.    What is a Subscreen? How can we use a Subscreen?

A subscreen is an independent screen that is displayed in a n area of another (“main”) screen.  To use a subscreen we must
call it in the flow logic (both PBO and PAI) of the main screen.  The CALL SUBSCREEN stratement tells the system to execute the PBO and PAI events for the
subscreen as part of the PBO or PAI events of the main screen.  The flow logic of your main program should look as follows:

PROCESS BEFORE OUTPUT.

CALL SUBSCREEN <area> INCLUDING ‘<program>’ ’<screen>’.

PROCESS AFTER INPUT.

CALL SUBSCREEN <area>.

Area is the name of the subscreen area you defined in your main screen.  This name can have up to ten characters.  Program is the name
of the program to which the subscreen belongs and screen is the subscreen’s number.



46.    What are the restrictions on Subscreens?

Subscreens have several restrictions.  They cannot:

·             Set their own GUI status

·             Have a named OK code

·             Call another screen

·             Contain an AT EXIT-COMMAND module

·             Support positioning of the cursor.



47.    How can we use / display table in a screen?

ABAP/4 offers two mechanisms for displaying and using table data in a screen.  These mechanisms are TABLE CONTROLS and STEP LOOPS.



48.    What are the differences between TABLE CONTROLS and STEP LOOPS?

TABLE CONTROLS are simply enhanced STEP LOOPS that display with the look and feel of a table widget in a desktop application.  But
from a programming standpoint, TABLE CONTROLS and STEP LOOPS are almost exactly the same.  One major difference between STEP LOOPS and TABLE CONTROLS is in STEP
LOOPS their table rows can span more than one time on the screen.  By contrast the rows in a TABLE CONTROLS  are always single lines, but can be very long.
(Table control rows are scrollable).  The structure of table control is different from step loops.  A step loop, as a screen object, is simply a series
of field rows that appear as a repeating block.  A table control, as a screen object consists of: I) table fields (displayed in the screen ) ii) a control
structure that governs the table display and what the user can do with it.



49.    What are the dynapro keywords?

FIELD, MODULE, SELECT, VALUES and CHAIN are the dynapro keywords.



50.    Why do we need to code a LOOP statement in both the PBO and PAI events for each table in the screen?

We need to code a LOOP statement in both PBO and PAI events for each table in the screen.  This is because the LOOP statement causes
the screen fields to be copied back and forth between the ABAP/4 program and the screen field.  For this reason, at least an empty LOOP….ENDLOOP must be there.



51.    The field SY-STEPL refers to the index of the screen table row that is currently being processed.  The system variable
SY-stepl only has a meaning within the confines of LOOP….ENDLOOP processing.  Outside the loop, it has no valid value.



52.    How can we declare a table control in the ABAP/4 program?



Using the syntax controls <table control name> type tableview using screen <scr no>.



53.    Differentiate between static and dynamic step loops.

Step loops fall into two classes: Static and Dynamic.  Static step loops have a fixed size that cannot be changed at
runtime.  Dynamic step loops are variable in size.  If the user re-sizes the window the system automatically increases or decreases the number of step loop
blocks displayed.  In any given screen you can define any number of static step loops but only a single dynamic one.



54.    What are the two ways of producing a list within a transaction?

By submitting a separate report.

By using leave to list-processing.



55.    What is the use of the statement Leave to List-processing?

Leave to List-processing statement is used to produce a list from a module pool.  Leave to list processing statement allows to switch
from dialog-mode to list-mode within a dialog program.



56.    When will the current screen processing terminates?

A current screen processing terminates when control reaches either a Leave-screen or the end of PAI.



57.    How is the command Suppress-Dialog useful?

Suppressing entire screens is possible using this command.  This command allows us to perform screen processing “in the
background”.  The system carries out all PBO and PAI logic, but does not display the screen to the user.  Suppressing screens is useful when we are branching to
list-mode from a transaction dialog step.



58.    What happens if we use Leave to list-processing without using Suppress-Dialog?

If we don’t use Suppress-Dialog to next screen will be displayed but as empty, when the user presses ENTER, the standard list output
is displayed.



59.    How the transaction that are programmed by the user can be protected?

By implementing an authority check.



60.    What are the modes in which any update tasks work?

Synchronous and Asynchronous.



61.    What is the difference between Synchronous and Asynchronous updates?

A program asks the system to perform a certain task, and then either waits or doesn’t wait for the task to finish.  In synchronous
processing, the program waits: control returns to the program only when the task has been completed.  In asynchronous processing, the program does not wait: the
system returns control after merely logging the request for execution.



62.    SAP system configuration incluedes Dialogtasks and Update tasks.

63.    Dialog-task updates are Synchronous  updates.

64.    Update –task updates are Asynchronous updates.

65.    What is the difference between Commit-work and Rollback-Work tasks?

Commit-Work statement “performs” many functions relevant to synchronized execution of tasks.  Rollback-work statement “cancels:
all reuests relevant to synchronized execution of tasks.



66.    What are the different database integrities?

·         Semantic Integrity.

·         Relational Integrity.

·         Primary Key Integrity.

·         Value Set Integrity.

·         Foreign Key integrity and

·         Operational integrity.



67.    All SAP Databases are Relational Databases.

68.    What is SAP locking?

It is a mechanism for defining and applying logical locks to database objects.



69.    What does a lock object involve?

The tables.

The lock argument.



70.    What are the different kinds of lock modes?

Shared lock

Exclusive lock.

Extended exclusive list.



71.    How can a lock object be called in the transaction?

By calling Enqueue<lock object> and Dequeue<lock object> in the transaction.



72.    What are the events by which we can program “help texts” and display “possible value lists”?

-PROCESS ON HELP-REQUEST (POH).

-PROCESS ON VALUE-REQUEST (POV).



73.    What is a matchcode?

A matchcode is an aid to finding records stored in the system whenever an object key is required in an input field but the user
only knows other (non-key) information about the object.



74.    In what ways we can get the context sensitive F1 help on a field?

-          Data element documentation.

-          Data element additional text in screen painter.

-          Using the process on help request event.



75.    What is roll area?

A roll area contains the program’s runtime context.  In addition to the runtime stack and other structures, all local variables and
any data known to the program are stored here.



76.    How does the system handle roll areas for external program components?

-          Transactions run in their own roll areas.

-          Reports run in their own roll areas.

-          Dialog modules run in their own roll areas

-          Function modules run in the roll area of their
callers.



77.    Does the external program run in the same SAP LUW as the caller, or in a separate one?

-          Transactions run with a separate SAP LUW

-          Reports run with a separate SAP LUW.

-          Dialog modules run in the same SAP LUW as the
caller

-          Function modules run in the same SAP LUW as
the caller.

The only exceptions to the above rules are function modules called with IN UPDATE TASK (V2 function only) or IN BACKGROUND TASK (ALE
applications).  These always run in their own (separate) update transactions.



78.    What are function modules?

Function modules are general-purpose library routines that are available system-wide.



79.    What are the types of parameters in the function modules?

In general, function module can have four types of parameters:

-          EXPORTING: for passing data to the called function.

-          IMPORTING: for receiving data returned from the function module.

-          TABLES: for passing internal tables only, by reference (that is, by address).

-          CHANGING: for passing parameters to and from
the function.



80.    What is the difference between Leave Transaction and Call Transaction?

In contrast to LEAVE TO TRANSACTION, the CALL TRANSACTION  statement causes the system to start a new SAP LUW.  This second
SAP LUW runs parallel to the SAP LUW  for the calling transaction.



81.    How can we pass selection and parameter data to a report?

There are three options for passing selection and parameter data to the report.

-          Using SUBMIT…WITH

-          Using a report variant.

-          Using a range table.



82.    How to send a report to the printer instead of displaying it on the screen?

We can send a report to the printer instead of diplaying it on the screen.  To do this, use the keywords TO SAP-SPOOL:

SUBMIT RSFLFIND…TO SAP-SPOOL DESTINATION ‘LT50’.



83.    How can we send data to external programs?

Using SPA/GPA parameters(SAP memory).

Using EXPORT/IMPORT data (ABAP/4 memory)



84.    What are SPA/GPA parameters (SAP memory)

SPA/GPA parameters are field values saved globally in memory.  There are two ways to use SPA/GPA parmeters:

Smartforms and SAPscripts

To Create a Bar code prefix:

1) Go to T-code - SPAD -> Full Administration -> Click on Device Type -> Double click the device for which you wish to create the print control -> Click on Print Control tab ->Click on change mode -> Click the plus sign to add a row or prefix say SBP99 (Prefix must start with SBP) -> save you changes , it will ask for request -> create request and save

2) Now when you go to SE73 if you enter SBP00 for you device it will add the newly created Prefix


Create a character format C1.Assign a barcode to the character format.Check the check box for the barcode.

The place where you are using the field value use like this

<C1> &itab-field& </C1>.

You will get the field value in the form of barcode.



Question 3:What is the difference between SAPSCRIPT and SMARTFORM? 
SAPSCRIPT
SMARTFORM
SAPSCRIPT is client dependent.
SMARTFORM is client independent.
SAPSCRIPT does not generate any Function module.
SMARTFORM generates a Function Module when activated.
Main Window is must.
You can create a SMARTFORM without a Main Window.
SAPSCRIPT can be converted to SMARTFORMS. Use Program SF_MIGRATE.
SMARTFORMS cannot be converted to SCRIPT.
Only one Page format is possible
Multiple page formats are possible.
Such thing is not possible in SCRIPT.
You can create multiple copies of a SMARTFORM using the Copies Window.
PROTECT … ENDPROTECT command is used for Page protection.
The Protect Checkbox can be ticked for Page Protection.

The way SMARTFORM is developed and the way in which SCRIPT is developed is entirely different. Not listing down those here. That would be too much. 
Question 19: A system has two clients 100 and 500 on the same application server. If you make changes to a SAPSCRIPT on client 100, will the changes be available in client 500?

No. SAPSCRIPT is client dependent. You will have to transport changes from client 100 to client 500. However, for SMARTFORMS, Changes will be made both for client 100 and client 500.  

Smartforms interview 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 'forminterface' 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.
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 name
move sf_label to externalname.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = externalname
importing
fm_name = internalname
exceptions
no_form = 1
no_function_module = 2
others = 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 output difference

Problem 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 PDF
There is a way to download smartform in PDF format.
Please do the following:
1. Print the smartform to the spool.
2. Note the spool number.
3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the
noted spool number.
SmartForm Doublesided printing question 
Your customer wants your PO SmartForm to be able to print "Terms and Conditinos" 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.
- 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.
 **************************
Sap scripts components –
The various component of the SAP script tools are:
 
1. Editor - Edits the text in a SAPscript form. The transaction of 
an application automatically calls this editor if you need to maintain 
texts related to the application.
 
2.Styles and  Forms - Define and print the style and layout of SAPscript form.
 
3. Composer or From processor - Acts as central output module to prepare
 final layout and text for an output device by including styles , various 
 formating options and the respective text.
 
4. Programming interface - Allows you to include SAPscript component into
 ABAP program and control the output of forms from the program.
 
5. Database tables - Store texts, styles and forms.
how many times a main window can be placed on placed on the
same page in a layout
 
99 main windows we can place in same page Main00, Main01..... Main98
 
 
what is the differ b/w script and smartform
 
1) Script is Client Dependent.
   Smartforms are Client InDependent.
 
2) Multiple Page formats are possible in Smartforms.
   Multiple Page formats are notpossible in Scripts.
 
3) We can maintain Background Graphics in Smartforms.
 
4) Scripts doesnot generate any Functionmodules.
   Smartforms generate  Functionmodules.
 
5) We can add colours in Smartforms
   We cannot add colours in Scripts
 
6) Scripts maintains 99 mainwindows .
   Smartforms maintains only one Main window.
 
7) Smartforms are 100% portable by exporting to .xml format.
   Scripts layouts are not portable. Even if we import a 
Script into a smartform, its not 100% imported.
 
8) Templates are available in Smartforms but not in Scripts.
 
 
 
why scripts are client dependent and smart forms are client 
independent.?
 
when u create a smart form it will store in the form of
function module program.where several clients can call that
fn module where they want to..so it is client independent.
 
sap script is a word processing tool which displays data on 
the form with the help of text elements where the logic of 
those is written in the print program and Forms were 
designed to be driven from print program, hence are often 
termed as client dependent. 
 
Smart forms are client independent. Bcoz it doesn’t use any 
text elements. it will be executed through a function 
module. When a print program calls a Smart Form, the form 
itself takes over to produce output, without any further 
direction from print program.
 
 
can we migrate custom defined smart form into adobe form, if
yes what are connecting settings we have to make in adboe form?
 
Yes we can migrate smartforms into adobe forms.
Additional settings are not required
In SFP transaction there is option in menu for migrate.Give 
smartform name and it will be converted in adobe form.
Two components will be created when u migrate smartform 
into adobe.
Interface and form.
                     
 
i have created script logo.is that logo goes to develpment 
to quality?
thru tranport request,using RSTXSCRP std program
 
can we transport text elements and text symblos in reports 
from devlopment to quality?is it necessary?
 
once we created text element or text symbols..we must 
assign text element to transport request through program 
RSTXTRAN.
            
 
Types of window in smartforms –
 
There are four types of windows:
MAIN WINDOW.
SECONDARY WINDOW.
COPIES WINDOW.
FINAL WINDOW.
 
U ca have only one main window in smartforms.
 
 
how to convert sapscript to email.....
There are several ways to do this.
Best and most practiced way is convert script to PDF and
send this PDF as attachment in mail.We use
"CONVERT_OTF_2_PDF" function module to convert script to PDF.
 
We can also use "CONVERT_OTFSPOOLJOB_2_PDF" function module
to do this. In 4.7 version of SAP, we can use standard
program RSTXPDF2T to serve this purpose.
 
After converting script to PDF, we use
"SO_DOCUMENT_SEND_API" to send this PDF as attachment to mail.
 
 
In Sapscript ,
For example : I want to define font in Arial?
And that font is not available in my system ? how can i get
this font into my sapscript?
 
Go to SE73, select True type font installation button,then 
in the font name give the font name  and if required bold 
and italic options select the attibute then in the font 
name file parameter give the font file (.ttf format) then 
execute the same.       
 
 
 
 
How to write long-text in SAP scripts?
EX: I want to write text like below:
* Terms and Conditions:
1>....
2>....
3>....
 
use the function module read_text . 
this is used to display the data from long text .
you can read the data from this function module and store it in 
tdline that is in the export of the function module
 
using this statement in SAPSCRIPT INCLUDE &REGUD-TXTUN&
OBJECT TEXT ID ADRS
 
by which function module we are going to put data into
sapscript ?
 
write_form for all the windows
read_text for standard text
 
 
 
How to put page-breaks in smartforms?
 
in smartfoms under loop statement in data tab select event 
on sort end checkbox .then one event on sort end node will 
be displayes just right click on  this node  & select 
command option . then in command select go to new page 
checkbox & give new page name .
 
 
 
Can we execute the script individually? If yes How? Else 
what
we need to do so?
 
U can execute ur script individually. for that goto
utilities --> printing test. By doing so u can view the 
texts placed in ur variable windows . but the text in Main 
windows can be seen only when u run a driver program. For 
tht goto se38 and from thr use function modules OPEN_FORM, 
WRITE_FORM, CLOSE_FORM. Pass the Text elements in the 
function module WRITE_FORM. and execute it. u can see the 
output.
 
 
Are Layout sets Client independent?
no Clinet dependent
 
 
How do you assign a print program to a script?
 
we can assign print program andscript in NACE T-code in 
the output type
 
 
 
Template & Table in Smartforms       
 
Tables are the dynamic in nature.
Tables are used in main window.
 
Templates are static in nature.
They are used in secondary windows.
 
 
how to copy client to client in scripts?
 
If it is to copy script between clients then,
se71,
utilities-copy frm client.
 
 
Check Out the SAP Standard program: RSTXCPY
 
 
 
 
 
 
 
What is the use of PROTECT and ENDPROTECT?
 
in sap-scripts what u write the text in between ptotect and 
endprotect it tryies to print the entire text in with in a 
window if not possible checks another window if possible 
print the entire text in that window there also not 
possible how text to print in that window is possible print 
that much of text remaining will print in another window.
 
eg:
 
mostly protect endprotect we are used in main window.
first it tries to print in main00 is not possible checks 
the main01 is possible print it ohterwise how space is 
sufficient print that much of text print and remaining will 
print in main02.
 
 
why u can call(r using) ssf_function_module_name in smartforms?
A function module is generated whenever a Smart Form is 
activated. This Smart Form could be called from the driver 
program by calling the function module generated in the 
system directly.
 
But this is not an efficient way of calling Smart Form for 
the following reason:
 
Whenever a Smart Form is generated, a function module is 
generated and the naming convention for that Smart Form is 
done internally by using Number range object or something 
similar. Let us consider the function module name 
as /1BCDWB/SF00000359. The function module for the next new 
and activated Smart Form would be /1BCDWB/SF00000360, one 
more than the previous one.
 
So when this Smart Form is transported from the development 
to Quality or Production system, a new function module name 
is generated according to the number series available in 
that system. If the above program is transported to either 
quality or production system, the program might go for a 
dump as the function module is not available in that 
system, because the number series generated in the for 
example in development system will be different from that 
of the quality system . To handle this situation, we use 
the function module SSF_FUNCTION_MODULE_NAME to get the 
name of the function module for a Smart Form dynamically. 
If the form is not active, the function module 
SSF_FUNCTION_MODULE_NAME raises the exception NO_FORM.