Thursday, May 12, 2022

Differences between Macros & Subroutines in SAP

Differences between Macros & Subroutines:-

 Macros Subroutines

1. In macro definition should be the 

first & the calling should be the next. 

2. The definition of the macro as 

well as the calling of the macro in 

the same program.

3. Macros can take up to 9 place 

holders. 

4. We can place any executable 

statements after the definition of the 

macro.

5. Macros are used in HR ABAP.

1. In subroutine calling should be the 

first & definition should be the next.

2. The definition of the subroutine as 

well as the calling of the subroutine 

may or may not be in the same 

program.

3. Subroutines can take any number 

of place holders.

4. We can‘t place any executable 

statements after the definition of the 

macro.

5. Subroutines are used in both 

ABAP & HR ABAP.

Global data:-

 Subroutines can access the global declarations in which they are 

defined.

When ever the changes occurred in the subroutine those changes will be reflected 

to global declarations. 

Note:-

LOCAL is the keyword to avoid the changes in subroutines.Differences between Macros & Subroutines:-

 Macros Subroutines

1. In macro definition should be the

first & the calling should be the next.

2. The definition of the macro as

well as the calling of the macro in

the same program.

3. Macros can take up to 9 place

holders.

4. We can place any executable

statements after the definition of the

macro.

5. Macros are used in HR ABAP.

1. In subroutine calling should be the

first & definition should be the next.

2. The definition of the subroutine as

well as the calling of the subroutine

may or may not be in the same

program.

3. Subroutines can take any number

of place holders.

4. We can‘t place any executable

statements after the definition of the

macro.

5. Subroutines are used in both

ABAP & HR ABAP.

Global data:-

 Subroutines can access the global declarations in which they are

defined.

When ever the changes occurred in the subroutine those changes will be reflected

to global declarations.

Note:-

LOCAL is the keyword to avoid the changes in subroutines.

Monday, April 25, 2022

Differences between function module & subroutine in SAP ABAP.

Differences between function module & subroutine in SAP ABAP. 

 Function module

 Subroutine 

1. Function modules are global, i.e., 

we can access the function module 

with in the server as well as outside 

the server also.

2. We can test the function module 

independently.

3. We can handle the errors in 

function module.

4. Function modules are defined by 

using SE37 transaction code.

1. Subroutines are local, i.e., we can 

access the subroutine with in the 

server only.

2. We can‘t test the subroutine 

independently without calling the 

subroutine.

3. We can‘t handle the errors in 

Subroutine.

4. Subroutines are defined by using 

SE38 transaction code.

Steps to create function module:-

 Execute SE37.

 Provide your function module name.

 Create.

 Provide function group name & short description.

 Save. 

How to create Function Group in SAP ABAP.

Steps to create Function group:-

 Execute SE37.

 In the menu bar – goto – function groups – create group.

 Provide your function group name.

 Provide short description.

 Save – local object.

Steps to activate the function group:-

 Execute SE37.

 In the menu bar – environment – inactive objects.

 Expand your function group.

 Select your function group.

 Click on activate (in ECC 6.0 – select function group – right click – activate).

Components of the function module:-

1. Attributes.

2. Import.

3. Export.

4. Changing.

5. Tables.

6. Exception.

7. Source code.

Differences between Macros & Subroutines:-

Differences between Macros & Subroutines:-

 Macros

 Subroutines

1. In macro definition should be the 

first & the calling should be the next. 

2. The definition of the macro as 

well as the calling of the macro in 

the same program.

3. Macros can take up to 9 place 

holders. 

4. We can place any executable 

statements after the definition of the 

macro.

5. Macros are used in HR ABAP.

1. In subroutine calling should be the 

first & definition should be the next.

2. The definition of the subroutine as 

well as the calling of the subroutine 

may or may not be in the same 

program.

3. Subroutines can take any number 

of place holders.

4. We can‘t place any executable 

statements after the definition of the 

macro.

5. Subroutines are used in both 

ABAP & HR ABAP.

Differences between single select &select up to 1 in SAP ABAP.

Differences between single select &select up to 1 rows:- 

 Select single

 Select up to 1 rows 

1. It always retrieves only one record 

at a time.

2. Here we must pass entire primary 

key combination in the where 

condition.

3. This is used to retrieve particular 

record.

Syntax:-

1. It always retrieves only one 

record.

2. Enough to pass a part of key 

combination in the where condition. 

It always picks the first record 

among the matched records.

3. This is used for validation.


Create Table step in SAP ABAP

Create Table step in SAP ABAP. 

Steps to create the Emp table by using Top-down approach data type. 

element:-

 Execute SE11.

 Select the radio button database table.

 Provide your table name (YSPRAO_730_Emp1).

 Click on create – enter.

 Provide any short meaningful description (Emp table by using Top-down 

approach).

 Provide delivery class (a).

 Select the maintenance allowed.

 Click on the fields tab.

 Provide the field name (Eid) & data element name which is not there 

(ZZSPRAO_730_Eid).]

 Double click on the data element – save before editing – yes – local object –

cerate the data element – yes.

 Provide a meaningful description.

 Provide domain name which is not created (ZSPRAO_730_Eid).

 Double click on domain – save before editing – yes – local object – yes. 

 Provide a short description, data type & length.

Eid ZZSPRAO_730_Eid.

  Save the domain.

 Check the domain.

 Activate the domain.

 Come back.

 Save the data element.

 Check the data element.

 Activate the data element.

 Come back.

 Repeat the same for all the fields

Steps to create Data element in SAP ABAP.

Steps to create Data element in SAP ABAP. 

 Execute SE11.

 Select the radio button data type.

 Provide your data element name (YYSPRAO_730_Eid).

 Click on create – enter.

 Provide any short meaningful description (id of the emp).

 Provide domain name which is already created – enter.

 Save the data element.

 Check the data element.

 Activate the data element.

 Repeat the same procedure for all the data elements

Steps to create Domain in SAP ABAP.

 Steps to create Domain in SAP ABAP. 

 Execute SE11.

 Select the radio button domain.

 Provide your domain name (YSPRAO_730_Eid).

 Click on create.

 Provide any short description (domain).

 Provide data type & length.

 Save the domain.

 Check the domain.

 Activate the domain.

 Repeat the same steps to all the domains

STEPS TO BE FOLLOWED IN CREATION OF LAYOUTSET IN SAP ABAP.

STEPS TO BE FOLLOWED IN CREATION OF LAYOUTSET  IN SAP ABAP. 


T-code SE71

Give form name

Give language

Press create button

Give description

Press page button

Give page name

Press enter

Give page description

Give next page name

Press page windows button

 To copy main window Edit --( Create element

 Double click main window. ( main window will be copied to the page)

Give some window width and height (eg. 10 cm and 10 cm)

To see the page format Settings --( Form Painter

Check the check box Graphical Form Painter

Press enter

To adjust the main window , drag it to the place where you want. You can change the size also.

To create new windows right click create window.

Move the window to the position where it is needed and adjust the size.

To rename window Right click Rename.

To close page format Settings-( Form painter

Un check the check box Graphical Form Painter

Press enter

To create paragraph format Press Paragraph formats push button

Give paragraph format name

Press enter

Give description

Press header

Press Basic settings

Give first page and Default paragraph

Save

To check errors form-( check-( Definition

To activate form -( Activate.


This is how we have to design the page. The no of windows in the page depends on page layout. Now I want to keep a logo in one of the windows of page. For that we first have to upload the logo into sap. For uploading logo into sap the T-code is SE78.

      It is used to upload only Bitmap images.


SCRIPTS IN SAP ABAP.

 SCRIPTS IN SAP ABAP. 


It is the integrated text management system of SAP. The output of  scripts and normal report will be same. But formatting is very easy using scripts. Usually scripts are used for external purpose and reports are used for internal purpose. When specific format is required in output we go for scripts.


In scripts we require layout set and print program. Layout set is used for designing the output. That is page designing is done here. For this Transaction code is SE71 (form painter).

Print program is used for writing the logic to get the data from data base. It is an executable program which is written in SE38 T-code.


Attributes of form painter (SE71)

Header

Pages

Windows

Page windows

Paragraph Formats

Character Formats

HEADER:- It contains Basic settings and administrative data. Administrative data gives history of the form and basic settings gives technical information about the form.


PAGES:- It is a logical memory area where output is formatted. It is a repository of pages.


WINDOWS:- I t is a place on the page where output or data is formatted. Page has to be divided into windows in order to hold the output. We cant format the output outside the windows. Windows  is repository of windows.


Paragraph formats and Character formats are used for alignment or beautifying the output.


SESSION METHOD IN SAP ABAP.

SESSION METHOD IN SAP ABAP. 


Differences between call transaction and session method.


In call transaction updation is immediate but in session method updation is not immediate.

In call transaction user has to handle errors but in session system handles the errors.

In call transaction updation can be synchronous or asynchronous or local but in session method updation by default synchronous.

Call transaction returns sy-subrc value but session will not return sy-subrc value.


In session method the data will be stored intermediately in session. After processing the session only the data will be moved into data base. For processing the session the T-code is SM35.


SESSION:- It is an intermediate memory area where data with flow logic is stored. It is intermediate between internal table and data base table. A session can not be processed on the date on which it is created. A session can not be processed if it is processed successfully. If session is having error it can be processed any number of times.



In session method we have to use 3 function modules.

BDC_OPEN_GROUP

BDC_INSERT

BDC_CLOSE_GROUP


BDC_OPEN_GROUP: -  This function module is used to create a session with particular name.


BDC_INSERT:-  This function module is used to move flow logic and data into session. This function module should be called between the loop and endloop after recording steps.


BDC_CLOSE_GROUP:- This function module should be used to close the session. If this function module is not used the session will be created but we cant process the session.

DIFFERENCES BETWEEN AT NEW AND ON CHANGE OF IN SAP.

 DIFFERENCES BETWEEN AT NEW  AND ON CHANGE OF IN SAP. 


At new should be used inside the loop, but on change of can be used outside the loop also.

At new takes only one field, but on change of can take multiple fields.

Let us assume that an internal table is having f1, f2, f3 , f4 and f5 fields and if  at new is applied on f3 field it will be triggered for every change in f1, f2 and f3 fields, but on change of will be triggered for only changes in f3.

TYPES OF REPORTS IN SAP

 

TYPES OF REPORTS IN SAP. 

There are three types of reports.

Classical Reports

Interactive Reports

Drill down Reports


CLASSICAL REPORT:-  A report which can generate only one list, that is Basic List,  is called classical report. First List of a report is called BASIC LIST.


INTERACTIVE REPORT:-  A report which can generate one basic list and upto 20 interactive lists is called an interactive report. First list is called Basic List and Interactive lists are called Secondary Lists.


DRILL DOWN REPORTS:- In these reports the output will be in tree forma

SOME IMPORTANT STANDARD TABLES IN SAP

 SOME IMPORTANT STANDARD TABLES IN SAP


1. MARA MATERIAL MASTER TABLE

2. MARC MATERIAL PLANT

3. MAKT MATERIAL DESCRIPTION

4. MARD MATERIAL STORAGE LOCATION

5. KNA1 CUSTOMER MASTER TABLE

6. LFA1 VENDOR MASTER TABLE

7. EKKO PURCHASE ORDER HEADER

8.  EKPO PURCHASE ORDER ITEM

9.  VBAK SALES ORDER HEADER

10. VBAP SALES ORDER ITEM

11. VBRK BILLING DOCUMENT HEADER

12. VBRP BILLING DOCUMENT ITEM

13. LIKP DELIVERY HEADER

14. LIPS DELIVERY ITEM

CONTROL STATEMENTS IN SAP ABAP

 CONTROL STATEMENTS IN SAP ABAP. 

Control statements are nothing but loops. The property of the loop is to rotate by it self until loop is terminated. There are 4 types of control statements in SAP. They are

DO.

..

..

ENDDO.


DO N  TIMES.

..

..

ENDDO.


WHILE  <CONDITION>.

..

..

ENDWHILE.


CASE  <VARIABLE>.

WHEN <VALUE1>.

 ..

 ..

WHEN <VALUE2>.

 ..


WHEN OTHERS.

 ..


ENDCASE.


Exit statement is used to terminate the loop. SY-INDEX is a system variable which gives present loop iteration number. These both things we use in coming program to see how they act in the loop.

SYSTEM VARIABLES IN SAP ABAP

SYSTEM VARIABLES IN SAP ABAP. 


1. sy-datum   --      Date

2. sy-uzeit     --      Time

3. sy-mandt   --      Logon client number

4. sy-uname   --      Logon user name

5. sy-repid     --       Report program name

6. sy-cprog    --       Current program name

7. sy-dynnr    --       Screen number

8. sy-tcode     --       Transaction code

9. sy-pagno     --       Page number

Sample program with these system variable is.


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

*& Report  ZSAMPLE                                                     *

*&                                                                     *

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

*&                                                                     *

*& SYSTEM VARIABLES                                                    *

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


REPORT  ZSAMPLE                                  .

write / sy-datum.

write / sy-uzeit.

write / sy-uname.

write / sy-repid.

write / sy-cprog.

write / sy-mandt.

write / sy-dynnr.

write / sy-pagno.

Write / sy-tcode.

MODULARIZATION IN SAP ABAP

 MODULARIZATION IN SAP ABAP. 


It is a technique of  splitting larger code into smaller block of code. It is done for easy understanding, easy debugging and to decrease the code. We can achieve this in SAP using 4 concepts.

Events

Subroutines

Include programs

Function modules


SMART FORMS IN SAP ABAP

 SMART FORMS IN SAP ABAP. 

It is enhanced version to SAP scripts. Transaction code is smartforms.


First we discuss about the differences scripts and smart forms.


Scripts are client dependent but smart forms are client independent.

Scripts are not self executable i.e. print program is compulsory, but smart forms are self executable. On executing the smart form system generates function module.

We can not write the logic in scripts but we can write the logic in smart forms.

Main window is compulsory in scripts but it is optional in smart forms.

Background logo is not possible in scripts but it is possible in smart forms.

There are character and paragraph formats in scripts but there are no character and  paragraph formats in smart forms

Labels are present in scripts but no labels in smart forms.


When ever you enter into smartforms under global settings you get three things.

Form attributes

Form interface

Global definitions

FORM ATTRIBUTES:-  It gives the history and technical attributes of smart form


FORM INTERFACE: - The variables that are needed to be populated at run time should be declared here.


GLOBAL DEFINITIONS:-  The variables that are needed in the smart form should be declared here. 

  


Now we discuss about the steps in creation of smart forms.


T-code smartforms

Press create button

To create logo window right click o page create( Graphic

Give the logo name

The variables that are needed to be populated at run time should be declared under form interface

The variables that are needed to be populated at run time should be declared under Global definitions.

To write the select query or logic select the window right click create( flow logic ( program lines

It is mandatory to give input parameters and output parameters

To write loop select the code Right click create( flow logic -( loop

To write the output select  loop Right click Create ( Text

Check for errors

Activate and Execute

Function module will be generated. Execute it

Give printer name LP01 (Default Printer)

Press print preview to see output

Saturday, April 23, 2022

What is ENHANCEMENTS in SAP.

 ENHANCEMENTS in SAP ABAP. 

These are used to add extra intelligence to SAP standard programs to suit the business requirements. If we want to add extra code to SAP standard programs, if we go for change mode system asks for access key. Instead of this, SAP has provided hooks where we can write the code. These hooks are enhancement spots. If a code is written in theses spots along with the normal program the code written in these spots is also executed. There are two ways to enhance the SAP standard code.

User Exits

BADIS (Business Addins)


If user exits are used one time in any project it can not be reused. But Badis can 

be used any no of times.



There are 4 types user exits.

Function module exit

Field exit

screen exit

Menu exit


Exits are defined at package level. So we want to enhance any T-code first we 

have to find out the package for that T-code. Then we have to find out the exits present in that package. For finding the exits present in a package we have to use SMOD T-code. After finding the suitable exit for writing the code we have to use CMOD T-code.


USER EXITS I N SAP ABAP.

USER EXITS IN SAP ABAP. 

There are four types of USER EXITS

Function Module exits

Screen exits

Menu exits

Fields exits


Function Module exits:

In this we will use FUNCTION MODULE, to enhance, SAP standard program.

Screen exits:

They are used to add extra FIELDS in SAP standard screens.

Menu exits:

It is used to add extra MENU ITEMS to SAP standard screens.


Field exits:

It is used to add extra VALIDATIONS to SAP standard screen fields