Tuesday, January 22, 2008

Converting CSV seperated by comma

Converting csv separated by ','

REPORT ZTEST.

TYPE-POOLS:TRUXS.

DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.

DATA: ITABT LIKE ITAB OCCURS 0 WITH HEADER LINE.

DATA: ITAB1 TYPE TRUXS_T_TEXT_DATA,
ITAB2 TYPE TRUXS_T_TEXT_DATA.

SELECT VBELN POSNR
UP TO 100 ROWS
FROM VBAP
INTO TABLE ITAB.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ','
TABLES
I_TAB_SAP_DATA = ITAB
CHANGING
I_TAB_CONVERTED_DATA = ITAB1
EXCEPTIONS
CONVERSION_FAILED = 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.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\TEMP\TEST.TXT'
TABLES
DATA_TAB = ITAB1
EXCEPTIONS
OTHERS = 1.

CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = ','
I_TAB_RAW_DATA = ITAB1
* I_FILENAME = 'C:\TEMP\TEST.TXT'
TABLES
I_TAB_CONVERTED_DATA = ITABT
EXCEPTIONS
CONVERSION_FAILED = 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.

Wednesday, January 16, 2008

Sample Code Using Field-Groups

A Note on the Use of Field Groups...

Because field-groups write their data to paging space (rather than storing it in memory), they are appropriate only for processing lists with lots (like 50,000 or more) of records. If you expect your programs to be handling tens of thousands of records, you should:

* analyze the expected size of your lists. For instance, if your system has 512M of main memory, you may decide that you don't want any report to use more than 15M of memory for its lists. In that program, you may have a list:

begin of mylist occurs XXX,

dat1(100) type c,

dat2(50) type c,

dat3(10) type c,

end of list.

Then each record takes up approximately 160 bytes; so every 6 records take up approximately 1K. For this list structure, it would take about 90,000 records to use up 15M RAM.
* decide the maximum amount of memory you want your program to use
* decide whether to use field-groups or something else (like internal tables).

If you expect the size of your list to be greater than the amount of memory you want your program to use, then use field-groups (actually, if you use internal tables, and the number of records exceeds the number of records in your OCCURS statement, the system just writes those extra records to the paging space. So is there really any difference between just using an internal table with an OCCURS 0 statement-- which would write the entire table to paging space-- and using field-groups? According to Gareth M. de Bruyn and Robert Lyfareff in Introduction to ABAP/4 Programming for SAP, field-groups are stored more efficiently, and have better performance. They recommend field-groups for lists of 100,000 or more records).

Field groups are groups similar fields together into one name. Field group works in conjuction with INSERT,EXTRACT,SORT,LOOP and ENDLOOP.

Field-Groups Sample Code

*&---------------------------------------------------------------------*
*& Report ZSPFLI *
*& *
*&---------------------------------------------------------------------*

REPORT ZSPFLI LINE-SIZE 132 LINE-COUNT 65(3)
NO STANDARD PAGE HEADING.
TABLES:SPFLI,SCARR, SFLIGHT, SBOOK.
SELECT-OPTIONS: MYCARRID FOR SPFLI-CARRID.

FIELD-GROUPS: HEADER, SPFLI_FG, SFLIGHT_FG, SBOOK_FG.

*------------------------------------------------------------------------------------
*The insert statement is used to create a field group dynamically by inserting the *field into it. Only global data fields can be inserted and not local data fields eg *: in form modules.
*------------------------------------------------------------------------------------

INSERT:
SPFLI-CARRID
SPFLI-CONNID
SFLIGHT-FLDATE
SBOOK-BOOKID
INTO HEADER,

SPFLI-CARRID
SPFLI-CONNID
SPFLI-CITYFROM
SPFLI-AIRPFROM
SPFLI-CITYTO
SPFLI-AIRPTO
SPFLI-DEPTIME
SCARR-CARRNAME
INTO SPFLI_FG,

SFLIGHT-FLDATE
SFLIGHT-SEATSMAX
SFLIGHT-SEATSOCC
SFLIGHT-PRICE
INTO SFLIGHT_FG,

SBOOK-BOOKID
SBOOK-CUSTOMID
SBOOK-CUSTTYPE
SBOOK-SMOKER
INTO SBOOK_FG.

*------------------------------------------------------------------------------------
*EXTRACT SPFLI_FG
*This will combine all the fields in the fieldgroup and write them to a sequential *dataset as a single record.
*------------------------------------------------------------------------------------

SELECT * FROM SPFLI WHERE CARRID IN MYCARRID.
SELECT SINGLE * FROM SCARR WHERE CARRID = SPFLI-CARRID.
EXTRACT SPFLI_FG.

SELECT * FROM SFLIGHT
WHERE CARRID = SPFLI-CARRID AND CONNID = SPFLI-CONNID.
EXTRACT SFLIGHT_FG.

SELECT * FROM SBOOK
WHERE CARRID = SFLIGHT-CARRID AND
CONNID = SFLIGHT-CONNID AND FLDATE = SFLIGHT-FLDATE.
EXTRACT SBOOK_FG.
CLEAR SBOOK.
ENDSELECT.
CLEAR SFLIGHT.
ENDSELECT.
CLEAR SPFLI.
ENDSELECT.

*------------------------------------------------------------------------------------
*SORT
*Sorting of sequential dataset by field group
*------------------------------------------------------------------------------------
SORT.
LOOP.
AT SPFLI_FG.
FORMAT COLOR COL_HEADING.
WRITE: / SCARR-CARRNAME,
SPFLI-CONNID, SPFLI-CITYFROM,
SPFLI-AIRPFROM, SPFLI-CITYTO, SPFLI-AIRPTO, SPFLI-DEPTIME.
FORMAT COLOR OFF.
ENDAT.

AT SFLIGHT_FG.
WRITE: /15 SFLIGHT-FLDATE, SFLIGHT-PRICE, SFLIGHT-SEATSMAX,
SFLIGHT-SEATSOCC.
ENDAT.

AT SBOOK_FG.
WRITE: /30 SBOOK-BOOKID, SBOOK-CUSTOMID,
SBOOK-CUSTTYPE, SBOOK-SMOKER.
ENDAT.
ENDLOOP.

*&---------------------------------------------------------------------*
*& END OF REPORT *
*&---------------------------------------------------------------------*

Program to Generate Graphs

*&---------------------------------------------------------------------*
*& Report Z_GRAPHS
*&---------------------------------------------------------------------*
*& This program demonstrates how easy it is to generate 3D or 2D graphs,
*& simply by populating the statistical data into an internal table and
*& passing it to a Function Module.
*&
*& The Example has no imput parameters, but they can be added based on
*& the requirement
*&---------------------------------------------------------------------*
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT Z_GRAPHS.

*----------------------------------------------------------------------*
*INTERNAL TABLES AND STRUCTURES
*----------------------------------------------------------------------*
*** Internal table to hold Statistical data
DATA:
BEGIN OF IT_DATA OCCURS 0,
DATANAME(15),
QUANTITY1 TYPE I,
QUANTITY2 TYPE I,
QUANTITY3 TYPE I,
END OF IT_DATA.

*** Internal table to hold Options
DATA:
BEGIN OF IT_OPTIONS OCCURS 0,
OPTION(20),
END OF IT_OPTIONS.

*----------------------------------------------------------------------*
* Populating statistics data
IT_DATA-DATANAME = 'India'.
IT_DATA-QUANTITY1 = 55.
IT_DATA-QUANTITY2 = 62.
IT_DATA-QUANTITY3 = 59.
APPEND IT_DATA.

IT_DATA-DATANAME = 'UK'.
IT_DATA-QUANTITY1 = 35.
IT_DATA-QUANTITY2 = 80.
IT_DATA-QUANTITY3 = 44.
APPEND IT_DATA.

IT_DATA-DATANAME = 'USA'.
IT_DATA-QUANTITY1 = 18.
IT_DATA-QUANTITY2 = 80.
IT_DATA-QUANTITY3 = 19.
APPEND IT_DATA.

* Call FM to generate graph for the stats
CALL FUNCTION 'GRAPH_MATRIX_3D'
EXPORTING
COL1 = 'IT Professionals'
COL2 = 'Doctors'
COL3 = 'Engineers'
TITL = 'Professional Statistics'
TABLES
DATA = IT_DATA
OPTS = IT_OPTIONS
EXCEPTIONS
OTHERS = 1.

Thursday, January 10, 2008

Hierarchical ALV list

REPORT Z_FI_RP_PROFIT_CENTER_DOCS NO STANDARD PAGE HEADING
MESSAGE-ID ZMSGCLASS.
************************************************************************
* Program Name : Z_FI_RP_PROFIT_CENTER_DOCS *
* Development class : ZDEVELOPMENT *
* Description : This program displays the Accounting documents *
* and their corresponding line items based on the *
* posting keys. *
* 1. Accouting Document *
* 2. Company code *
* 3. Fiscal Year *
* 4. Document date *
* 5. Posting date *
* 6. User name *
************************************************************************
*----------------------------------------------------------------------*
* Request No. Created Date Developer name
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
* TYPE-POOLS *
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS. " ALV Global types

*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
TABLES: BKPF,
FAGLFLEXA.

*---------------------------------------------------------------------*
* DATA DECLARATIONS *
*---------------------------------------------------------------------*
DATA:LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LS_KEYINFO TYPE SLIS_KEYINFO_ALV,
LS_SORT TYPE SLIS_SORTINFO_ALV,
LT_SORT TYPE SLIS_T_SORTINFO_ALV,
LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
S_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
FCAT TYPE SLIS_T_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV,
EVENT TYPE SLIS_T_EVENT WITH HEADER LINE,
HEAD TYPE SLIS_T_LISTHEADER WITH HEADER LINE,
ITEM TYPE SLIS_T_LISTHEADER WITH HEADER LINE,
SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
*---------------------------------------------------------------------*
* CONSTANTS *
*---------------------------------------------------------------------*
CONSTANTS :C_X TYPE C VALUE 'X',
C_IT_HEAD TYPE SLIS_TABNAME VALUE 'IT_HEAD',
C_IT_ITEM TYPE SLIS_TABNAME VALUE 'IT_ITEM',
C_K TYPE C VALUE 'K',
C_D TYPE C VALUE 'D',
C_BLN(03) TYPE C VALUE 'BLN',
C_BUK(03) TYPE C VALUE 'BUK',
C_GJR(03) TYPE C VALUE 'GJR',
C_FB03(04) TYPE C VALUE 'FB03'.
*--- Constant for FORM TOP_OF_PAGE
CONSTANTS:GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

*---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*---------------------------------------------------------------------*
*--- Internal table declaration to hold the Accounting Document Header data
DATA: BEGIN OF IT_BKPF OCCURS 0,
BUKRS LIKE BKPF-BUKRS, " Company Code
BELNR LIKE BKPF-BELNR, " Accounting Document Number
GJAHR LIKE BKPF-GJAHR, " Fiscal Year
BLDAT LIKE BKPF-BLDAT, " Document Date in Document
BUDAT LIKE BKPF-BUDAT, " Posting Date in the Document
CPUDT LIKE BKPF-CPUDT, " Day On Which Accounting Document Was Entered
USNAM LIKE BKPF-USNAM, " User Name
END OF IT_BKPF.
*--- Internal table declaration to hold the General Ledger: Actual Line Items
DATA: BEGIN OF IT_FAGLFLEXA OCCURS 0,
DOCNR LIKE FAGLFLEXA-DOCNR, " Accounting Document Number
BUDAT LIKE FAGLFLEXA-BUDAT, " Posting Date in the Document
RYEAR LIKE FAGLFLEXA-RYEAR, " Fiscal Year
RBUKRS LIKE FAGLFLEXA-RBUKRS, " Company Code
PRCTR LIKE FAGLFLEXA-PRCTR, " Profit Center
BUZEI LIKE FAGLFLEXA-BUZEI, " Line Item No.
TSL LIKE FAGLFLEXA-TSL, " Value in Transaction Currency
HSL LIKE FAGLFLEXA-HSL, " Value in Local Currency
DRCRK LIKE FAGLFLEXA-DRCRK, " Debit/Credit Indicator
BSCHL LIKE FAGLFLEXA-BSCHL, " Posting Key
RMVCT LIKE FAGLFLEXA-RMVCT, " Transaction Type
RTCUR LIKE FAGLFLEXA-RTCUR, " Currency Key
RCNTR LIKE FAGLFLEXA-RCNTR, " Cost Center
KOKRS LIKE FAGLFLEXA-KOKRS, " Controlling Ara
SEGMENT LIKE FAGLFLEXA-SEGMENT, " Segment
RASSC LIKE FAGLFLEXA-RASSC, " Company ID of trading partner
POPER LIKE FAGLFLEXA-POPER, " Posting Period
BSTAT LIKE FAGLFLEXA-BSTAT, " Document Status
USNAM LIKE FAGLFLEXA-USNAM, " Username
END OF IT_FAGLFLEXA.
*--- Internal table declaration to hold the Posting Keys
DATA: BEGIN OF IT_TBSL OCCURS 0,
BSCHL LIKE TBSL-BSCHL, " Posting Key
KOART LIKE TBSL-KOART, " Account Type
END OF IT_TBSL.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors
DATA: BEGIN OF IT_BSIK OCCURS 0,
BUKRS LIKE BSIK-BUKRS, " Company Code
LIFNR LIKE BSIK-LIFNR, " Vendor
UMSKZ LIKE BSIK-UMSKZ, " Special G/L Indicator
GJAHR LIKE BSIK-GJAHR, " Fiscal Year
BELNR LIKE BSIK-BELNR, " Accounting Document
BUZEI LIKE BSIK-BUZEI, " Line Item
END OF IT_BSIK.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors (Cleared Items)
DATA: BEGIN OF IT_BSAK OCCURS 0,
BUKRS LIKE BSAK-BUKRS, " Company Code
LIFNR LIKE BSAK-LIFNR, " Vendor
UMSKZ LIKE BSAK-UMSKZ, " Special G/L Indicator
GJAHR LIKE BSAK-GJAHR, " Fiscal Year
BELNR LIKE BSAK-BELNR, " Accounting Document
BUZEI LIKE BSAK-BUZEI, " Line Item
END OF IT_BSAK.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers
DATA: BEGIN OF IT_BSID OCCURS 0,
BUKRS LIKE BSID-BUKRS, " Company Code
KUNNR LIKE BSID-KUNNR, " Customer Number
UMSKZ LIKE BSID-UMSKZ, " Special G/L Indicator
GJAHR LIKE BSID-GJAHR, " Fiscal Year
BELNR LIKE BSID-BELNR, " Accounting Document
BUZEI LIKE BSID-BUZEI, " Line Item
END OF IT_BSID.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers (Cleared Items)
DATA: BEGIN OF IT_BSAD OCCURS 0,
BUKRS LIKE BSAD-BUKRS, " Company Code
KUNNR LIKE BSAD-KUNNR, " Customer Number
UMSKZ LIKE BSAD-UMSKZ, " Special G/L Indicator
GJAHR LIKE BSAD-GJAHR, " Fiscal Year
BELNR LIKE BSAD-BELNR, " Accounting Document
BUZEI LIKE BSAD-BUZEI, " Line Item
END OF IT_BSAD.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts
DATA: BEGIN OF IT_BSIS OCCURS 0,
BUKRS LIKE BSIS-BUKRS, " Company Code
HKONT LIKE BSIS-HKONT, " GL Account
GJAHR LIKE BSIS-GJAHR, " Fiscal Year
BELNR LIKE BSIS-BELNR, " Accounting Document
BUZEI LIKE BSIS-BUZEI, " Line Item
END OF IT_BSIS.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts (Cleared Items)
DATA: BEGIN OF IT_BSAS OCCURS 0,
BUKRS LIKE BSAS-BUKRS, " Company Code
HKONT LIKE BSAS-HKONT, " GL Account
GJAHR LIKE BSAS-GJAHR, " Fiscal Year
BELNR LIKE BSAS-BELNR, " Accounting Document
BUZEI LIKE BSAS-BUZEI, " Line Item
END OF IT_BSAS.
*--- Internal table to hold the Header data
DATA: BEGIN OF IT_HEAD OCCURS 0,
BUKRS LIKE BKPF-BUKRS, " Company Code
BELNR LIKE BKPF-BELNR, " Accounting Document
GJAHR LIKE BKPF-GJAHR, " Fiscal Year
BLDAT LIKE BKPF-BLDAT, " Document Date
BUDAT LIKE BKPF-BUDAT, " Posting date
CPUDT LIKE BKPF-CPUDT, " Entry Date
USNAM LIKE BKPF-USNAM, " User name
END OF IT_HEAD.
*--- Internal table to hold the Item data
DATA: BEGIN OF IT_ITEM OCCURS 0.
INCLUDE STRUCTURE IT_FAGLFLEXA.
DATA: LIFNR LIKE BSIK-LIFNR, " Vendor
UMSKZ LIKE BSIK-UMSKZ, " Special GL Indicator
KUNNR LIKE BSID-KUNNR, " Customer
HKONT LIKE BSIS-HKONT, " GL Account
ACCNT_NAME LIKE SKAT-TXT50, " GL Account Name
END OF IT_ITEM.
*--- Internal table to hold Vendor descriptions
DATA: BEGIN OF IT_LFA1 OCCURS 0,
LIFNR LIKE LFA1-LIFNR, " Vendor NUmber
NAME1 LIKE LFA1-NAME1, " Vendor Name
END OF IT_LFA1.
*--- Internal table to hold Customer descriptions
DATA: BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR, " Customer Number
NAME1 LIKE KNA1-NAME1, " Customer Name
END OF IT_KNA1.
*--- Internal table to hold GL descriptions
DATA: BEGIN OF IT_SKAT OCCURS 0,
SAKNR LIKE SKAT-SAKNR, " GL Account Number
TXT50 LIKE SKAT-TXT50, " GL Account Name
END OF IT_SKAT.

*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCLSCR1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_BUKRS FOR BKPF-BUKRS OBLIGATORY NO-EXTENSION, " Company Code
S_BELNR FOR BKPF-BELNR, " Accounting Document Number
S_GJAHR FOR BKPF-GJAHR OBLIGATORY NO-EXTENSION, " Fiscal Year
S_BLART FOR BKPF-BLART, " Document Type
S_BLDAT FOR BKPF-BLDAT, " Document Date in Document
S_BUDAT FOR BKPF-BUDAT, " Posting Date in the Document
S_CPUDT FOR BKPF-CPUDT, " Accounting Document Entry Date
S_USNAM FOR BKPF-USNAM NO-EXTENSION, " User Name
S_PRCTR FOR FAGLFLEXA-PRCTR OBLIGATORY. " Profit Center
SELECTION-SCREEN END OF BLOCK SCLSCR1.

*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_BUKRS.
*--- Perform to validate Company code
PERFORM VALIDATE_BUKRS.

AT SELECTION-SCREEN ON S_BELNR.
*--- Perform to validate Accounting Document Number
PERFORM VALIDATE_BELNR.

AT SELECTION-SCREEN ON S_GJAHR.
*--- Perform to validate Fiscal Year
PERFORM VALIDATE_GJAHR.

AT SELECTION-SCREEN ON S_BLART.
*--- Perform to validate Document Type
PERFORM VALIDATE_BLART.

AT SELECTION-SCREEN ON S_USNAM.
*--- Perform to validate User Name
PERFORM VALIDATE_USNAM.

AT SELECTION-SCREEN ON S_PRCTR.
*--- Perform to validate User Name
PERFORM VALIDATE_PRCTR.

*---------------------------------------------------------------------*
* TOP-OF-PAGE *
*---------------------------------------------------------------------*
TOP-OF-PAGE.

*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.

*--- Perform to get the Accounting Document Header data
PERFORM GET_BKPF_DATA.
*--- Perform to get the General Ledger: Actual Line Items
PERFORM GET_FAGLFLEXA_DATA.
*--- Perform to get the Posting Keys
PERFORM GET_TBSL_DATA.
*--- Perform to get the Account Information based on Posting key
PERFORM GET_ACCOUNT_INFO.
*--- Perform to get the Vendor Descriptions
PERFORM GET_LFA1_DATA.
*--- Perform to get the Customer Descriptions
PERFORM GET_KNA1_DATA.
*--- Perform to get the GL Descriptions
PERFORM GET_SKAT_DATA.

*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*--- Perform to get the Output data
PERFORM GET_OUTPUT.
*--- Perform to Build the fieldcat to display the output in ALV format
PERFORM BUILD_FIELDCAT_ALV.
*--- Perform to display the Hierarchial ALV List
PERFORM DISPLAY_ALV_OUTPUT.

*&---------------------------------------------------------------------*
*& Form GET_BKPF_DATA
*&---------------------------------------------------------------------*
* To get the Accounting Document Header data
*----------------------------------------------------------------------*
FORM GET_BKPF_DATA.

*--- Select construct to get the Accounting Document Header data
SELECT BUKRS BELNR GJAHR BLDAT BUDAT CPUDT USNAM
FROM BKPF
INTO TABLE IT_BKPF
WHERE BUKRS IN S_BUKRS
AND BELNR IN S_BELNR
AND GJAHR IN S_GJAHR
AND BLART IN S_BLART
AND BLDAT IN S_BLDAT
AND BUDAT IN S_BUDAT
AND CPUDT IN S_CPUDT
AND USNAM IN S_USNAM.
IF SY-SUBRC = 0.
*--- Sort table IT_BKPF by Accounting document
SORT IT_BKPF BY BELNR.
ELSE.
*--- Display message if an invalid Profit Center is entered
MESSAGE S002(ZMSGCLASS)
WITH 'No data exists for the selection criteria'.
ENDIF.


ENDFORM. " GET_BKPF_DATA
*&---------------------------------------------------------------------*
*& Form GET_FAGLFLEXA_DATA
*&---------------------------------------------------------------------*
* To get the General Ledger: Actual Line Items
*----------------------------------------------------------------------*
FORM GET_FAGLFLEXA_DATA .

IF NOT IT_BKPF[] IS INITIAL.
*--- Select construct to get the General Ledger: Actual Line Items
SELECT DOCNR " Document NUmber
BUDAT " Posting Date
RYEAR " Fiscal Year
RBUKRS " Company code
PRCTR " Profit center
BUZEI " Line Item
TSL " Value in Transaction Currency
HSL " Value in Local Currency
DRCRK " Debit/Credit Indicator
BSCHL " Posting Key
RMVCT " Transaction Type
RTCUR " Currency Key
RCNTR " Cost Center
KOKRS " Controlling Area
SEGMENT " Segment for Segmental Reporting
RASSC " Company ID of trading partner
POPER " Posting period
BSTAT " Document status
USNAM " User name
FROM FAGLFLEXA
INTO TABLE IT_FAGLFLEXA
FOR ALL ENTRIES IN IT_BKPF
WHERE RYEAR = IT_BKPF-GJAHR
AND DOCNR = IT_BKPF-BELNR
AND RBUKRS = IT_BKPF-BUKRS
AND PRCTR IN S_PRCTR.
IF SY-SUBRC = 0.
*--- Sort table IT_FAGLFLEXA by Document number
SORT IT_FAGLFLEXA BY DOCNR.
ENDIF.

ENDIF.

ENDFORM. " GET_FAGLFLEXA_DATA

*&---------------------------------------------------------------------*
*& Form GET_TBSL_DATA
*&---------------------------------------------------------------------*
* To get the Posting Keys
*----------------------------------------------------------------------*
FORM GET_TBSL_DATA.

IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Posting keys
SELECT BSCHL KOART
FROM TBSL
INTO TABLE IT_TBSL
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BSCHL = IT_FAGLFLEXA-BSCHL.
IF SY-SUBRC = 0.
ENDIF.

ENDIF.

ENDFORM. " GET_TBSL_DATA
*&---------------------------------------------------------------------*
*& Form GET_ACCOUNT_INFO
*&---------------------------------------------------------------------*
* To get the Vendor/Customer/GL Account Information
*----------------------------------------------------------------------*
FORM GET_ACCOUNT_INFO .

*--- Loop to get the Vendor, Customer, G/L related data based on posting key
LOOP AT IT_TBSL.
*--- If posting key relates to Vendor
IF IT_TBSL-KOART = C_K.
PERFORM GET_BSIK_DATA.
*--- If posting key relates to Customer
ELSEIF IT_TBSL-KOART = C_D.
PERFORM GET_BSID_DATA.
*--- If posting key relates to G/L
ELSE.
PERFORM GET_BSIS_DATA.
ENDIF.
ENDLOOP.

ENDFORM. " GET_ACCOUNT_INFO

*&---------------------------------------------------------------------*
*& Form GET_BSIK_DATA
*&---------------------------------------------------------------------*
* To get the Vendor data
*----------------------------------------------------------------------*
FORM GET_BSIK_DATA .

IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSIK
INTO TABLE IT_BSIK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

IF SY-SUBRC <> 0.
*--- If document does not exist in BSIK get from BSAK
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSAK
INTO TABLE IT_BSAK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

ENDIF.
ENDIF.
ENDFORM. " GET_BSIK_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSID_DATA
*&---------------------------------------------------------------------*
* To get the Customer data
*----------------------------------------------------------------------*
FORM GET_BSID_DATA .

IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSID
INTO TABLE IT_BSID
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSAD
INTO TABLE IT_BSAD
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

ENDIF.
ENDIF.

ENDFORM. " GET_BSID_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSIS_DATA
*&---------------------------------------------------------------------*
* To get the G/L data
*----------------------------------------------------------------------*
FORM GET_BSIS_DATA .

IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSIS
INTO TABLE IT_BSIS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSAS
INTO TABLE IT_BSAS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.

ENDIF.

ENDIF.

ENDFORM. " GET_BSIS_DATA

*&---------------------------------------------------------------------*
*& Form GET_LFA1_DATA
*&---------------------------------------------------------------------*
* To get the Vendor Descriptions
*----------------------------------------------------------------------*
FORM GET_LFA1_DATA.

IF NOT IT_BSIK[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT LIFNR NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_BSIK
WHERE LIFNR = IT_BSIK-LIFNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.

ENDFORM. " GET_LFA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_KNA1_DATA
*&---------------------------------------------------------------------*
* To get the Customer descriptions
*----------------------------------------------------------------------*
FORM GET_KNA1_DATA .

IF NOT IT_BSID[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT KUNNR NAME1
FROM KNA1
INTO TABLE IT_KNA1
FOR ALL ENTRIES IN IT_BSID
WHERE KUNNR = IT_BSID-KUNNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.

ENDFORM. " GET_KNA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_SKAT_DATA
*&---------------------------------------------------------------------*
* To get the GL Descriptions
*----------------------------------------------------------------------*
FORM GET_SKAT_DATA .

IF NOT IT_BSIS[] IS INITIAL.
*--- Select construct to get the GL Account descriptions
SELECT SAKNR TXT50
FROM SKAT
INTO TABLE IT_SKAT
FOR ALL ENTRIES IN IT_BSIS
WHERE SAKNR = IT_BSIS-HKONT
AND SPRAS = 'EN'.

IF SY-SUBRC <> 0.
ENDIF.
ENDIF.

ENDFORM. " GET_SKAT_DATA
*&---------------------------------------------------------------------*
*& Form GET_OUTPUT
*&---------------------------------------------------------------------*
* To get the Output data
*----------------------------------------------------------------------*
FORM GET_OUTPUT.

DATA: L_LIFNR LIKE BSIK-LIFNR,
L_KUNNR LIKE BSID-KUNNR,
L_SAKNR LIKE SKAT-SAKNR.
DATA: FG_DOC TYPE C.

LOOP AT IT_BKPF.
FG_DOC = SPACE.
LOOP AT IT_FAGLFLEXA WHERE DOCNR = IT_BKPF-BELNR.
*--- Get the documents pertaining to profit center
IF FG_DOC = SPACE.
IT_HEAD-BUKRS = IT_BKPF-BUKRS.
IT_HEAD-BELNR = IT_BKPF-BELNR.
IT_HEAD-GJAHR = IT_BKPF-GJAHR.
IT_HEAD-BLDAT = IT_BKPF-BLDAT.
IT_HEAD-BUDAT = IT_BKPF-BUDAT.
IT_HEAD-CPUDT = IT_BKPF-CPUDT.
IT_HEAD-USNAM = IT_BKPF-USNAM.
APPEND IT_HEAD.
CLEAR IT_HEAD.
FG_DOC = 'X'.
ENDIF.

IT_ITEM = IT_FAGLFLEXA.

*--- Read tables BSIK to get the Vendor data
READ TABLE IT_BSIK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSIK-LIFNR.
IT_ITEM-UMSKZ = IT_BSIK-UMSKZ.
L_LIFNR = IT_BSIK-LIFNR.
ELSE.
*--- Read tables BSAK to get the Vendor data
READ TABLE IT_BSAK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSAK-LIFNR.
IT_ITEM-UMSKZ = IT_BSAK-UMSKZ.
L_LIFNR = IT_BSAK-LIFNR.
ENDIF.
ENDIF.
*---- Get the Vendor description into output table
READ TABLE IT_LFA1 WITH KEY LIFNR = L_LIFNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_LFA1-NAME1.
ENDIF.

*--- Read tables BSID to get the Customer data
READ TABLE IT_BSID WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSID-KUNNR.
IT_ITEM-UMSKZ = IT_BSID-UMSKZ.
L_KUNNR = IT_BSID-KUNNR.
ELSE.
*--- Read tables BSAD to get the Customer data
READ TABLE IT_BSAD WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSAD-KUNNR.
IT_ITEM-UMSKZ = IT_BSAD-UMSKZ.
L_KUNNR = IT_BSAD-KUNNR.
ENDIF.
ENDIF.
*---- Get the Customer description into output table
READ TABLE IT_KNA1 WITH KEY KUNNR = L_KUNNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_KNA1-NAME1.
ENDIF.

*--- Read tables BSIS to get the G/L data
READ TABLE IT_BSIS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSIS-HKONT.
ELSE.
*--- Read tables BSAS to get the G/L data
READ TABLE IT_BSAS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSAS-HKONT.
ENDIF.
ENDIF.
*--- Get the GL Account descrition into Output table
READ TABLE IT_SKAT WITH KEY SAKNR = L_SAKNR.
IF SY-SUBRC = 0.
IT_ITEM-HKONT = L_SAKNR.
IT_ITEM-ACCNT_NAME = IT_SKAT-TXT50.
ENDIF.

APPEND: IT_ITEM.
CLEAR: IT_ITEM,
L_LIFNR,
L_KUNNR,
L_SAKNR.
ENDLOOP.
ENDLOOP.

ENDFORM. " GET_OUTPUT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
* Format and display the output
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT_ALV .

DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV.

*--- Set Layout properties
LS_LAYOUT-GROUP_CHANGE_EDIT = C_X.
LS_LAYOUT-COLWIDTH_OPTIMIZE = SPACE.
LS_LAYOUT-ZEBRA = C_X.
LS_LAYOUT-DETAIL_POPUP = C_X.
LS_LAYOUT-GET_SELINFOS = C_X.

**--- Build field catalog and sort table
S_FIELDCATALOG-COL_POS = '1'.
S_FIELDCATALOG-FIELDNAME = 'BELNR'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'BELNR_D'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
S_FIELDCATALOG-SP_GROUP = 'A'.
S_FIELDCATALOG-EMPHASIZE = 'C71'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Company Code (Header data)
S_FIELDCATALOG-COL_POS = '2'.
S_FIELDCATALOG-FIELDNAME = 'BUKRS'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'BUKRS'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Fiscal year (Header data)
S_FIELDCATALOG-COL_POS = '3'.
S_FIELDCATALOG-FIELDNAME = 'GJAHR'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'GJAHR'.
S_FIELDCATALOG-OUTPUTLEN = '12'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Document Date (Header data)
S_FIELDCATALOG-COL_POS = '4'.
S_FIELDCATALOG-FIELDNAME = 'BLDAT'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'BLDAT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Posting Date (Header data)
S_FIELDCATALOG-COL_POS = '5'.
S_FIELDCATALOG-FIELDNAME = 'BUDAT'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'BUDAT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Document Entry Date (Header data)
S_FIELDCATALOG-COL_POS = '6'.
S_FIELDCATALOG-FIELDNAME = 'CPUDT'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'CPUDT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for UserName (Header data)
S_FIELDCATALOG-COL_POS = '7'.
S_FIELDCATALOG-FIELDNAME = 'USNAM'.
S_FIELDCATALOG-TABNAME = 'IT_HEAD'.
S_FIELDCATALOG-ROLLNAME = 'USNAM'.
S_FIELDCATALOG-OUTPUTLEN = '12'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Document No. (Item data)
S_FIELDCATALOG-COL_POS = '1'.
S_FIELDCATALOG-FIELDNAME = 'DOCNR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BELNR_D'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
S_FIELDCATALOG-EMPHASIZE = 'C11'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Posting Date. (Item data)
S_FIELDCATALOG-COL_POS = '2'.
S_FIELDCATALOG-FIELDNAME = 'BUDAT'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BUDAT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Fiscal Year (Item data)
S_FIELDCATALOG-COL_POS = '3'.
S_FIELDCATALOG-FIELDNAME = 'RYEAR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'RYEAR'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Company Code. (Item data)
S_FIELDCATALOG-COL_POS = '4'.
S_FIELDCATALOG-FIELDNAME = 'RBUKRS'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BUKRS'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Profit Center (Item data)
S_FIELDCATALOG-COL_POS = '5'.
S_FIELDCATALOG-FIELDNAME = 'PRCTR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'PRCTR'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Item No. (Item data)
S_FIELDCATALOG-COL_POS = '6'.
S_FIELDCATALOG-FIELDNAME = 'BUZEI'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BUZEI'.
S_FIELDCATALOG-OUTPUTLEN = '3'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Value in Transaction Currency (Item data)
S_FIELDCATALOG-COL_POS = '7'.
S_FIELDCATALOG-FIELDNAME = 'TSL'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'VTCUR12'.
S_FIELDCATALOG-OUTPUTLEN = '15'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Value in Local Currency (Item data)
S_FIELDCATALOG-COL_POS = '8'.
S_FIELDCATALOG-FIELDNAME = 'HSL'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'VLCUR12'.
S_FIELDCATALOG-OUTPUTLEN = '15'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Debit/Credit Indicator (Item data)
S_FIELDCATALOG-COL_POS = '9'.
S_FIELDCATALOG-FIELDNAME = 'DRCRK'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'DRCRK'.
S_FIELDCATALOG-OUTPUTLEN = '2'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Posting Key (Item data)
S_FIELDCATALOG-COL_POS = '10'.
S_FIELDCATALOG-FIELDNAME = 'BSCHL'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BSCHL'.
S_FIELDCATALOG-OUTPUTLEN = '4'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Vendor Number (Item data)
S_FIELDCATALOG-COL_POS = '11'.
S_FIELDCATALOG-FIELDNAME = 'LIFNR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'LIFNR'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for (Item data)
S_FIELDCATALOG-COL_POS = '12'.
S_FIELDCATALOG-FIELDNAME = 'UMSKZ'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'UMSKZ'.
S_FIELDCATALOG-OUTPUTLEN = '3'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Customer Number (Item data)
S_FIELDCATALOG-COL_POS = '13'.
S_FIELDCATALOG-FIELDNAME = 'KUNNR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'KUNNR'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for GL Account (Item data)
S_FIELDCATALOG-COL_POS = '14'.
S_FIELDCATALOG-FIELDNAME = 'HKONT'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'HKONT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Account Name (Item data)
S_FIELDCATALOG-COL_POS = '15'.
S_FIELDCATALOG-FIELDNAME = 'ACCNT_NAME'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'NAME1_GP'.
S_FIELDCATALOG-OUTPUTLEN = '50'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Transaction Type (Item data)
S_FIELDCATALOG-COL_POS = '16'.
S_FIELDCATALOG-FIELDNAME = 'RMVCT'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'RMVCT'.
S_FIELDCATALOG-OUTPUTLEN = '4'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Currency Key (Item data)
S_FIELDCATALOG-COL_POS = '17'.
S_FIELDCATALOG-FIELDNAME = 'RTCUR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'RTCUR'.
S_FIELDCATALOG-OUTPUTLEN = '5'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Cost Center (Item data)
S_FIELDCATALOG-COL_POS = '18'.
S_FIELDCATALOG-FIELDNAME = 'RCNTR'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'RCNTR'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Controlling Area (Item data)
S_FIELDCATALOG-COL_POS = '19'.
S_FIELDCATALOG-FIELDNAME = 'KOKRS'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'KOKRS'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Segment (Item data)
S_FIELDCATALOG-COL_POS = '20'.
S_FIELDCATALOG-FIELDNAME = 'SEGMENT'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'SEGMENT'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Company ID of trading partner (Item data)
S_FIELDCATALOG-COL_POS = '21'.
S_FIELDCATALOG-FIELDNAME = 'RASSC'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'RASSC'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Posting period (Item data)
S_FIELDCATALOG-COL_POS = '22'.
S_FIELDCATALOG-FIELDNAME = 'POPER'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'POPER'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for Document Status (Item data)
S_FIELDCATALOG-COL_POS = '23'.
S_FIELDCATALOG-FIELDNAME = 'BSTAT'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'BSTAT'.
S_FIELDCATALOG-OUTPUTLEN = '4'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

*--- Fieldcatalog for User Name (Item data)
S_FIELDCATALOG-COL_POS = '24'.
S_FIELDCATALOG-FIELDNAME = 'USNAM'.
S_FIELDCATALOG-TABNAME = 'IT_ITEM'.
S_FIELDCATALOG-ROLLNAME = 'USNAM'.
S_FIELDCATALOG-OUTPUTLEN = '10'.
APPEND S_FIELDCATALOG TO T_FIELDCATALOG.
CLEAR: S_FIELDCATALOG.

S_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL TEXT'.
S_LAYOUT-KEY_HOTSPOT = 'X'.
S_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.

*--- Add events for the Hierarchial List
EVENT-NAME = 'TOP_OF_PAGE'.
EVENT-FORM = 'TOP_OF_PAGE'.
APPEND EVENT.

*--- Specifying the Key field information
LS_KEYINFO-HEADER01 = 'BELNR'.
LS_KEYINFO-ITEM01 = 'DOCNR'.
LS_KEYINFO-ITEM02 = 'RYEAR'.

ENDFORM. " BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
* To display the ALV list output
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_OUTPUT .

*--- Call function to display Hierarchical list
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_EVENTS = EVENT[]
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = T_FIELDCATALOG
I_TABNAME_HEADER = C_IT_HEAD
I_TABNAME_ITEM = C_IT_ITEM
IS_KEYINFO = LS_KEYINFO
TABLES
T_OUTTAB_HEADER = IT_HEAD
T_OUTTAB_ITEM = IT_ITEM
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. " DISPLAY_ALV_OUTPUT

*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* To navigate to the Document display - transaction FB03
*----------------------------------------------------------------------*
FORM USER_COMMAND USING I_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED

DATA: LS_HEAD LIKE IT_HEAD,
LS_ITEM LIKE IT_ITEM.

*--- Check the User command
CASE I_UCOMM.
WHEN '&IC1'. " Pick
CASE IS_SELFIELD-TABNAME.
*--- Check whether selection is from HEADER data
WHEN C_IT_HEAD.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_HEAD INDEX IS_SELFIELD-TABINDEX INTO LS_HEAD.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_HEAD-BELNR.
SET PARAMETER ID C_BUK FIELD LS_HEAD-BUKRS.
SET PARAMETER ID C_GJR FIELD LS_HEAD-GJAHR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.

*--- Check whether selection is from ITEM data
WHEN C_IT_ITEM.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_ITEM INDEX IS_SELFIELD-TABINDEX INTO LS_ITEM.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_ITEM-DOCNR.
SET PARAMETER ID C_BUK FIELD LS_ITEM-RBUKRS.
SET PARAMETER ID C_GJR FIELD LS_ITEM-RYEAR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.

ENDFORM. " USER_COMMAND

*&---------------------------------------------------------------------*
*& Form VALIDATE_BUKRS
*&---------------------------------------------------------------------*
* To validate Company code against the check table T001
*----------------------------------------------------------------------*
FORM VALIDATE_BUKRS.

DATA: L_BUKRS LIKE BKPF-BUKRS.

IF NOT S_BUKRS[] IS INITIAL.
*--- Select Construct to check S_BUKRS against BUKRS from T001
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Company Code is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid Company code'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_BUKRS
*&---------------------------------------------------------------------*
*& Form VALIDATE_BELNR
*&---------------------------------------------------------------------*
* Validating the Document No. against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_BELNR .

DATA: L_BELNR LIKE BKPF-BELNR.

IF NOT S_BELNR[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BELNR
INTO L_BELNR
FROM BKPF
WHERE BELNR IN S_BELNR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Number is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid Document Number'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_BELNR
*&---------------------------------------------------------------------*
*& Form VALIDATE_GJAHR
*&---------------------------------------------------------------------*
* Validating the Fiscal Year against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_GJAHR.

DATA: L_GJAHR LIKE BKPF-GJAHR.

IF NOT S_GJAHR[] IS INITIAL.
*--- Select Construct to check S_GJAHR against GJAHR from BKPF
SELECT SINGLE GJAHR
INTO L_GJAHR
FROM BKPF
WHERE GJAHR IN S_GJAHR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Fiscal Year is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid Fiscal Year'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_GJAHR
*&---------------------------------------------------------------------*
*& Form VALIDATE_BLART
*&---------------------------------------------------------------------*
* Validating the Document Type against T003
*----------------------------------------------------------------------*
FORM VALIDATE_BLART .

DATA: L_BLART LIKE T003-BLART.

IF NOT S_BLART[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BLART
INTO L_BLART
FROM T003
WHERE BLART IN S_BLART.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Type is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid Document Type'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_BLART
*&---------------------------------------------------------------------*
*& Form VALIDATE_USNAM
*&---------------------------------------------------------------------*
* Validating the Username against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_USNAM .

DATA: L_USNAM LIKE BKPF-USNAM.

IF NOT S_USNAM[] IS INITIAL.
*--- Select Construct to check S_USNAM against USNAM from BKPF
SELECT SINGLE USNAM
INTO L_USNAM
FROM BKPF
WHERE USNAM IN S_USNAM.
IF SY-SUBRC <> 0.
*--- Display message if an invalid User Name is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid User Name'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_USNAM
*&---------------------------------------------------------------------*
*& Form VALIDATE_PRCTR
*&---------------------------------------------------------------------*
* Validating the Profit against the check table CEPC
*----------------------------------------------------------------------*
FORM VALIDATE_PRCTR .

DATA: L_PRCTR LIKE CEPC-PRCTR.

IF NOT S_PRCTR[] IS INITIAL.
*--- Select Construct to check S_PRCTR against PRCTR from CEPC
SELECT SINGLE PRCTR
INTO L_PRCTR
FROM CEPC
WHERE PRCTR IN S_PRCTR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Profit Center is entered
MESSAGE E002(ZMSGCLASS) WITH 'Enter a valid Profit Center'.
ENDIF.
ENDIF.

ENDFORM. " VALIDATE_PRCTR

*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* TOP OF PAGE *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.

DATA: V_COUNT(05) TYPE N.
DATA: L_COUNT(05) TYPE C.
DATA: V_HEADER(100) TYPE C.

*--- Get the number of Documents to be displayed
DESCRIBE TABLE IT_HEAD LINES V_COUNT.
V_COUNT = V_COUNT.
L_COUNT = V_COUNT.
CONCATENATE ' Profit center wise documents'
'Number of Documents'
V_COUNT
INTO V_HEADER SEPARATED BY ':'.

REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = V_HEADER.
APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
* I_LOGO =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE

Wednesday, January 9, 2008

ABAP Performance Standards

Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.g. Use the results of the above checks to remove all variables/constants etc that are declared but are not used)

Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations

Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your “where” clause to assure they are significant. Check other indices for this table and where you have to change your “where” clause to use it. Create new indices if necessary, but do not forget to check the impact by consulting onsite coordinator.

TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name

Internal Table is defined with “TYPE STANDARD TABLE OF” & Work-Areas is used instead of header lines

Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s)

In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view

For selecting single row from a database table, “SELECT UP to 1 Rows” is used. “Select Single” is used only when full primary key combination is known

No SELECT * is used

Use “SELECT INTO TABLE” rather than “SELECT INTO CORRESPONDING FIELDS OF TABLE”

Always specify as many primary keys as possible in WHERE clause to make the Select efficient

Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use “Up to N Rows” when the number of records needed is known

Select statement within a GET event is not used

Wild cards like ‘A%’ is avoided as much as possible

Nested Select is not used instead “Inner Join” and/or “For all Entries” is used. “For all Entries” is to be used over “Loop at ITAB / Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database)

When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use “ FOR ALL ENTRIES” select statement

Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time

CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table

Delete adjacent duplicate entries from internal table before selection from database table using “ FOR ALL ENTRIES” statement

For copying internal tables use ‘=’ operator instead of Looping & Appending

SORT inside a LOOP is not used

Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work

For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF…EXIT…ENDIF as appropriate to exit from the loop

Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)

Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully specified key)

DELETE or SORT is not used on a hashed table since it increases memory consumption

Sorted table is used for range accesses involving table key or index accesses

Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively

When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields “equal to” something

LOOP AT ITAB INTO WORKAREA WHERE K = ‘XXX’ should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = ‘XXX’.

Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.

After the APPEND statement inside a loop, the work area that has been appended is cleared

Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch program

Do not delete the records of internal table inside the Loop – End loop.

Do not use: LOOP AT ITAB WHERE EQUNR = ‘00001011’.
DELETE ITAB.

ENDLOOP.

Use: DELETE ITAB WHERE EQUNR = ‘00001011’.

Use the MODIFY ITAB ... TRANSPORTING f1 f2 ... for single line, and MODIFY ITAB ... TRANSPORTING f1 f2 ... WHERE condition for a set of line, to accelerate the updating of internal table

If possible, Update/Insert statement is used instead of Modify

Is the following steps ensured during database updates?
• Lock data to be edited
• Read current data from the database
• Process data and write it to the database
• Release the locks set at the beginning

Try to avoid logical databases. If your program
uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database

Avoid the aggregate (Count, Max, Min) functions in the database selection

Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records

In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface

Good Link

http://www.sappoint.com/PHPWebUI/Documents/Performance%20Problems%20in%20ABAP%20Programs%20How%20to%20Find%20Them.pdf

How to update and insert database records without writing code?

Update Database Records
http://allaboutsap.blogspot.com/2008/01/how-to-update-database-records-without.html

http://www.saptechnical.com/Tips/Basis/Transport/TableEntries.htm

Creating Entries in Table when Table Maintainence is not allowed.
First set break points to both the includes LSD41F01 for case df-ddxx-mainflag and for include LSETBU03 set break point to if dd02l-mainflag = 'N'.

Now go to SE11 tcode and give the table name and press display now debug will start and take you to the case mentioned below.

CASE df-ddxx-mainflag.
during debug change the value to 'X'
and press F8 Now it will take you to the next include

LSETBU03
if dd02l-mainflag = 'N'.
Here set the value to 'X'.Now it will take you to the creation of table entries and we can give the required entries.

Search Help Step-by-Step

Creating Search Helps - Elementary & Collective

Elementary search helps define the standard flow of an input help. Components of this flow include:

* the sources data displayed in the hit list (selection method)
* information that should be displayed in the dialog box for value selection and in the hit list (search help parameters)
* field contents that can be taken into account for hit list selections and which values in the hit list can be returned to the screen fields (search help parameters)
* dialog steps that should be executed in the input help (dialog behavior)

Collective search helps can combine more than one elementary search helps. Thus enabling the user to choose one of several alternative search paths with a collective search help.

When you define a collective search help, you only have to specify the search helps that are to be combined in the collective search help. In the input help, the values are transported between the elementary search help selected by the user and the input template using the collective search help. This is why a collective search help also has an interface for transporting the values.

Creation of Search Helps: A Simple Elementary Search Help
Go to SE11 -> Select radio button "Search Help" -> enter a name



You will see a popup window (as shown below), select "Elementary Search Help" radio button and hit "Enter"



-> Enter "Short description", "Selection method**" (MARA in this case) and fields that should be displayed in the Search Help.

Selection method** You can enter the name of a table or a view (database view, projection view or help view) here. If you enter a table that has a text table, the name of the text table is automatically entered in the corresponding field.

Notice that the text table of MARA (MAKT) has automatically been included as we entered MARA in the Selection Method



-> "Save" -> "Check" -> "Activate" -> "Execute". You will see a popup window (as shown below) with all the fields you added. Press F4 on any of them to see how your first Elementary Search Help looks.



Below is how it looks.Your first Elementary Search Help is ready.



Creation of Search Helps: A Simple Collective Search Help
Go to SE11 -> Select radio button "Search Help" -> enter a name



Select "Elementary Search Help" radio button (on the popup) and hit "Enter"



-> Enter "Short description" and fields that should be displayed in the Search Help in the Definition Tab.



-> Now go to the "Included Search Helps" tab and enter the names of the Elementary Search Helps you wish to include into your Collective Search Help (ZKAR_SHLP in this case).

-> Now select the line which contains your Elementary Search Help and click on "Param. Assignment**"

Position the cursor one after the other on each allocated search help and choose Parameter assignment.



In the next screen, enter the parameter names of the elementary search helps to which the corresponding parameters of the collective search help should be assigned in the field Reference parameter. You can select the parameters contained in the included search help using the input help. Create a proposal for the assignment with Proposal.



-> "Save" -> "Check" -> "Activate" -> "Execute". You will see a popup window (as shown below) with all the fields you added. Press F4 on any of them to see how your first Collective Search Help looks.



Below is how it looks.Your first Collective Search Help is ready.



Once done, you can attach the search help to:

* A data element
* A check table
* A table field
* A screen field

Thursday, January 3, 2008

ABAP Debugger

Single step(F5) - Use this option to step through the program statement by statement. This allows you to branch into subroutines and function modules, and to execute these routines step by step as well. Once a subroutine or function module has been processed, control returns to the statement following the CALL FUNCTION or PERFORM statement.

Execute(F6)- Use this option to process a program line by line. All of the statements on the current line are processed in a single step. If you are positioned on a line that calls a subroutine and you choose Execute, the Debugger processes the whole subroutine and then moves on to the line following the subroutine call.
This allows you to jump through the statements within the subroutine.

Return(F7) - The Debugger returns from a routine to the point at which control returns to the main program. Use this option to return from a subroutine, function module, or called program to the calling program.

Continue(F8)- Use this option to process the program up to the next dynamic or static breakpoint or up to the cursor position. If there are no more breakpoints in the program and no cursor has been set, the system exits debugging mode and executes the rest of the program normally.

Tables
- Display the contents of internal tables.


Good Link

http://www.sappoint.com/PHPWebUI/Documents/The%20New%20ABAP%20Debugger%20-%20An%20Introduction.pdf