Search this site

Saturday, March 31, 2012

Create index in table sap ?

-Goto SE11
-Give the table name and click on 'Indexes' and then click on Create button. Give Index ID. Specify the fields which you require to be as secondary index in the same order for that table.

Get date time in abap sap ?

SY-DATLO

User’s local date, for example 19981129, 19990628, …

SY-DATUM

Current application server date, for example 19981130, 19990627, …

SY-DAYST

X during summertime, otherwise space.

SY-FDAYW

Factory calendar day of the week: Monday = 1 … Friday = 5.

SY-TIMLO

Friday, March 30, 2012

Way to find a badi in abap sap

There are several ways to find BADIs in the program.

1. Set a beark-point in method ‘CL_EXITHANDLER=>GET_INSTANCE’. Because old BAID technology will always call this method to get the BADI instance.

2. Search string ‘CL_EXITHANDLER=>GET_INSTANCE’ in the program. This drawback of this method is that the program may call another program in the runtime. In this case, you will be able to find the BADI in another program.

3. You can also go the t-code SPRO, you can also find plenty of BADIs in the related area.

4. You can also find the BADI call using ST05. Below is the steps:

  • Go to ST05, then choose ‘table buffer trace’ and activate the trace.
  • Run the t-code from where you want to find the BADI.
  • Deactive the trace and then display trace.
  • using selection criteria object ‘V_EXT_IMP’ and ‘V_EXT_ACT’ and then you can get called BADI list.

This analyzing technique is based on the fact that all BAdIs are registrated in SAP database tables. So for each BAdI call these database tables will be accessed. The BAdI database tables are SXS_INTER, SXC_EXIT, SXC_CLASS and SXC_ATTR. These tables are always accessed by the views V_EXT_IMP and V_EXT_ACT. So these two ABAP views (T: SE11) will be the basis for the trace.

Example ALV in abap SAP

&---------------------------------------------------------------------*
*& Report Z_SCREEN_DEMO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Z_SCREEN_DEMO.


*&---------------------------------------------------------------------*
* Declare global object and selection screen.
*&---------------------------------------------------------------------*
*-----------------------------------------------------------------------
* TYPE POOL
*-----------------------------------------------------------------------
TYPE-POOLS:
SLIS.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES:MARA.
*----------------------------------------------------------------------*
* TYPES
*----------------------------------------------------------------------*
*Struct MARA
TYPES: BEGIN OF GTY_MARA,
MATNR TYPE MARA-MATNR,"MATERIAL NUMBER
MTART TYPE MARA-MTART,
END OF GTY_MARA.
*Struct MAKT
TYPES: BEGIN OF GTY_MAKT,
MATNR TYPE MAKT-MATNR,"MATERIAL NUMBER
MAKTX TYPE MAKT-MAKTX,
END OF GTY_MAKT.
*Struct OUTPUT
TYPES: BEGIN OF GTY_OUTPUT,
MATNR TYPE MARA-MATNR,"MATERIAL NUMBER
MTART TYPE MARA-MTART,"MATERIAL TYPE
MAKTX TYPE MAKT-MAKTX,"MATERIAL DES
END OF GTY_OUTPUT.
*----------------------------------------------------------------------*
* Internal table
*----------------------------------------------------------------------*
DATA: GT_OUTPUT TYPE STANDARD TABLE OF GTY_OUTPUT,
GT_MARA TYPE STANDARD TABLE OF GTY_MARA,
GT_MAKT TYPE STANDARD TABLE OF GTY_MAKT,
*----------------------------------------------------------------------*
* Work area
*----------------------------------------------------------------------*
GS_OUTPUT TYPE GTY_OUTPUT,
GS_MARA TYPE GTY_MARA,
GS_MAKT TYPE GTY_MAKT.
*----------------------------------------------------------------------*
* Selection screen
*----------------------------------------------------------------------*
SELECT-OPTIONS: S_ERDA FOR MARA-ERSDA default '20110916 ' OBLIGATORY.
PARAMETERS:
pa_lim_1 RADIOBUTTON GROUP lim ,"JOIN
pa_lim_2 RADIOBUTTON GROUP lim,"FOR ALL ENTRIES
*----------------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
*Select data
IF PA_LIM_1 IS NOT INITIAL.
*Join
SELECT
M~MATNR
M~MTART
M2~MAKTX
INTO TABLE GT_OUTPUT
FROM
MARA AS M
JOIN MAKT AS M2 ON M~MATNR = M2~MATNR
WHERE M~ERSDA IN S_ERDA AND
M2~SPRAS = 'E'.
ELSE.
*For all entries
SELECT
MATNR
MTART
FROM MARA
INTO TABLE GT_MARA
WHERE ERSDA IN S_ERDA.
DELETE ADJACENT DUPLICATES FROM GT_MARA COMPARING MATNR.
IF GT_MARA IS NOT INITIAL.
SELECT
MATNR
MAKTX
FROM MAKT
INTO TABLE GT_MAKT
FOR ALL ENTRIES IN GT_MARA
WHERE MATNR = GT_MARA-MATNR AND SPRAS = 'E'.
ENDIF.
SORT GT_MAKT BY MATNR.
LOOP AT GT_MARA INTO GS_MARA.
CLEAR: GS_MAKT.
READ TABLE GT_MAKT BINARY SEARCH WITH KEY MATNR = GS_MARA-MATNR
INTO GS_MAKT.
GS_OUTPUT-MATNR = GS_MARA-MATNR.
GS_OUTPUT-MTART = GS_MARA-MTART.
GS_OUTPUT-MAKTX = GS_MAKT-MAKTX.
APPEND GS_OUTPUT TO GT_OUTPUT.
ENDLOOP.
ENDIF.
*----------------------------------------------------------------------*
* End-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
* Output data
* ALV
data: LS_FIELDCAT type slis_fieldcat_alv.
data: GT_FIELDCAT type slis_t_fieldcat_alv.
PERFORM CREATE_FIELD_CAT.
*&---------------------------------------------------------------------*
*& Form CREATE_FIELD_CAT
*&---------------------------------------------------------------------*
* Create field catalogies
*----------------------------------------------------------------------*
FORM CREATE_FIELD_CAT .
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_internal_tabname = 'GT_OUTPUT'
i_structure_name = 'ZOUTPUT'
changing
ct_fieldcat = GT_FIELDCAT.
ENDFORM. " CREATE_FIELD_CAT
*&---------------------------------------------------------------------*
*& Form GRID_DISPLAY
*&---------------------------------------------------------------------*
* Grid Display
*----------------------------------------------------------------------*
FORM GRID_DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZSCREEN_DEMO1'
* I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'FRM_TOP_OF_PAGE'
IT_FIELDCAT = GT_FIELDCAT
I_SAVE = 'X'
* IS_VARIANT = G_VARIANT
TABLES
T_OUTTAB = GT_OUTPUT
EXCEPTIONS
PROGRAM_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.
ENDFORM. " GRID_DISPLAY
*&---------------------------------------------------------------------*
*& Form Top of page
*&---------------------------------------------------------------------*
* Top of page
*----------------------------------------------------------------------*
FORM FRM_TOP_OF_PAGE.
*ALV Header declarations
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.
* Title
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'ALV Demo'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
* Date
WA_HEADER-TYP = 'S'.
WA_HEADER-KEY = 'Date: '.
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM(4) INTO WA_HEADER-INFO. "todays date
APPEND WA_HEADER TO T_HEADER.
CLEAR: WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM.

*Output Result:

BDC example in ABAP ?

Here example of source code run BDC to update the logon language of a user from a file contains user language infomation.

Input file: input.txt
user01 FR
user02 EN

*&---------------------------------------------------------------------*
*& Report ZDEMO_UPDATE_SU01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDEMO_UPDATE_SU01.
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
TABLES: T100.
DATA: BEGIN OF ST_RECORD,
BNAME TYPE USR02-BNAME,
LANGU(2) TYPE C,
END OF ST_RECORD.
DATA: GT_UPLOAD LIKE TABLE OF ST_RECORD,
GS_UPLOAD LIKE ST_RECORD.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS P_FILE TYPE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM F4_SELECTFILE.

INITIALIZATION.

START-OF-SELECTION.
PERFORM UPLOAD_DATA.
LOOP AT GT_UPLOAD INTO GS_UPLOAD.
PERFORM BDC_DYNPRO USING 'SAPLSUU5' '0050'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'USR02-BNAME'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=CHAN'.
PERFORM BDC_FIELD USING 'USR02-BNAME'
GS_UPLOAD-BNAME.
PERFORM BDC_DYNPRO USING 'SAPLSUU5' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=DEFA'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'SZA5_D0700-TITLE_MEDI'.
PERFORM BDC_DYNPRO USING 'SAPLSUU5' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=UPD'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'USDEFAULTS-START_MENU'.
PERFORM BDC_FIELD USING 'USDEFAULTS-LANGU'
GS_UPLOAD-LANGU.
PERFORM BDC_TRANSACTION USING 'SU01'.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM UPLOAD_DATA .
DATA: L_FILE TYPE STRING.
L_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = GT_UPLOAD
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " UPLOAD_DATA
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM. "BDC_FIELD
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE 'N'
UPDATE 'S'
MESSAGES INTO MESSTAB.

LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
ELSE.
WRITE: / MESSTAB.
ENDIF.
ENDLOOP.
SKIP.
REFRESH BDCDATA.
ENDFORM. "BDC_TRANSACTION
*&---------------------------------------------------------------------*
*& Form F4_SELECTFILE
*&---------------------------------------------------------------------*
FORM F4_SELECTFILE .
CALL FUNCTION 'NAVIGATION_FILENAME_HELP'
EXPORTING
DEFAULT_PATH = 'TEST.TXT'
IMPORTING
SELECTED_FILENAME = P_FILE.
MOVE P_FILE TO P_FILE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " F4_SELECTFILE

What is BDC in ABAP SAP ?

The full form of BDC is Batch Data Communication. It’s a technique in SAP used for mass input of data or uploading data into SAP system (If particular BAPI is not available).BDC also known as Batch Input. There are two types of BDC are there

  • Call Transaction Using (using CALL TRANSACTION statement)
  • Batch Input Session (using BDC_OPEN_GROUP, BDC_INSERT and BDC_CLOSE_GROUP function modules)

ABAP programming is requires for any BDC methods. First we need to record a transaction and then embed this recording in our ABAP program. Then we will run this using Call Transaction using or BI session method.

CALL TRANSACTION USING:

This is the fastest method to transfer data.

Syntax:

CALL TRANSACTION

USING

MODE

UPDATE

Main Display Modes used

A: Display all

E: Display Errors only

N : No Display

Main Updates modes

S: Synchronous

A: Asynchronous

L : Local Update

While we doing CALL TRANSACTION USING method, first we will create a structure BDCDATA for the transaction. This structure is used in the USING addition of the CALL TRANSACTION statement.

Batch Input Session

In this method data is stored in a batch input session and later run this session. Here is the process flow of BI session method.

  • Use BDC_OPEN_GROUP function module to create a BI session.
  • BDCDATA structure, enter the value for all screens and fields that must be processed in the transaction
  • Use BDC INSERT function module to transfer the transaction and the BDCDATA structure to the session
  • Use BDC_CLOSE_GROUP function module to close the batch input session.

Now this session will be in a batch input queue and we need to process it. The session processing can be two types

  • Manually using the batch input menu options (SM35 transaction).
  • Use RSBDCSUB program to run the session in background.

BDC

  1. What is BDC in ABAP SAP ?
  2. BDC example in ABAP ?

Tuesday, March 27, 2012

List processing example

*&---------------------------------------------------------------------*
*& Report Z_LIST_PROCESSING
*&
*&---------------------------------------------------------------------*

REPORT Z_LIST_PROCESSING .

*&---------------------------------------------------------------------*
* Declare global object and selection screen.
*&---------------------------------------------------------------------*
*-----------------------------------------------------------------------
* TYPE POOL
*-----------------------------------------------------------------------
TYPE-POOLS:
SLIS.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES:MARA.
*----------------------------------------------------------------------*
* TYPES
*----------------------------------------------------------------------*
*Struct MARA
TYPES: BEGIN OF GTY_MARA,
MATNR TYPE MARA-MATNR,"MATERIAL NUMBER
MTART TYPE MARA-MTART,
END OF GTY_MARA.
*Struct MAKT
TYPES: BEGIN OF GTY_MAKT,
MATNR TYPE MAKT-MATNR,"MATERIAL NUMBER
MAKTX TYPE MAKT-MAKTX,
END OF GTY_MAKT.
*Struct OUTPUT
TYPES: BEGIN OF GTY_OUTPUT,
MATNR TYPE MARA-MATNR,"MATERIAL NUMBER
MTART TYPE MARA-MTART,"MATERIAL TYPE
MAKTX TYPE MAKT-MAKTX,"MATERIAL DES
END OF GTY_OUTPUT.
*----------------------------------------------------------------------*
* Internal table
*----------------------------------------------------------------------*
DATA: GT_OUTPUT TYPE STANDARD TABLE OF GTY_OUTPUT,
GT_MARA TYPE STANDARD TABLE OF GTY_MARA,
GT_MAKT TYPE STANDARD TABLE OF GTY_MAKT,
*----------------------------------------------------------------------*
* Work area
*----------------------------------------------------------------------*
GS_OUTPUT TYPE GTY_OUTPUT,
GS_MARA TYPE GTY_MARA,
GS_MAKT TYPE GTY_MAKT.
*----------------------------------------------------------------------*
* Selection screen
*----------------------------------------------------------------------*
SELECT-OPTIONS: S_ERDA FOR MARA-ERSDA default '20111017 ' OBLIGATORY.
PARAMETERS:
pa_lim_1 RADIOBUTTON GROUP lim ,"JOIN
pa_lim_2 RADIOBUTTON GROUP lim,"FOR ALL ENTRIES
*----------------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
*Select data
IF PA_LIM_1 IS NOT INITIAL.
*Join
SELECT
M~MATNR
M~MTART
M2~MAKTX
INTO TABLE GT_OUTPUT
FROM
MARA AS M
JOIN MAKT AS M2 ON M~MATNR = M2~MATNR
WHERE M~ERSDA IN S_ERDA AND
M2~SPRAS = 'E'.
ELSE.
*For all entries
SELECT
MATNR
MTART
FROM MARA
INTO TABLE GT_MARA
WHERE ERSDA IN S_ERDA.
DELETE ADJACENT DUPLICATES FROM GT_MARA COMPARING MATNR.
IF GT_MARA IS NOT INITIAL.
SELECT
MATNR
MAKTX
FROM MAKT
INTO TABLE GT_MAKT
FOR ALL ENTRIES IN GT_MARA
WHERE MATNR = GT_MARA-MATNR AND SPRAS = 'E'.
ENDIF.
SORT GT_MAKT BY MATNR.
LOOP AT GT_MARA INTO GS_MARA.
CLEAR: GS_MAKT.
READ TABLE GT_MAKT BINARY SEARCH WITH KEY MATNR = GS_MARA-MATNR
INTO GS_MAKT.
GS_OUTPUT-MATNR = GS_MARA-MATNR.
GS_OUTPUT-MTART = GS_MARA-MTART.
GS_OUTPUT-MAKTX = GS_MAKT-MAKTX.
APPEND GS_OUTPUT TO GT_OUTPUT.
ENDLOOP.
ENDIF.
*----------------------------------------------------------------------*
* End-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
* Output data

LIST PROCESSING

* Struct
TYPES: BEGIN OF GTY_OUTPUT1,
MTART TYPE MARA-MTART,"MATERIAL TYPE
MATNR TYPE MARA-MATNR,"MATERIAL NUMBER
MAKTX TYPE MAKT-MAKTX,"MATERIAL DES
END OF GTY_OUTPUT1.
DATA: GT_OUTPUT1 TYPE STANDARD TABLE OF GTY_OUTPUT1,
GS_OUTPUT1 TYPE GTY_OUTPUT1.
LOOP AT GT_OUTPUT INTO GS_OUTPUT.
GS_OUTPUT1-MTART = GS_OUTPUT-MTART.
GS_OUTPUT1-MATNR = GS_OUTPUT-MATNR.
GS_OUTPUT1-MAKTX = GS_OUTPUT-MAKTX.
APPEND GS_OUTPUT1 TO GT_OUTPUT1.
ENDLOOP.

SORT GT_OUTPUT1 BY MTART MATNR.
LOOP AT GT_OUTPUT1 INTO GS_OUTPUT1.
AT FIRST.
WRITE: / 'AT FIRST'.
ENDAT.
AT NEW MTART.
WRITE: /.
WRITE: /10(15) 'MATERIAL TYPE:'.
WRITE: 26(10) GS_OUTPUT1-MTART.
WRITE: /1(15) 'Material number'.
WRITE: 17(20) 'Material description'.
ENDAT.
WRITE: /1(10) GS_OUTPUT1-MATNR.
WRITE: 17(20) GS_OUTPUT1-MAKTX.
AT END OF MTART.
WRITE: /.
ULINE 10(30).
ENDAT.
AT LAST.
WRITE: / 'AT last'.
ENDAT.
ENDLOOP.
ENDIF.

Selection screen:
Here's the output:

Sap grid control




DATA:
obj_Custom TYPE REF TO cl_gui_custom_container,
obj_alvGrid TYPE REF TO cl_gui_alv_grid.
*PBO
CREATE OBJECT obj_Custom
EXPORTING CONTAINER_NAME ‘GridName’.

CREATE OBJECT obj_alvGrid
EXPORTING I_PARENT = obj_Custom.
*Insert data into internal table
………………….
*Display
obj_AlvGrid->SET_TABLE_FOR_FIRST_DISPLAY( EXPORTING
I_STRUCTURE_NAME = ‘StructureName'
CHANGING IT_OUTTAB = InternalTable ).




Data Formatting and Control Level Processing

LOOP AT itab INTO ….
AT FIRST.
ENDAT.
AT NEW .
ENDAT.
AT END OF
ENDAT.
AT LAST.
ENDAT.
ENDLOOP.

Programming Data Retrieval

Programming Data Retrieval

INNER JOIN
OUTTER JOIN
FOR ALL ENTRIES
SELECT carrid connid fldate…
INTO TABLE itab_splight FROM SFLIGHT
FOR ALL ENTRIES IN itab_spfli
WHERE


Selection Screen

a)Generate

PARAMETERS:
[TYPE ] [DECIMALS ] [LIKE ] [MEMORY ID ]
[OBLIGATORY] [DEFAULT ] [LOWER CASE]
[VALUE CHECK]
[AS CHECKBOX]
[RADIOBUTTON GROUP ]

Selection-options
SELECT-OPTIONS: FOR
DEFAULT VALUE
DEFAULT TO
MEMORY ID
LOWER CASE
OBLIGATORY
NO-EXTENSION
NO INTERVALS
b)Design Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK
WITH FRAME [TITLE ]

PARAMETERS :
NAME LIKE BKPF-BUKRS,
Rad1 RADIOBUTTON GROUP G1,
Rad2 RADIOBUTTON GROUP G1.

SELECT-OPTIONS:
CpCode FOR BKPF-BUKRS NO INTERVALS.

SELECTION-SCREEN END OF BLOCK

SELECTION-SCREEN BEGIN OF LINE
COMMENT Pos(len) [FOR FIELD ]
POSITION pos
SELECTION-SCREEN END OF LINE

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 10(10) Text-001.
PARAMETER : Name(10) TYPE c.
SELECTION-SCREEN COMMENT 40(10) Text-002 FOR FIELD Check.
PARAMETER : Check AS CHECKBOX.

SELECTION-SCREEN END OF LINE.


Outputting Data in Lists

a)Simple list

Example:

Output:


b)List formats
REPORT LINE-SIZE LINE-COUNT
LINE-SIZE LINE-COUNT
TOP-OF-PAGE event : generate page headersExample:

Ouput


WRITE [AT] [/] ...
-Option:
NO-ZERO.
CURRENCY .
UNIT .
USING EDIT MARK .
UNDER .
LEFT-JUSTIFIED.
CENTERED.
RIGHT-JUSTIFIED.

SY-ULINE
Contains a horizontal line with length 255 that you can use when creating lists.
SY-VLINE
Contains a vertical line (|) that you can use when creating lists.
NO-ZERO If the contents of field are equal to zero, only spaces are
output.
CURRENCY Formats currency fields based on rules defined in table TCURX.
UNIT Formats quantity fields based on rules defined in table T0006.
USING EDIT MASK Outputs according to the formatting template.
UNDER The output begins at the column in which field was output.
LEFT-JUSTIFIED Left-justified output (default for types C, N, D, T, X).
CENTERED Centered output within the output length.
RIGHT-JUSTIFIED Right-justified output (standard for all number fields: I, P and F)













Techniques of List Processing

  1. Outputting Data in Lists
  2. Selection Screen
  3. Programming Data Retrieval
  4. Data Formatting and Control Level Processing
  5. Basic Techniques in Interactive Lists
  6. SAP Grid Control
  7. List processing example

Workflow

  1. What is workflow ?
  2. Abap workflow tcodes ?
  3. Abap workflow tutorial ?
  4. Abap workflow interview questions?
  5. Abap workflow example ,how to create workflow ?

Workflow

  1. What is workflow ?

What is workflow ?

SAP Workflow is a tool to automate complex business processes where there is more than one user involved. SAP workflow maps the position in organization because SAP believes that Positions are more stable than the people.

SAP Workflow is a process tool that is designed to facilitate and automate business processes involving the tasks sequence performed by the users (people in the workplace) and ensure that the right work is assigned in the right sequence at the right time to the right person in the workflow. The SAP workflow can be linked to other software tools such as Microsoft Outlook or Lotus Notes. Using SAP Workflow, each step of a business transaction can be easily monitored throughout the initiation and completion of the business processes. The SAP Workflow enables the process owners to track deadlines, determine the workload as well as provide statistics on the length of time to complete work processes.

The key components of the SAP Workflow include the Workflow Definition, Work Items, Events triggers and the Organizational Structure in the workplace.

Monday, March 26, 2012

Logical database

  1. What is logical database ?
  2. Abap logical database example
  3. Abap logical database selection screen
  4. Abap logical database PCH
  5. Abap logical database PNP
  6. Abap logical database transaction

What is 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.

Disadvantages:
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).

Sunday, March 25, 2012

BADI

  1. What is BADI ?
  2. Way to find a badi in abap sap?
  3. Abap BADI tutorial
  4. Abap BADI example
  5. Abap badi interview questions
  6. Abap badi transaction
  7. Abap badi error handling

What is BADI ?

Business Add-Ins, or BADIs, are software extensions to products developed and sold by worldwide software firm SAP. BADI provides custom enhancements to SAP software that help it meet specific SAP customer and business needs; for example, modifications to timesheets and field entries in human resources software


ALV

  1. What is ALV ?
  2. Example ALV in abap SAP ?

What is ALV ?

The ALV is used mostly used as a report output for Tabular and Hierarchical display. ALV has rich set of standard functions like sorting, filtering, aggregation. The ALV programming has undergone lots of changes in couple of years. Initially the ALV display is done using function modules. Then the concept of OO class is introduced in Version 4.6C. In this blog, we will look at the old and new methods of calling an ALV.
Example:


Step to Create SAP Query

1. Create User Group (SQ03)

Specify the users who should be authorized to run the query.

2. Create Infoset (SQ02)

Indicates from which part of the SAP database the data is going to be retrieved and how the data is to be retrieved by the query.

3. Create Queries (SQ01)
Create the query and arrange the layout. Report type and the Graphical Query Painter:
Basic List – Simple Reports
Statistics – Reports with statistical functions such Avg, %.
Ranked List – Analytical Reports

Components of SAP query

The SAP Query comprises five components:

Ø Queries
Ø InfoSet Query
Ø InfoSets
Ø User Groups
Ø Translation/Query


· InfoSets - InfoSets determine to which tables, or field within a table, a query can refer. InfoSets are usually based on table joins or logical databases.These should be created with sharability in mind.

· User Groups -The user group allows you to to specify the users who are authorized to run and/or create/change queries under that user group.

· Queries - Formatting the data identified in the InfoSet to

create the desired report.