ABAP Programming - Day 3
ABAP Programming - Day 3
Day 3
Break Points (Session/External), Watch Points & Debugging -> Program Flow; Logic better
Function Module
Create one simple FM with MATNR as IMPORTING Parameter & WERKS field of MARC as
EXPORTING/Table Parameter
File Handling
Local File/Presentation - Upload/Download
Variant is a concept of saving a set of input fields with values with a particular name, so that we can use
the same set of inputs next time.
The extended program check can be called for activated programs either from ABAP Workbench or by
using transaction SLIN. It performs static checks that are too complex for the normal syntax check.
Use the extended program check and take the results seriously.
For the Code Inspector we will use the t-code SCI. It helps developers to adhere to programming standards
and guidelines by creating messages on less-than-optimal coding. The Code Inspector can be used in
various scenarios with different types of checks, thus providing insights into the code quality from various
angles. We can create a Custom Variant as well
Write the below Demo Program and do an inspection via SCI and use the Custom Variant
created and check the Results via Logs
Important part in troubleshooting of an ABAP application. Helps in understanding the program flow and
logic better. Having good debugging skill is an Art and added Advantage.
Two kinds of BPs: - Static (By using BREAK-POINT) and Dynamic (External or Session) and also in the
debugger we can place BPs which are known as Debugger BPs.
Check F5, F6, F7, F8(Icon Strip) and how to create a watchpoint. Check the current cursor line in
debugger as in the yellow line. Also check the Desktop Strip and Tools available on the right side and
Variable Fast Display along with system variables(syst).
Will show some more BP concepts to participants by playing around with Internal Table and Variables
and how to change the entries.
Function Module
Create one simple FM with MATNR as IMPORTING Parameter & WERKS of MARC as EXPORTING/Table
Parameter. FM name ZFM_FETCH_PLANT_DETAIL. Use the FM created in report Z_ABAP_TRAINING.
(Save Test Data, Test & Debug)
3. Update Module-> An Update Function Module has a special purpose. Consider a situation
where a vendor is to be created followed by a vendor extension. The prerequisite to
extend a vendor, the same vendor should be available in the database. Viz. a vendor
150100 is to be created in company 1000 and the same vendor needs to be extended to
companies 1001 and 1002. The vendor extension code is written in an update function
module and will be called as CALL FUNCTION ‘ZMM_EXTEND_VENDOR’ IN UPDATE
TASK exporting the relevant parameters. This function call will be kept in a queue rather
than executing it. Then the vendor is created and checked whether the creation is
successful. If the vendor creation is successful, a COMMIT WORK is called which executes
all Update Function Modules in the queue. If the transaction is failure, either a ROLLBACK
is called or the program is exited as is.
So, if a predefined set of instructions need to be executed after a successful execution of a module,
the predefined set is made an Update Module and called when needed. When the work is committed
on a successful execution, the Update Module in the queue is called.
START-OF-SELECTION.
ls_data-emp_id = '1001'.
ls_data-address = 'ABC Street'.
ls_data-city = 'Bangalore'.
ls_data-state = 'Karnataka'.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
COMMIT WORK.
ENDFUNCTION.
Also, since the updates registered via update FM are executed in Special Work Processes UPD
hence exceptions are not considered for Update FMs.
For debugging an update FM, we have to change the settings via going to Debugger and Click on
Change debugger profile/settings button and then the update FM will be triggered on reaching
COMMIT WORK.
File Handling
Local File/Presentation - Upload/Download
Show the Custom Prog: - Z_ABAP_TRAINING_UPLD_DWNLD to upload files from Pres. Server to App
Server and similarly download from App. Server to Presentation Server. There is also a provision to delete
files from both Presentation and App. Server. Execute the program and show them with the help of
debugging as in what’s the flow and how File Handling can be done.
Explain the concepts to participants w.r.t GUI_UPLOAD and GUI_DOWNLOAD AND THE CONCEPT OF
DATASET to read and write files.(IN BINARY OR TEXT MODE FOR INPUT/OUTPUT)
Difference, Advantage, Disadvantage: - Jobs can be scheduled in background mode not only at the current
time, but it can also be scheduled for future time. If you schedule a background job which does
GUI_DOWNLOAD/UPLOAD, your program would dump or cancel out. The reason being, want to take
chance. GUI_DOWNLOAD/UPLOAD needs your laptop/computer to be switched on for it to save the data
in the presentation server path. Say you scheduled a job which has GUI_DOWNLOAD/UPLOD and switched
off your laptop and went to bed. When the job actually triggers, where will it save the file since your
laptop is switched off?
Therefore, SAP came with Application File Concept (although not just for background job).
Now, let us do the same exercise. You have OPEN DATASET (for AL11) syntax in your program. You
schedule a job. Switch off your laptop and go to sleep. In the middle of the night, the job triggers and it
saves the file in Application Server (AL11). It is not dependent on your local laptop or desktop. It is at the
Server level and Servers normally never sleep (except at planned outage or downtime).
Concept of OPEN DATASET, CLOSE DATASET…. (OUTPUT & INPUT MODE) … TRANSFER….. / READ
DATASET…/ DELETE DATASET… and so on.
While creating an Include Program what is the Type to be chosen under Program Attributes?
• Executable
• Include
• Module Pool
• Function Group
Suppose you set a Session BP in an ABAP program and you log off from the session and log in as a
different user; will the session BP be still applicable?
• Yes
• No
For passing the Parameters in an Update or RFC FM can we pass them by Reference?
• Yes
• No
For calling a FN. Module in Update Task which statement needs to be executed?
What is the t-code used for Configuring a directory in SAP App. Server?
• AL11
• SM51
• WE05
• BD87
Exercise: -
• Explore AL11 and DATASET concepts and create a program for the same by making use of the
concepts learnt? (Same as in lines of the concept taught today). The below screens to be
designed and the functionality to be achieved as shown in class.
• Explore SCI and create your own variant by making use of DEFAULT variant and then use this
variant to inspect an ABAP object.
• Explore the Debugger Screen and find out how many Desktop strips are there and also play
around by changing the values of an Internal Table during debugging.
• Explore V1, V2 and V3 update FM in detail. Also try to show some real time use cases of V1 and
V2 update FMs and also which work-process will be used for V1 and V2? (Hint: - UPD and UP2)
• Can’t we call an Update FM without making use of CALL FM…” IN UPATE TASK” statement. If yes
please try the same with the help of an example and do end to end testing.