allsapsites
Rating: 52
Member since: 2008-10-08
Feeds: 2
Bookmarks
Bookmarks
Bookmark with Del.icio.us Digg it Bookmark with Furl
Submit to Reddit Bookmark with Yahoo
StumbleUpon Toolbar Bookmark with Technorati

Categories

Subscribe: All SAP ABAP Notes
All SAP ABAP Notes Add to My Yahoo! All SAP ABAP Notes Add to Google! All SAP ABAP Notes Add to AOL! All SAP ABAP Notes Add to MSN All SAP ABAP Notes Subscribe in NewsGator Online All SAP ABAP Notes Add to Netvibes
All SAP ABAP Notes Subscribe in Pakeflakes All SAP ABAP Notes Subscribe in Bloglines All SAP ABAP Notes Add to Alesti RSS Reader All SAP ABAP Notes Add To Fwicki All SAP ABAP Notes Add to NewsBurst All SAP ABAP Notes Add to Windows Live
All SAP ABAP Notes Rojo RSS reader All SAP ABAP Notes iPing-it All SAP ABAP Notes Add to Feedage RSS Alerts All SAP ABAP Notes Add to Feedage.com Groups All SAP ABAP Notes Add to Spoken to You
All SAP ABAP Notes http://freesapabapnotes.blogspot.com/rss.xml
Feed Statistics
Views: 267 Feedage Grade B rated
Rating: 5
Adult Score: 0.015
Added: 2008-10-08 04:54:52
Added By: allsapsites
Media n RSS Type ATOM
Niche Language English
Tags: alv  data  end  event  fieldcat  fieldcatalog  form  grid  header  itab  layout  line  list  mara  perform  slis  text 
Rate this Feed:
Rating: 5 starRating: 5 starRating: 5 starRating: 5 starRating: 5 star

Comments (0)

Sponsored Links:
Preview: All SAP ABAP Notes

All SAP ABAP Notes



SAP,ABAP PROGRAMMING,Reports,Bdc,SAP Scripts,Smart Forms,Debugging,Internal table,interview Questions,FAQ'S,Series of Complete Course of all major topics of ABAP



Updated: 2009-10-16T08:43:16.608+05:30

 

Vb codes (or VBA macro code) for access SAP, and run one RFC

2009-02-12T17:26:51.569+05:30

I am looking for, Vb codes (or VBA macro code) for access SAP, and run one RFC . Does anyone have example VB to SAP code? Hakan I can give you some code, but not sure it will work for you. When you ( or the help desk ) installs the SAP GUI, you can also install the SAP RFC development kit, if you do this you will have in your c:\program files\SAP??? ( in my case C:\Program Files\SAP620 ) a folder with a .frm extension ( in my case C:\Program Files\SAP620 \SAPGUI\rfcsdk\ccsamp\RFCSamp.VB\RFCsamp.frm ) From there you can start then, because you also need the vbp file and the vbw file in order to really make it work. If you just need the code, then here you go : Option ExplicitPrivate Sub Command1_Click()'Dim Foo As RFCSampObj ' Due to an acknowledged problem in MTSDim Foo As Object ' we Dim Foo as Object instead of as RFCSampObjDim searchterm As StringDim custlist As RecordsetSet Foo = CreateObject("RFCSampObj.RFCSampObj.1")Foo.Destination = "IDES"'Foo.Client = "800"'Foo.Language = "E"'Foo.UserID = "test"'Foo.Password = "pw"If Not Foo Is Nothing Then searchterm = Text1.Text 'Unfortunately RFC_CUSTOMER_GET does not convert ' a SPACE selction into a * so we do it here.... If IsEmpty(searchterm) Then searchterm = "*" On Error Resume Next Call Foo.GetCustList(searchterm, "", custlist) If Err.Number = 0 Then If Not custlist Is Nothing Then custlist.MoveFirst While Not custlist.EOF Debug.Print "------------------" Debug.Print "custlist.Fields(name1) " &custlist.Fields("NAME1") Debug.Print "custlist.Fields(stras) " &custlist.Fields("STRAS") Debug.Print "custlist.Fields(ort01) " &custlist.Fields("ORT01") Debug.Print "custlist.Fields(pstlz) " &custlist.Fields("PSTLZ") Debug.Print "custlist.Fields(telf1) " &custlist.Fields("TELF1") Debug.Print "custlist.Fields(telfx) " &custlist.Fields("TELFX") custlist.MoveNext Wend Else Debug.Print "ERROR: custlist is Nothing" End If Else Debug.Print "ERROR" & Err.Description MsgBox Err.Description, vbCritical, "Error:" End IfElse Debug.Print "Foo is nothing" MsgBox "Foo is nothing"End IfEnd SubPrivate Sub Command2_Click()'Dim Foo As RFCSampObj ' Due to an acknowledged problem in MTSDim Foo As Object ' we Dim Foo as Object instead of as RFCSampObjDim rs As RecordsetDim HeaderIn As RecordsetDim ItemsIn As RecordsetDim Partners As RecordsetDim OrderNumber As StringDim BapiReturn As RecordsetDim SoldTo As RecordsetDim ShipTo As RecordsetDim Payer As RecordsetDim ItemsOut As Recordset'Input tables can be crafted in two different ways:' - either using the DimAsXXXX method which returns a fully' described but empty Recordset.' - or using the AdvancedDataFactory to craft up a disconnected' Recordset.' An example of the later is shown with the Partners Table' the remaining input tables are crafted with the dim as.Dim adf As Object' Describe the shape of a disconnected recordsetDim vrsShape(1)Dim vrsParvw(3)Dim vrsKunnr(3)vrsParvw(0) = "PARTN_ROLE"vrsParvw(1) = CInt(8)vrsParvw(2) = CInt(2)vrsParvw(3) = FalsevrsKunnr(0) = "PARTN_NUMB"vrsKunnr(1) = CInt(8)vrsKunnr(2) = CInt(10)vrsKunnr(3) = FalsevrsShape(0) = vrsParvwvrsShape(1) = vrsKunnr' Create a disconnected recordset to pass as an inputSet adf = CreateObject("RDSServer.DataFactory")If adf Is Nothing Then MsgBox "ADF == NOTGHING"End IfSet Partners = adf.CreateRecordSet(vrsShape)Set Foo = CreateObject("RFCSampObj.RFCSampObj.1")If Not Foo Is Nothing Then ' Get an empty recordset which will be used as input inCreateOrder call Call Foo.DimHeader(HeaderIn) HeaderIn.AddNew HeaderIn.Fields("DOC_TYPE") = "TA" HeaderIn.Fields("SALES_ORG") = "1000" HeaderIn.Fields("DISTR_CHAN") = "10" HeaderIn.Fields("DIVISION") = "00" HeaderIn.Fields("PURCH_NO") = "SM-1177-3" HeaderIn.Fields("INCOTERMS1") = "CPT" HeaderIn.Fields("INCOTERMS2") = "Hamburg" HeaderIn.Fields("PMNTTRMS") = "ZB01" HeaderIn.Update Call Foo.DimItems(ItemsIn)[...]

An Introduction to SAP

2009-02-12T17:25:41.871+05:30

SAP was founded in 1972 in Walldorf, Germany. It stands for Systems, Applications and Products in Data Processing. Over the years, it has grown and evolved to become the world premier provider of client/server business solutions for which it is so well known today. The SAP R/3 enterprise application suite for open client/server systems has established a new standards for providing business information management solutions.

SAP product are consider excellent but not perfect. The main problems with software product is that it can never be perfect.

The main advantage of using SAP as your company ERP system is that SAP have a very high level of integration among its individual applications which guarantee consistency of data throughout the system and the company itself.

In a standard SAP project system, it is divided into three environments, Development, Quality Assurance and Production.

The development system is where most of the implementation work takes place. The quality assurance system is where all the final testing is conducted before moving the transports to the production environment. The production system is where all the daily business activities occur. It is also the client that all the end users use to perform their daily job functions.

To all company, the production system should only contains transport that have passed all the tests.

SAP is a table drive customization software. It allows businesses to make rapid changes in their business requirements with a common set of programs. User-exits are provided for business to add in additional source code. Tools such as screen variants are provided to let you set fields attributes whether to hide, display and make them mandatory fields.

This is what makes ERP system and SAP in particular so flexible. The table driven customization are driving the program functionality instead of those old fashioned hard-coded programs. Therefore, new and changed business requirements can be quickly implemented and tested in the system.

Many other business application software have seen this table driven customization advantage and are now changing their application software based on this table customizing concept.

In order to minimized your upgrading costs, the standard programs and tables should not be changed as far as possible. The main purpose of using a standard business application software like SAP is to reduced the amount of time and money spend on developing and testing all the programs. Therefore, most companies will try to utilized the available tools provided by SAP.

sap abap program for Upload Logo for REUSE_ALV_COMMENTARY_WRITE

2009-02-12T17:25:06.237+05:30

For those who wish to upload and use a picture in your ALV abap reports.

Steps for uploading Logo :-:
1. Goto the transaction OAER
2. Enter the class name as 'PICTURES'
3. Enter the class type as 'OT'
4. Enter the object key as the name of the logo you wish to give
5. Execute
6. Then in the new screen select Standard doc. types in bottom window
Click on the Screen icon
Now, it will ask for the file path where you have to upload the logo
7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE

or

Import Logo and Background Picture for Reporting

In this step, you can import a customer-specific logo and a background picture into the R/3 System. These will be displayed in the header area of reports in HR Funds and Position Management.

From the SPRO:
HR Funds and Position Management --> Dialog Control --> Customize Reporting Interface --> Import Logo and Background Picture for Reporting.

Activities
1. Enter the Name of your logo/background picture as an object key in the initial screen.
2. Make sure that the class name is PICTURES, and the class type is OT.
3. Choose Execute.
4. Double-click the document type Picture on the Create tab page. A dialog box will appear in which you can enter the path in which the logo/background picture can be found.
5. Enter the path and choose Open. The logo will be uploaded into the current R/3 System. If the logo/background picture is to be transported into other systems as well, choose Transport.
6. Return to the initial screen and repeat the procedure after having entered the Name of your background picture as an object key.

Please note that the logo/background picture can only be displayed in ALV-based reports with an HTML header. Manually programmed reports such as business distribution plans are not based on the ALV.

If you have selected several initial objects, ALV-based reports in HR Funds and Position Management will automatically use a hiearchical-sequential display. A logo is not displayed here either. Note also that the logo cannot be printed (see print preview in program).

Make sure that the logo does not exceed a height of 100 pixels because it would mean that the header of the report will be scrollable.


What is SLIS in sap abap ALV

2009-02-12T17:24:38.148+05:30

SLIS is the type library for ALV grid.

If you'll use the ALV you have to add TYPE-POOLS : SLIS. command at the beginning of your code.

Consider these :
slis_t_fieldcat_alv is containing "_t_"
It means that it is an internal table and slis_fieldcat_alv is header line of that.

Here is a practical example for alv grid :
Just think that you have an internal table named 'ITAB' to show.

Step1 : First add these lines to your code :
TYPE-POOLS : SLIS.

DATA ALV_PROG_NAME LIKE SY-REPID.
ALV_PROG_NAME = SY-REPID.

DATA : ALV_ITAB_NAME(30),
L_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
ALV_ITAB_NAME = 'ITAB'. "!!Write here the name of your internal table

Step 2 : Add these two function :
The first function is filling the fieldcat L_FIELDCAT that you described, second is showing it on the screen.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = ALV_PROG_NAME
I_INTERNAL_TABNAME = ALV_ITAB_NAME
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = ALV_PROG_NAME
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = L_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
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 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ALV_PROG_NAME
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = L_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB[] "Write here the name of your internal table + []
* 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. *-- Bulent


How to Refresh ALV List/Grid once it is displayed?

2009-02-12T17:24:07.612+05:30

This mean to say that if you have a 'refresh' push button in your gui status, every time you press the button, the list should get refreshed.

In ALV, to refresh the table you have to call the method "refresh_table_display".

It has the syntax very similar to creating the table.

It has two parameters. In the first one, you can mention if you want to refresh only the data (the icons are not refreshed)

or

if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used in day to day applications).

the synatx is :-

call method grid (name of grid )->refresh_table_display

exporting

IS_STABLE = (THIS IS FOR DATA REFRESHING)

I_SOFT_REFRESH = (THIS IS FOR ICON REFRESHING).


sap abap ALV 'Classic' Creating User/Global Layout Variants

2009-02-12T17:23:44.651+05:30

You are working with the ALV "Classic" function module REUSE_ALV_LIST_DISPLAY.

Reading the documentation for the function module, it seems there is a way to save an ALV layout variant as "user-specific" and/or "global". But unfortunately, you either can only save "globals" (with the '/' as first character of the layout name) or "user-specific".

You have tried the I_SAVE parameter as 'U' and can only save "user-specific". You tried I_SAVE as 'X' and can only save "global". You tried I_SAVE as 'A', but only can only save as "user-specific". The odd thing is, on the Save Layout pop-up dialog the User-Specific checkbox is always "greyed-out", but has a check (for 'U' and 'A') or is checkless (for 'X').

Can "user" and "global" layout variants be saved together from same program with I_SAVE as 'A'?

Why is the User-Specific checkbox on the Save Layout pop-up always "greyed-out"?

You have the following EXPORTING parameters in my function module:
I_DEFAULT = 'X'
I_SAVE = 'A' "<=== this is to be global & user IS_VARIANT = VARIANT

VARIANT has the program's name in the REPORT field.


The "user-specific saving" needs a special authorization:
Authority-check object 'S_ALV_LAYO' id 'ACTVT' field '23', you can
avoid this authorization with IS_LAYOUT-NO_AUTHOR = 'X

How to use ALV for Hierarchical Lists

2009-02-12T17:23:17.471+05:30

Can anyone tell me how to use ALV for hierarchical lists using the function code REUSE_ALV_HIERSEQ_LIST_DISPLAY?

Swarna

Hello, there are some nice examples in SAP which use this function module, so you might want to check them out ( where used etc. )

In essence, this is a call in one of my ABAPs

  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_interface_check = 'I'
i_callback_program = gv_repid
* i_callback_pf_status_set = 'STATUS_DATA'
i_callback_user_command = 'COMMAND_DATA'
* is_layout = gs_layout
it_fieldcat = gt_fieldcat
i_default = ' '
i_save = 'A'
i_tabname_header = v_headers_itable
i_tabname_item = v_items_itable
i_structure_name_header = v_headers_table
i_structure_name_item = v_items_table
is_keyinfo = gs_keyinfo
i_bypassing_buffer = 'X'
TABLES
t_outtab_header = i_headers
* t_outtab_item = i_result
t_outtab_item = i_report
EXCEPTIONS
program_error = 1
OTHERS = 2.

The field cat creation worked like this :
FORM fieldcat.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_internal_tabname = v_items_itable
i_structure_name = v_items_table
CHANGING
ct_fieldcat = gt_fieldcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_internal_tabname = v_headers_itable
i_structure_name = v_headers_table
CHANGING
ct_fieldcat = gt_fieldcat.

ENDFORM.


and of course you need to tell the thing what is key and item

gs_keyinfo-header01 = 'PA'.
gs_keyinfo-item01 = 'PA'.
gs_keyinfo-item02 = 'SAPDOC'.
PERFORM fieldcat.
I hope this helps you and not confuse you,
Cheers.

sap abap program for Sample ALV: Heading in ALV

2009-02-12T17:22:53.129+05:30

report zus_alv_demo_grid .tables: ekko.type-pools: slis.types: begin of t_ekko,ebeln type ekpo-ebeln,ebelp type ekpo-ebelp,statu type ekpo-statu,aedat type ekpo-aedat,matnr type ekpo-matnr,menge type ekpo-menge,meins type ekpo-meins,netpr type ekpo-netpr,peinh type ekpo-peinh,line_color(4) type c, "Used to store row colorend of t_ekko.data: it_ekko type standard table of t_ekko initial size 0, wa_ekko type t_ekko.*ALV data declarationsdata: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid.* Data declaration for EVENT and PRINT PARAMETER.data: gt_events type slis_t_event, gd_prntparams type slis_print_alv.* data declaration for sorting.data : it_sortcat type slis_sortinfo_alv occurs 1, wa_sort like line of it_sortcat.data : i_list_comments type slis_t_listheader.start-of-selection.perform data_retrieval.* perform user_command.perform build_fieldcatalog.perform build_layout.perform build_events.perform build_print_params.perform build_sortcat.perform display_alv_report.end-of-selection.*TOP-OF-PAGE.* PERFORM top-of-page.end-of-page.*&----------------------------------------------------------*& Form build_fieldcatalog*&----------------------------------------------------------* text*-----------------------------------------------------------* --> p1 text* p1 text* p1 text* p1 text* p1 text* p1 text* R_UCOMM ** --> RS_SELFIELD **---------------------------------------------------------------------*form user_command using r_ucomm like sy-ucommrs_selfield type slis_selfield.case r_ucomm. when '&IC1'. if rs_selfield-fieldname = 'EBELN'. read table it_ekko into wa_ekko index rs_selfield-tabindex. set parameter id 'BES' field wa_ekko-ebeln. call transaction 'ME23N' and skip first screen. endif. when 'ULHAS'. if rs_selfield-fieldname = 'EBELN'. read table it_ekko into wa_ekko index rs_selfield-tabindex. set parameter id 'BES' field wa_ekko-ebeln. call transaction 'ME23N' and skip first screen. endif.endcase.endform.*---------------------------------------------------------------------** FORM set_pf_status **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------** --> RT_EXTAB **---------------------------------------------------------------------*form set_pf_status using rt_extab type slis_t_extab.set pf-status 'ZNEWSTATUS'.endform.*&---------------------------------------------------------------------**& Form build_events*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* p1 text* p1 text* [...]

sap abap program for Test ALV Display With Header & Footer

2009-02-12T17:22:19.246+05:30

*Program to Test ALV Display With Header & Footer.*&---------------------------------------------------------------------**& Report ZRJR02 **&---------------------------------------------------------------------*REPORT ZRJR02 .*Table declaration.TABLES:ZEMP_MST,ZDEPT_MST,ZDESG_MST,ZSL_TXN.*Varriable declaration.TYPE-POOLS SLIS.DATA : POS TYPE I.DATA REPID LIKE SY-REPID.DATA : F1 TYPE SLIS_T_FIELDCAT_ALV, F2 TYPE SLIS_FIELDCAT_ALV, L_LAYOUT TYPE SLIS_LAYOUT_ALV.DATA L_POS TYPE I VALUE 1. "position of the columnDATA GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.*DATA GT_SORT TYPE SLIS_T_SORTINFO_ALV.data: GT_EVENTS TYPE SLIS_T_EVENT, FS_EVENTCAT LIKE LINE OF GT_EVENTs.*Internal table declaration.*DATA BEGIN OF IT_SORT OCCURS 5.* INCLUDE TYPE SLIS_SORTINFO_ALV.*DATA END OF IT_SORT.DATA:BEGIN OF ITAB OCCURS 0, ZEMPNO LIKE ZEMP_MST-ZEMPNO, ZEMPNAME LIKE ZEMP_MST-ZEMPNAME, ZDEPTCD LIKE ZEMP_MST-ZDEPTCD, ZDEPTNAME LIKE ZDEPT_MST-ZDEPTNAME, ZDESGCD LIKE ZEMP_MST-ZDESGCD, ZDESGNAME LIKE ZDESG_MST-ZDESGNAME, END OF ITAB.REFRESH ITAB.CLEAR ITAB.START-OF-SELECTION.SELECT A~ZEMPNO A~ZEMPNAME A~ZDEPTCD B~ZDEPTNAME A~ZDESGCD C~ZDESGNAME FROM ZEMP_MST AS A INNER JOIN ZDEPT_MST AS B ON A~ZDEPTCD EQ B~ZDEPTCD INNER JOIN ZDESG_MST AS C ON A~ZDESGCD EQ C~ZDESGCD INTO CORRESPONDING FIELDS OF TABLE ITAB.IF SY-SUBRC 0. MESSAGE E899(M3) WITH 'No records'.ENDIF.perform f_build_eventcat.PERFORM LAYOUT.END-OF-SELECTION.*&---------------------------------------------------------------------**& Form LAYOUT*&---------------------------------------------------------------------*FORM LAYOUT .PERFORM FCAT USING 'ZEMPNO' 'ITAB' '' 'Emp.No.' 'ZEMPNO' 'ZEMP_MST' ''.PERFORM FCAT USING 'ZEMPNAME' 'ITAB' '' 'Emp. Name' 'ZEMPNAME' 'ZEMP_MST' ''.PERFORM FCAT USING 'ZDEPTCD' 'ITAB' '' 'Dept.Code' 'ZDEPTCD' 'ZEMP_MST' ''.PERFORM FCAT USING 'ZDEPTNAME' 'ITAB' '' 'Dept.Name' 'ZDEPTNAME' 'ZDEPT_MST' ''.PERFORM FCAT USING 'ZDESGCD' 'ITAB' '' 'Desg.Code' 'ZDESGCD' 'ZEMP_MST' ''.PERFORM FCAT USING 'ZDESGNAME' 'ITAB' '' 'Desg.Name' 'ZDESGNAME' 'ZDESG_MST' ''.* PERFORM LSORT USING 'ZEMPNO' 'IDATA' ''.* PERFORM LSORT USING 'ZEMPNAME' 'IDATA' ''.* MOVE IT_SORT[] TO GT_SORT[].REPID = SY-REPID.CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = REPID IT_FIELDCAT = F1* IT_SORT = GT_SORT I_SAVE = 'X' IT_EVENTS = GT_EVENTS[] TABLES T_OUTTAB = ITAB.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. " LAYOUT*&---------------------------------------------------------------------**& Form FCAT*&---------------------------------------------------------------------*FORM FCAT USING P_FIELD P_TABLE P_SUM P_TEXT P_RFIELD P_RTABLE P_DISP.ADD 1 TO POS.F2-COL_POS = POS.F2-FIELDNAME = P_FIELD.F2-TABNAME = P_TABLE.F2-SELTEXT_L = P_TEXT.F2-REF_FIELDNAME = P_RFIELD.F2-REF_TABNAME = P_RTABLE.F2-DO_SUM = P_SUM.F2-NO_OUT = P_DISP.APPEND F2 TO F1.CLEAR F2.ENDFORM. " FCAT*&---------------------------------------------------------------------**& Form LSORT*&---------------------------------------------------------------------**FORM LSORT USING P_FIELD P_TABLE P_UP.* ADD 1 TO L_POS.* IT_SORT-SPOS = L_POS.* IT_SORT-FIELDNAME = P_FIELD.* IT_SORT-TABNAME = P_TABLE.* IT_SORT-UP = P_UP.* APPEND IT_SORT.*ENDFORM. " LSORT*-------------FORM F_BUILD_EVENTCAT .CLEAR: GT_EVENTS. REFRESH: GT_E[...]

Sample programs on sap abap ALV Grid

2009-02-12T17:21:47.339+05:30

report zbnstest.************************************************************************* TABLES AND DATA DECLARATION.*************************************************************************TABLES: mara,makt.",marc.data syrepid like sy-repid.data sydatum(10). " LIKE sy-datum.data sypagno(3) type n.* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE* GROUP (TYPE-POOLS--------->SLIS)type-pools : slis.************************************************************************* INTERNAL TABLE DECLARATION.************************************************************************* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLEdata: begin of t_mara occurs 0,matnr like mara-matnr,meins like mara-meins,mtart like mara-mtart,matkl like mara-matkl, end of t_mara. * INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLEdata : begin of t_marc occurs 0,matnr like mara-matnr,werks like marc-werks,minbe like marc-minbe.data: end of t_marc. * INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.data : begin of t_makt occurs 0,matnr like mara-matnr,maktx like makt-maktx,spras like makt-spras,end of t_makt. * INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.data: begin of itab1 occurs 0,matnr like mara-matnr,meins like mara-meins,maktx like makt-maktx,spras like makt-spras,werks like marc-werks,minbe like marc-minbe,end of itab1.* THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT* AND THE LAYOUT FOR THE ALV.* HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE* WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT* OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.* THIS IS DONE TO MAKE THE CODE SIMPLER.* OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP* PROGRAMS.* IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR* MORE TABLES AND CREATE A STRUCTURE* IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS* LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.data: fieldcatalog type slis_t_fieldcat_alv with header line,fieldlayout type slis_layout_alv.* DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE* TOP-OF-PAGE ETC.data : eventstab type slis_t_event with header line. * DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGEdata : heading type slis_t_listheader with header line.data : heading1 type slis_t_listheader with header line.data : heading2 type slis_t_listheader with header line.data : heading3 type slis_t_listheader with header line.data : heading4 type slis_t_listheader with header line.data : heading5 type slis_t_listheader with header line.data : heading6 type slis_t_listheader with header line.data : heading7 type slis_t_listheader with header line.data : heading8 type slis_t_listheader with header line.* STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.data : colorstruct type slis_coltypes.************************************************************************* INITIALIZATION. *************************************************************************initialization.syrepid = sy-repid.sypagno = sy-pagno.clear fieldcatalog.************************************************************************* START-OF-SELECTION. *************************************************************************start-of-selection.* SUBROUTINE TO POPULATE THE COLORSTRUCTperform fill_colorstruct using colorstruct.* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUEperform populate_fieldcatalog.* SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE* INTERNAL TABLE.perform selectdata_and_sort.* SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.perform populate_layout using fieldlayout.* SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.perform merge_fieldcatalog.* SUBROUTINE TO POPULATE THE EVENTSTAB.perform fill_eventst[...]

what is abap REUSE_ALV_GRID_DISPLAY Functions Example

2009-02-12T17:21:15.163+05:30

I am using "REUSE_ALV_GRID_DISPLAY" to display Report in ALV.I have to show System Date and Time at the end of Report so I caught Event "END_OF_PAGE" in IT_EVENTS and modified IT_EVENTS field FORM with "F100_TOP_OF_PAGE", but I am not able to see the Date and Time in the END OF PAGE I wrote follwoing ocde so please suggest me necessary changes *&---------------------------------------------------------------------**& Form f100-end_of_page*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** --> p1 text* CLEAR ls_line.ls_line-typ = 'S'.ls_line-info = yl_uname.APPEND ls_line TO e06_lt_end_of_page. endform. "e06_comment_build Suman Tyagi An Example: REPORT ZALV_GRID. TABLES :vbap.type-pools : slis.data i_events TYPE slis_t_event.DATA : my_alv TYPE REF TO cl_gui_alv_grid.TYPES : BEGIN OF itab,vbeln LIKE vbap-vbeln,arktx LIKE vbap-arktx,END OF itab.TYPES : itab1 TYPE TABLE OF itab.DATA : display TYPE itab1.DATA : fcat TYPE SLIS_T_FIELDCAT_ALV.DATA : wa LIKE LINE OF FCAT.DATA WA1 LIKE VBAP.DATA: container TYPE REF TO cl_gui_custom_container.data report_id like sy-repid. SELECT-OPTIONS s_vbeln FOR vbap-vbeln.report_id = sy-repid. SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE display WHEREvbeln IN s_vbeln. wa-fieldname = 'VBELN'.wa-tabname = 'VBAP'.wa-key = 'X'.WA-HOTSPOT = 'X'.wa-text_fieldname = 'Doc no.'.APPEND wa TO fcat.CLEAR wa.wa-fieldname = 'ARKTX'.wa-tabname = 'VBAP'.wa-text_fieldname = 'Item Text'.APPEND wa TO fcat. PERFORM f0650_build_event USING 'USER_COMMAND''F0750_USER_COMMAND'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY 'EXPORTING I_CALLBACK_PROGRAM = report_id IT_FIELDCAT = FCATIT_EVENTS = i_eventsTABLESt_outtab = DISPLAY. FORM f0650_build_event USING value(w_c_event_name)value(w_c_event_form). DATA: f0650_wa_event TYPE slis_alv_event. CLEAR f0650_wa_event.f0650_wa_event-name = w_c_event_name.f0650_wa_event-form = w_c_event_form.APPEND f0650_wa_event TO i_events. ENDFORM.FORM f0750_user_command USING w_ucomm TYPE sy-ucomm w_selfield TYPE slis_selfield. CASE w_ucomm.WHEN '&IC1'. READ TABLE DISPLAY INTO WA1 INDEX w_selfield-tabindex.* MESSAGE E000 WITH* ' You have no authorization to view the report'.call transaction 'SE11'. ENDCASE.ENDFORM. *** End of Program [...]

Display a Secondary List using ALV Grid

2009-02-12T17:20:40.581+05:30

To display a secondary list when you click on one of the row items in an alv grid. The secondary list should also be an alv. Try out this code. You will have to make a structure ZSTR same as the output internal table.REPORT ZTEST_REP1 . TABLES : MARA, BHDGD, zstr. TYPES: BEGIN OF T_MARA, MATNR LIKE MARA-MATNR, ERNAM LIKE MARA-ERNAM, END OF T_MARA.CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.*Constants for ALV ImplementationCONSTANTS: C_SET VALUE 'X', C_RESET VALUE '0', C_SAVE VALUE 'A', C_EXIT(4) VALUE 'EXIT', C_BACK(4) VALUE 'BACK', C_CANC(4) VALUE 'CANC', C_PGTOP(5) VALUE 'PGTOP', C_PGUP(4) VALUE 'PGUP', C_PGDN(4) VALUE 'PGDN', C_PGEND(5) VALUE 'PGEND'.DATA : I_MARA TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE, * Internal table for fields catalouge I_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE,* i_fieldcat2 type lvc_t_fcat with header line, * Internal table for cursor position I_GT_SELROWS TYPE LVC_T_ROW . DATA : WA_MARA LIKE I_MARA, WA_GRIDROW LIKE LVC_S_ROW, WA_GRIDCOL LIKE LVC_S_COL. *Data for ALV Implementation.DATA: OK_CODE LIKE SY-UCOMM, W_OK_CODE LIKE SY-UCOMM, W_CALL TYPE I VALUE 1, W_TAB LIKE SY-UCOMM VALUE 'TAB1', W_SAVE, "For Parameter I_SAVE W_VARIANT TYPE DISVARIANT, "For parameter IS_VARIANT W_GRID TYPE REF TO CL_GUI_ALV_GRID,* w_grid1 type ref to cl_gui_alv_grid, W_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER, * w_container1 type ref to cl_gui_custom_container, W_REPID LIKE SY-REPID, W_GS_PRINT TYPE LVC_S_PRNT, W_GS_LAYOUT TYPE LVC_S_LAYO, W_EVENT_REC TYPE REF TO LCL_EVENT_RECEIVER, W_CONT_MAIN TYPE SCRFNAME VALUE 'CCCONTAINER', W_LN TYPE I, "line number W_INDEX LIKE SY-TABIX, W_FLAG, W_TEMP_VAL TYPE I. *---------------------------------------------------------------------** Definition:*---------------------------------------------------------------------*CLASS LCL_EVENT_RECEIVER DEFINITION. PUBLIC SECTION. METHODS: HANDLE_TOP_OF_PAGE FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID, HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN.ENDCLASS.*---------------------------------------------------------------------** CLASS LCL_EVENT_RECEIVER IMPLEMENTATION*---------------------------------------------------------------------*CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.METHOD HANDLE_TOP_OF_PAGE. PERFORM F_GET_HEADER.ENDMETHOD. "handle_top_of_page METHOD HANDLE_DOUBLE_CLICK. * The event DOUBLE_CLICK provides parameters for row and column* of the click. We use row parameter to select a line of the* corresponding internal table. * read selected row from internal table READ TABLE I_MARA INDEX E_ROW-INDEX INTO WA_MARA. IF SY-SUBRC 0.* message i001. " Cursor position not correct. ELSE.* call dialog screen and display the details call screen 200 starting at 10 5. ENDIF. ENDMETHOD. "handle_double_click ENDCLASS. *-----------------------------------------------------------------------* start-of-selection.*-----------------------------------------------------------------------START-OF-SELECTION. SELECT MATNR ERNAM FROM MARA INTO TABLE I_MARA. *----------------------------------------------------------[...]

sap abap program for Line Color in ALV Example

2009-02-12T17:20:06.068+05:30

An example of using linecolor (ALV). Here you have a good example of coloring rows, columns and specific cells in alvs. It comes in an example of how to use hashed tables. For coloured rows and cols check gp_bymatfor coloured specific rows uncheck gp_bymat.HTH.Horaciops: code:report zuseofhashedtables.************************************************************************** Program: ZUseOfHashedTables **************************************************************************** Author: Horacio Zapettini **** **** Versions: 4.6b - 4.6c **************************************************************************** Notes: **** this program shows how we can use hashed tables to improve **** the responce time. **** It shows, **** 1. how to declare hashed tables **** 2. a cache-like technique to improve access to master data **** 3. how to collect data using hashed tables **** 4. how to avoid deletions of unwanted data **************************************************************************** Results: the test we run read about 31000 rows from mkpf, 150000 **** rows from mseg, 500 rows from makt and 400 from lfa1. **** it filled ht_lst with 24500 rows and displayed them in **** alv grid format. **** **** It took about 65 secodns to perform this task (first time **** we run it when all the db buffers are empty. **** **** The same program with standard tables needed 140 seconds **** to run with the same recordset and with buffers filled in **** **** A simmilar test over more than a million rows************************************************************************** Objetive: show a list that consists of all the material movements **** '101' - '901' for a certain range of dates in mkpf-budat. **** the columns to be displayed are: **** mkpf-budat, **** mkpf-mblnr, **** mseg-lifnr, **** lfa1-name1, **** mkpf-xblnr, **** mseg-zeile **** mseg-charg, **** mseg-matnr, **** makt-maktx, **** mseg-erfmg, **** mseg-erfme. **** or show a sumary list by matnr - menge **** **** You'll have to create a pf-status called vista - **** See form set_pf_status for details **************************************************************************** tables used -tables: [...]

sap abap program for How to make ALV header like this?

2009-02-12T17:19:03.945+05:30

Header long text 1 Header long text 2 Header long text 3
Col_1 Col_2 Col_3 Col_4 Col_5 Col_6 Col_7 Col_8 Col_9
----------------------- Cell conents -------------------------------
----------------------- Cell conents -------------------------------
----------------------- Cell conents -------------------------------
----------------------- Cell conents -------------------------------
----------------------- Cell conents -------------------------------

You could try:
data: gt_list_top_of_page type slis_t_listheader. " Top of page text.

Initialization.
perform comment_build using gt_list_top_of_page[].

form top_of_page.
* Note to self: the gif must be loaded into transaction OAOR with
* classname 'PICTURES' AND TYPE 'OT' to work with ALV GRID Functions.
* I Loaded NOVALOGO2 into system.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
* I_LOGO = 'NOVALOGO2'
* i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = gt_list_top_of_page.

endform. " TOP_OF_PAGE

form comment_build using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader.
clear ls_line.
ls_line-typ = 'A'.
ls_line-info = 'Special'(001).
fgrant = xgrant.
concatenate ls_line-info fgrant
'Stock Option Report to the board'(002)
into ls_line-info separated by space.
condense ls_line-info.
append ls_line to e04_lt_top_of_page.

endform. " COMMENT_BUILD

How to implement a footer in alv grid programming? What is the procedure and the code regarding to create a footer?

Use following syntex for footer print in alv:

* For End of Page

form END_OF_PAGE.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .

endform.

* For End of Report

form END_OF_LIST.

data: listwidth type i,

ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .

endform.


sap abap program for Use Simple ALV Functions to Make Reporting Easy

2009-02-12T17:18:41.294+05:30

*&---------------------------------------------------------------------**& Report ZBC_ALV_EXAMPLE **& **&---------------------------------------------------------------------** This program explains how we can use simple ALV functions to make ** reporting easy and looks pretty************************************************************************* Programmer : Venkat Reddy ETA ** Date : 10/02/04 ************************************************************************** Maintenance Log **----------------------------------------------------------------------** Changed By Date Transport# Description **------------ ---------------------------------------------------------** Venkat Reddy 10/02/04 EGD913575 Changed program to avoid **----------------------------------------------------------------------*REPORT ZBC_ALV_EXAMPLE.************************************************************************* D-A-T-A D-E-C-L-A-R-A-T-I-O-N-S *************************************************************************tables: sflight.**-- TYPE-POOLS Definition**Includes the types and constants of a type group. Since the types and*constants specified in a type group have global validity, you cannot*use the statement within a FORM or FUNCTION.type-pools: slis.PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.**-- ALV variables*****- Field Catalog structuredata: ls_fieldcat type slis_fieldcat_alv, "Field Catalog list**--- Field Catalog table gt_fieldcat type slis_t_fieldcat_alv, "Field Catalog**--- Layout ( How you would like to see the output ) gs_layout type slis_layout_alv, "List Layout**-- Report name g_repid like sy-repid, g_save(1) type c, g_exit(1) type c, g_variant like disvariant, gx_variant like disvariant.**-- Flight Info Internal tabledata: lt_sflight like sflight occurs 0 with header line.************************************************************************* C-O-N-S-T-A-N-T-S ************************************************************************************************************************************************** S-E-L-E-C-T-I-O-N S-C-R-E-E-N *************************************************************************selection-screen begin of block a with frame title text-100.select-options: s_carrid for sflight-carrid, s_connid for sflight-connid, s_fldate for sflight-fldate default sy-datum.selection-screen end of block a .************************************************************************* I-N-I-T-I-A-L-I-Z-A-T-I-O-N *************************************************************************initialization.g_repid = sy-repid.**-- Fill ALV field catalogperform initialize_fieldcat using gt_fieldcat[].***-- Build Events* perform build_eventtab using gt_events[].***-- Read the default variantperform initialize_variant.************************************************************************* A-T S-E-L-E-C-T-I-O-N S-C-R-E-E-N *************************************************************************at selection-screen on value-request for p_vari.**-- Display all existing variantscall function 'REUSE_ALV_VARIANT_F4' e[...]

sap abap ALV Reporting - Z_LIST_MATERIALS

2009-02-12T17:18:06.591+05:30

REPORT Z_LIST_MATERIALS.TYPE-POOLS: SLIS.TABLES:MARC, MARD, VBAP, LIPS, EKPO, VBFA, EKBE, MARM, VBBE, MARA, MBEW.SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.SELECT-OPTIONS: S_WERKS FOR MARC-WERKS, " Plant S_MATNR FOR MARC-MATNR, " Material S_MTART FOR MARA-MTART. " Material Type SELECTION-SCREEN END OF BLOCK SEL.PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT. " ALV VariantCONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.DATA: BEGIN OF INV OCCURS 100, WERKS LIKE MARD-WERKS, " Plant MATNR LIKE MARD-MATNR, " Material MTART LIKE MARA-MTART, " Material Type STPRS LIKE MBEW-STPRS, " Standard Price AVAIL LIKE MARD-LABST, " Available LABST LIKE MARD-LABST, " Unrestricted use INSME LIKE MARD-INSME, " Quality Inspection RETME LIKE MARD-RETME, " Returns TRANS LIKE MARC-UMLMC, " Stock in transit (calculated) UMLMC LIKE MARC-UMLMC, " Stock Transfer (plant) UMLME LIKE MARD-UMLME, " Transfer (SLoc) WESBS LIKE EKBE-WESBS, " GR Blocked Stock TRAME LIKE MARC-TRAME, " Stock in transit SPEME LIKE MARD-SPEME, " Blocked KWMENG LIKE VBAP-KWMENG, " Sales orders LFIMG LIKE LIPS-LFIMG, " Scheduled for Delivery MENGE LIKE EKPO-MENGE, " Open Purch. Orders VALUE LIKE MBEW-SALK3, " Stock Value (Calculated) MEINS LIKE MARA-MEINS, " Unit of measure END OF INV.DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV, HEADING TYPE SLIS_T_LISTHEADER, LAYOUT TYPE SLIS_LAYOUT_ALV, EVENTS TYPE SLIS_T_EVENT, REPNAME LIKE SY-REPID, F2CODE LIKE SY-UCOMM VALUE '&ETA', G_SAVE(1) TYPE C, G_EXIT(1) TYPE C, G_VARIANT LIKE DISVARIANT, GX_VARIANT LIKE DISVARIANT.INITIALIZATION.REPNAME = SY-REPID.PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].PERFORM BUILD_EVENTTAB USING EVENTS[].PERFORM BUILD_COMMENT USING HEADING[].PERFORM INITIALIZE_VARIANT.AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.PERFORM F4_FOR_VARIANT.AT SELECTION-SCREEN.PERFORM PAI_OF_SELECTION_SCREEN.START-OF-SELECTION.PERFORM GET_MARD.PERFORM GET_UNIT_OF_MEASURE.PERFORM GET_MARC.PERFORM GET_EKPO.PERFORM GET_LIPS.PERFORM GET_VBAP.PERFORM GET_OPEN.PERFORM GET_PRICE.END-OF-SELECTION.PERFORM BUILD_LAYOUT USING LAYOUT.PERFORM WRITE_OUTPUT.*&---------------------------------------------------------------------**& Form INITIALIZE_FIELDCAT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_FIELDTAB[] text **----------------------------------------------------------------------*FORM INITIALIZE_FIELDCAT USING P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.* fixed columns (obligatory)CLEAR L_FIELDCAT.L_FIELDCAT-TABNAME = 'INV'.L_FIELDCAT-FIX_COLUMN = 'X'.L_FIELDCAT-NO_OUT = 'O'.L_FIELDCAT-FIELDNAME = 'WERKS'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'MATNR'.APPEND L_FIELDCAT TO P_FIELDTAB.* totalized columnsCLEAR L_FIELDCAT.L_FIELDCAT-TABNAME = 'INV'.L_FIELDCAT-SP_GROUP = 'A'.L_FIELDCAT-DO_SUM = 'X'.L_FIELDCAT-FIELDNAME = 'LABST'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'INSME'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'RETME'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'UMLME'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'WESBS'.APPEND L_FIELDCAT TO P_FIELDTAB.L_FIELDCAT-FIELDNAME = 'SPEME'.APPEND L_FIELDCAT TO P_FIELDTAB.* columns with different descriptionL_FIELDCAT-FIELDNAME = 'KWMENG'.L_FIELDCAT-SELTEXT_M = 'Sales Orders'.L_FIELDCAT-SELTEXT_S = 'Sales Or'.L_FIELDCAT-SELTEXT_L = 'Sales[...]

sap abap program for Reincarnation of REUSE_ALV_FIELDCATALOG_MERGE

2009-02-12T17:17:21.699+05:30

* Author Jayanta Narayan Choudhuri* Flat 302* 395 Jodhpur Park* Kolkata 700 068* Email sss@cal.vsnl.net.in* URL: http://www.geocities.com/ojncThese FORMs are for people accustomed toREUSE_ALV_FIELDCATALOG_MERGE (despite the 72 ch source line limit)but not happy with LVC_FIELDCATALOG_MERGE which has NO Internaltable optionWe do not want to crowd DDIC with too many structures!The routines handle any internal table using field name as titleif not a DDIC data element.Create a Include ZJNCINCLUDE with the 2 FORMsThere are two FORMs: ZJNC_DUMP_LIST will be very useful as it issimple and needs no screen and can be called any number of times.Should be very useful also for debugging esp. where Excel is notavailable as you can dump any internal table anytime and inspect contents.I wrote these routine mainly for debugging and the problem created byhalf-line long comments in internal tables. With RTTI there is no sourcecode dependency.ZJNC_DUMP_GRID is for OO-GRID loving people who can adapt that routinefor one off reports.You can call this ONLY ONCE as it is best used using a dummy selectionscreen - tip from SDN ABAP FAQ.As FORMs use RTTI there is no special case for Structures!-----------------------------------------------------------------------------------*&---------------------------------------------------------------------**& Include ZJNCINCLUDE **&---------------------------------------------------------------------**&---------------------------------------------------------------------**& Reincarnations of REUSE_ALV_FIELDCATALOG_MERGE*&---------------------------------------------------------------------** Author Jayanta Narayan Choudhuri* Flat 302* 395 Jodhpur Park* Kolkata 700 068* Email sss@cal.vsnl.net.in* URL: http://www.geocities.com/ojnc*-----------------------------------------------------------------------* These FORMs are for people accustomed to* REUSE_ALV_FIELDCATALOG_MERGE (despite the 72 ch source line limit)* but not happy with LVC_FIELDCATALOG_MERGE* We do not want to crowd DDIC with too many structures!*-----------------------------------------------------------------------*&--------------------------------------------------------------------**& Form ZJNC_DUMP_LIST Our Good Old ALV list - RECOMMENDED!*&--------------------------------------------------------------------*FORM zjnc_dump_list USING value(p_it_name) TYPE c value(p_wa_name) TYPE c value(p_heading) TYPE c.TYPE-POOLS: slis.DATA: stru_ref TYPE REF TO cl_abap_structdescr, comp_tab TYPE abap_compdescr_tab, one_comp TYPE abap_compdescr, one_name TYPE string, type_ref TYPE REF TO cl_abap_typedescr, is_ddic TYPE abap_bool, lt_ddic TYPE dd_x031l_table, wa_ddic TYPE x031l, lt_fcat TYPE slis_t_fieldcat_alv, wa_fcat TYPE slis_fieldcat_alv, ls_layo TYPE slis_layout_alv, l_alv TYPE REF TO cl_gui_alv_grid.FIELD-SYMBOLS: TYPE ANY, TYPE STANDARD TABLE, TYPE ANY.ASSIGN (p_it_name) TO .ASSIGN (p_wa_name) TO .ls_layo-colwidth_optimize = 'X'.ls_layo-zebra = 'X'.ls_layo-window_titlebar = p_heading.ls_layo-box_tabname = p_it_name.stru_ref ?= cl_abap_structdescr=>describe_by_data( ).comp_tab = stru_ref->components.LOOP AT comp_tab INTO one_comp. CLEAR wa_fcat. wa_fcat-tabname = p_it_name. wa_fcat-fieldname = one_comp-name. CONCATENATE p_wa_name '-' one_comp-name INTO one_name. ASSIGN (one_name) TO . type_ref ?= cl_abap_typed[...]

ALV Reporting - REUSE_ALV_BLOCK_LIST_DISPLAY

2009-02-12T17:16:45.362+05:30

REPORT z_alv_list_block.TYPE-POOLS: slis. " ALV Global typesSELECTION-SCREEN :SKIP,BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDEDPARAMETERS p_max(2) TYPE n DEFAULT '02' OBLIGATORY.SELECTION-SCREEN END OF LINE.DATA:* 1st TableBEGIN OF gt_kna1 OCCURS 0, " Data displayedkunnr LIKE kna1-kunnr, " Customer numberernam LIKE kna1-ernam, " Name of Person who Createderdat LIKE kna1-erdat, " Creation datename1 LIKE kna1-name1, " Name 1END OF gt_kna1,* 2nd TableBEGIN OF gt_mara OCCURS 0,ernam LIKE mara-ernam, " Name of Person who Createdmatnr LIKE mara-matnr, " Material numberersda LIKE mara-e rsda, " Creation datebrgew LIKE mara-brgew, " Gross weightEND OF gt_mara,* 3rd TableBEGIN OF gt_vbak OCCURS 0,vkorg LIKE vbak-vkorg, " Sales organizationkunnr LIKE vbak-kunnr, " Sold-to partyvbeln LIKE vbak-vbeln, " Sales documentnetwr LIKE vbak-netwr, " Net Value of the Sales Orderwaerk LIKE vbak-waerk, " SD document currencyEND OF gt_vbak.*---------------------------------------------------------------------*INITIALIZATION.v_1 = 'Maximum of records to read'.*---------------------------------------------------------------------*START-OF-SELECTION.* Read dataSELECT * FROM kna1UP TO p_max ROWSINTO CORRESPONDING FIELDS OF TABLE gt_kna1.SELECT * FROM maraUP TO p_max ROWSINTO CORRESPONDING FIELDS OF TABLE gt_mara.SELECT * FROM vbakUP TO p_max ROWSINTO CORRESPONDING FIELDS OF TABLE gt_vbak.CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'EXPORTINGi_callback_program = sy-cprogi_callback_user_command = 'USER_COMMAND'.PERFORM list_append TABLES gt_kna1USING '1''GT_KNA1'.PERFORM list_append TABLES gt_maraUSING '2''GT_MARA'.PERFORM list_append TABLES gt_vbakUSING '3''GT_VBAK'.PERFORM f_list_display.*---------------------------------------------------------------------** FORM USER_COMMAND **---------------------------------------------------------------------*FORM user_command USING i_ucomm LIKE sy-ucommis_selfield TYPE slis_selfield. "#EC CALLEDCASE i_ucomm.WHEN '&IC1'. " PickCASE is_selfield-tabname.WHEN 'GT_MARA'.WHEN 'GT_KNA1'.WHEN 'GT_VBAK'.READ TABLE gt_vbak INDEX is_selfield-tabindex.IF sy-subrc EQ 0.* Sales order numberSET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.* Display Sales OrderCALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.ENDIF.ENDCASE.ENDCASE.ENDFORM. " USER_COMMAND*---------------------------------------------------------------------*< /div>* Form list_append*---------------------------------------------------------------------*FORM list_append TABLES ut_tableUSING u_no TYPE char1u_tabname TYPE slis_tabname.* Macro definitionDEFINE m_fieldcat.ls_fieldcat-fieldname = &1.ls_fieldcat-ref_tabname = &2.append ls_fieldcat to lt_fieldcat.END-OF-DEFINITION.DEFINE m_sort.ls_sort-fieldname = &1.ls_sort-up = 'X'.append ls_sort to lt_sort.END-OF-DEFINITION.DATA :ls_fieldcat TYPE slis_fieldcat_alv,lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalogls_sort TYPE slis_sortinfo_alv,lt_sort TYPE slis_t_sortinfo_alv. " Sort tableDATA:lt_events TYPE slis_t_event,ls_event TYPE slis_alv_event,ls_layout TYPE slis_layout_alv.ls_layout-group_change_edit = 'X'.ls_layout-colwidth_optimize = 'X'.ls_layout-zebra = 'X'.ls_layout-detail_popup = 'X'.ls_layout-get_selinfos = 'X'.ls_layout-max_linesize = '200'.CASE u_no.WHEN '1'.* Build field catalog and sort tablem_fieldcat 'KUNNR' 'KNA1'.m_fieldcat 'ERNAM' 'KNA1'.m_fieldcat 'ERDAT' 'KNA1'.m_fieldcat 'NAME1' 'KNA1'.m_sort 'KUNNR'.WHEN '2'.m_fieldcat 'MATNR' 'MARA'.m_fieldcat 'ERNAM' 'MARA'.m_fieldcat 'ERSDA' 'MARA'.m_fieldcat 'BRGEW' 'MARA'.m_sort 'MATNR'.WHEN '3'.m_fieldcat 'VBELN' 'VBAK'.m_fieldcat 'VKORG' 'VBAK'.m_fieldcat 'KUNNR' 'VBAK'.m[...]

sap abap program for An Interactive ALV Report

2009-02-12T17:16:14.960+05:30

*&---------------------------------------------------------------------**& Report ZZ_22038_22098_002 **& **&---------------------------------------------------------------------**& This is an Interactive ALV report, where on line slection we can see*& the secondry list*&*& **&---------------------------------------------------------------------*REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650MESSAGE-ID ZZ_9838 .TYPE-POOLS: SLIS.*type declaration for values from ekkoTYPES: BEGIN OF I_EKKO, EBELN LIKE EKKO-EBELN, AEDAT LIKE EKKO-AEDAT, BUKRS LIKE EKKO-BUKRS, BSART LIKE EKKO-BSART, LIFNR LIKE EKKO-LIFNR, END OF I_EKKO.DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0, WA_EKKO TYPE I_EKKO.*type declaration for values from ekpoTYPES: BEGIN OF I_EKPO, EBELN LIKE EKPO-EBELN, EBELP LIKE EKPO-EBELP, MATNR LIKE EKPO-MATNR, MENGE LIKE EKPO-MENGE, MEINS LIKE EKPO-MEINS, NETPR LIKE EKPO-NETPR, END OF I_EKPO.DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0, WA_EKPO TYPE I_EKPO .*variable for Report IDDATA: V_REPID LIKE SY-REPID .*declaration for fieldcatalogDATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.* declaration for events table where user comand or set PF status will* be definedDATA: V_EVENTS TYPE SLIS_T_EVENT, WA_EVENT TYPE SLIS_ALV_EVENT.* declartion for layoutDATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.* declaration for variant(type of display we want)DATA: I_VARIANT TYPE DISVARIANT, I_VARIANT1 TYPE DISVARIANT, I_SAVE(1) TYPE C.*PARAMETERS : p_var TYPE disvariant-variant.*Title displayed when the alv list is displayedDATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.INITIALIZATION.V_REPID = SY-REPID.PERFORM BUILD_FIELDCATLOG.PERFORM EVENT_CALL.PERFORM POPULATE_EVENT.START-OF-SELECTION.PERFORM DATA_RETRIEVAL.PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.PERFORM DISPLAY_ALV_REPORT.*&--------------------------------------------------------------------**& Form BUILD_FIELDCATLOG*&--------------------------------------------------------------------** Fieldcatalog has all the field details from ekko*---------------------------------------------------------------------*FORM BUILD_FIELDCATLOG.WA_FIELDCAT-TABNAME = 'IT_EKKO'.WA_FIELDCAT-FIELDNAME = 'EBELN'.WA_FIELDCAT-SELTEXT_M = 'PO NO.'.APPEND WA_FIELDCAT TO I_FIELDCAT.CLEAR WA_FIELDCAT.WA_FIELDCAT-TABNAME = 'IT_EKKO'.WA_FIELDCAT-FIELDNAME = 'AEDAT'.WA_FIELDCAT-SELTEXT_M = 'DATE.'.APPEND WA_FIELDCAT TO I_FIELDCAT.CLEAR WA_FIELDCAT.WA_FIELDCAT-TABNAME = 'IT_EKKO'.WA_FIELDCAT-FIELDNAME = 'BUKRS'.WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.APPEND WA_FIELDCAT TO I_FIELDCAT.CLEAR WA_FIELDCAT.WA_FIELDCAT-TABNAME = 'IT_EKKO'.WA_FIELDCAT-FIELDNAME = 'BUKRS'.WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.APPEND WA_FIELDCAT TO I_FIELDCAT.CLEAR WA_FIELDCAT.WA_FIELDCAT-TABNAME = 'IT_EKKO'.WA_FIELDCAT-FIELDNAME = 'LIFNR'.WA_FIELDCAT-NO_OUT = 'X'.WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.APPEND WA_FIELDCAT TO I_FIELDCAT.CLEAR WA_FIELDCAT.ENDFORM. "BUILD_FIELDCATLOG*&--------------------------------------------------------------------**& Form EVENT_CALL*&-----------------------------------[...]

sap abap program for Example of a Simple ALV Grid Report

2009-02-12T17:15:34.337+05:30

REPORT ZTUFI091 .*&---------------------------------------------------------------------**& Report ZDEMO_ALVGRID **& **&---------------------------------------------------------------------**& **& Example of a simple ALV Grid Report **& ................................... **& **& The basic requirement for this demo is to display a number of **& fields from the EKKO table. **&---------------------------------------------------------------------**REPORT zdemo_alvgrid .TABLES: ekko.type-pools: slis. "ALV Declarations*Data Declaration*----------------TYPES: BEGIN OF t_ekko,ebeln TYPE ekpo-ebeln,ebelp TYPE ekpo-ebelp,statu TYPE ekpo-statu,aedat TYPE ekpo-aedat,matnr TYPE ekpo-matnr,menge TYPE ekpo-menge,meins TYPE ekpo-meins,netpr TYPE ekpo-netpr,peinh TYPE ekpo-peinh,END OF t_ekko.DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko.*ALV data declarationsdata: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid, gt_events type slis_t_event, gd_prntparams type slis_print_alv.*************************************************************************Start-of-selection.START-OF-SELECTION.perform data_retrieval.perform build_fieldcatalog.perform build_layout.perform build_events.perform build_print_params.perform display_alv_report.*&---------------------------------------------------------------------**& Form BUILD_FIELDCATALOG*&---------------------------------------------------------------------** Build Fieldcatalog for ALV Report*----------------------------------------------------------------------*form build_fieldcatalog.* There are a number of ways to create a fieldcat.* For the purpose of this example i will build the fieldcatalog manualy* by populating the internal table fields individually and then* appending the rows. This method can be the most time consuming but can* also allow you more control of the final product.* Beware though, you need to ensure that all fields required are* populated. When using some of functionality available via ALV, such as* total. You may need to provide more information than if you were* simply displaying the result* I.e. Field type may be required in-order for* the 'TOTAL' function to work.fieldcatalog-fieldname = 'EBELN'.fieldcatalog-seltext_m = 'Purchase Order'.fieldcatalog-col_pos = 0.fieldcatalog-outputlen = 10.fieldcatalog-emphasize = 'X'.fieldcatalog-key = 'X'.* fieldcatalog-do_sum = 'X'.* fieldcatalog-no_zero = 'X'.append fieldcatalog to fieldcatalog.clear fieldcatalog.fieldcatalog-fieldname = 'EBELP'.fieldcatalog-seltext_m = 'PO Item'.fieldcatalog-col_pos = 1.append fieldcatalog to fieldcatalog.clear fieldcatalog.fieldcatalog-fieldname = 'STATU'.fieldcatalog-seltext_m = 'Status'.fieldcatalog-col_pos = 2.append fieldcatalog to fieldcatalog.clear fieldcatalog.fieldcatalog-fieldname = 'AEDAT'.fieldcatalog-seltext_m = 'Item change date[...]

ABAP Example Program ALV Grid Control

2009-02-12T17:14:49.960+05:30

You need to create a screen 100 for calling it, and in the Element list of the sceen supply OK_CODE of type OK & in the layout, place a Custom - control with name DILEEP_TEST1.

Then activate modules STATUS_0100 and USER_COMMAND_0100 in the flow logic .

REPORT ZTEST_DIL4 .
TABLES ZMSTKSUM.
DATA : OK_CODE LIKE SY-UCOMM,
TAB_DISPLAY TYPE TABLE OF ZMSTKSUM,
C_CONTAINER TYPE SCRFNAME VALUE 'DILEEP_TEST1',
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
C_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : S_WERKS FOR ZMSTKSUM-WERKS.

SELECTION-SCREEN END OF BLOCK B1.

SELECT * FROM ZMSTKSUM INTO TABLE TAB_DISPLAY WHERE WERKS IN S_WERKS.


CALL SCREEN 100.
*&---------------------------------------------------------------------

*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------

* text
*----------------------------------------------------------------------

MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
* SET TITLEBAR 'xxx'.
IF C_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT C_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = C_CONTAINER
.
CREATE OBJECT ALV_GRID EXPORTING I_PARENT = C_CUSTOM_CONTAINER.

CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
I_STRUCTURE_NAME = 'ZMSTKSUM'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
CHANGING
IT_OUTTAB = TAB_DISPLAY
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* others = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT

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

*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------

* text
*----------------------------------------------------------------------

MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT'.
LEAVE PROGRAM.

ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT

What Are The Events In abap ALV

2009-02-12T17:14:21.118+05:30

What are the events in alvs and which events not used in alvs? Events in alv and their FM The main events in alv and their FM and why we use these: 1. SLIS_PRINT_ALV. 2. SLIS_T_LISTHEADER. 3. SLIS_T_EVENT. 4. SLIS_T_SORTINFO_ALV. 5. SLIS_T_LAYOUT_ALV. 6. SLIS_T_FIELDCAT_ALV. and in classic reports what is the sequence of events: === Events are At selection-screen output. Initialization. At selection-screen on field At selection-screen on end of field At selection-screen on Radiobutton Group R1. (If you have any radio buttons) At selection-screen on block b1. (If you have any blocks) Start-of-selection. Get node. (if the data is retreived from a logical database) Get node late. (if the data is retreived from a logical database) Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement) end-of-selection. and fuction modules are LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information. EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation. These events are captured by this FM. LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style. FIELDCAT - These are used to populate the List header. We can change them according to our req. User-defined Text Output Event Application print_end_of_list Define output text to be printed at the end of the entire list print_top_of_list Define output text to be printed at the beginning of the entire list print_end_of_page Define output text to be printed at the end of each page print_top_of_page Define output text to be printed at the beginning of each page subtotal_text Define self-defined subtotals texts Mouse-controlled Actions in the Grid Control Event Application button_click Query a click on a pushbutton in the ALV Grid Control double_click Query a double-click on a cell of the ALV Grid control hotspot_click Query a hotspot click on columns defined for this purpose in advance onDrag Collect information when elements of the ALV Grid Control are dragged onDrop Process information when elements of the ALV Grid Control are dropped onDropComplete Perform final actions after successful Drag&Drop onDropGetFlavor Distinguish between options for Drag&Drop behavior Processing of Self-defined and Standard Functions Event Application before_user_command Query self-defined and standard function codes user_command Query self-defined function codes after_user_command Query self-defined and standard function codes Definition of Self-defined Functions Event Application toolbar Change, delete or add GUI elements in the toolbar menu_button Define menus for menu buttons in the toolbar context_menu_request Change context menu onf1 Define self-defined F1 help All of these can be found under type group SLIS. * EventsSLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',SLIS_EV_REPREP_SEL_MODIFY TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',SLIS_EV_TOP_OF_P[...]

abap program for Creation Of Active Icon

2009-02-12T17:13:52.914+05:30

REPORT CREATION_OF_ACTIVE_ICON.
INITIALIZATION.
IMPORT mytab-activetab FROM MEMORY ID 'TABSTRIP'.
CASE mytab-activetab.
WHEN 'UCOMM1'. mytab-dynnr = 100.
WHEN 'UCOMM2'. mytab-dynnr = 200.
WHEN 'UCOMM3'. mytab-dynnr = 300.
WHEN OTHERS.
tabb1-dynnr = 100.
ENDCASE.

START-OF-SELECTION.
EXPORT: tabb1-activetab TO MEMORY ID 'TABSTRIP'.

SHORT VERSION.

INITIALIZATION.
IMPORT mytab FROM MEMORY ID 'TABSTRIP'.

START-OF-SELECTION.
EXPORT: mytab TO MEMORY ID 'TABSTRIP'.


SYNTAX FOR CREATING THE EXISTING CONTEXT MENU.::

FORM on_ctmenu_text USING menu TYPE REF TO cl_ctmenu.
CALL METHOD menu->load_gui_status
EXPORTING program = prog
status = 'CON_MENU'
menu = menu .
CALL METHOD menu->set_default_function
EXPORTING fcode = 'list'.
ENDFORM.


CREATING A NEW CONTEXT MENU::

FORM on_ctmenu_text USING menu TYPE REF TO cl_ctmenu.
DATA new_menu TYPE REF TO cl_ctmenu.
CREATE OBJECT new_menu.
CALL METHOD new_menu->add_function
EXPORTING fcode = 'list'
text = text-001.

CALL METHOD new_menu->add_function
EXPORTING fcode = 'add'
text = text-002. CALL METHOD
new_menu->add_function
EXPORTING fcode = 'delete'
text = text-003.

CALL METHOD new_menu->add_submenu
EXPORTING menu = new_menu
text = text-005.
ENDFORM


SYNTAX FOR STATUS ICON:


CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'icon name'
TEXT = 'text to be displayed'
INFO = 'tooltip text'•

using alv grid real time implementation

2009-02-12T17:13:14.279+05:30

REPORT ZALV .type-pools : slis.tables : spfli,SFLIGHT.data : begin of itab occurs 0,carrid like spfli-carrid,connid like spfli-connid,end of itab.CONSTANTS:GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.data : g_fieldcat type slis_t_fieldcat_alv,GS_LAYOUT TYPE SLIS_LAYOUT_ALV,g_repid like sy-repid,GT_EVENTS TYPE SLIS_T_EVENT,g_layout type slis_layout_alv,GS_KEYINFO TYPE SLIS_KEYINFO_ALV,G_TABNAME_HEADER TYPE SLIS_TABNAME,G_TABNAME_ITEM TYPE SLIS_TABNAME.data : itab1 like sflight occurs 0 with header line.g_repid = sy-repid.select carrid connid into corresponding fields of table itab fromspfli.G_TABNAME_HEADER = 'ITAB'.G_TABNAME_ITEM = 'ITAB1'.CLEAR GS_KEYINFO.GS_KEYINFO-HEADER01 = 'CARRID'.GS_KEYINFO-ITEM01 = 'CARRID'.LOOP AT ITAB.SELECT * FROM SFLIGHT WHERE CARRID = ITAB-CARRID. MOVE-CORRESPONDING SFLIGHT TO ITAB1. APPEND ITAB1. CLEAR ITAB1.ENDSELECT.IF SY-SUBRC EQ 0. EXIT.ENDIF.ENDLOOP.PERFORM E03_EVENTTAB_BUILD USING GT_EVENTS[].perform pc_fld using :1 1 'CARRID' 'CARRIER' 10 ' H' 'ITAB',1 2 'CONNID' 'CONNECTIONID' 04 ' H' 'ITAB',2 1 'FLDATE' 'FLIGHT DET' 10 ' H' 'ITAB1',2 2 'PRICE' 'PRICING DET' 20 ' H' 'ITAB1'.GS_LAYOUT-F2CODE = '&ETA'.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTING* I_INTERFACE_CHECK = ' 'I_CALLBACK_PROGRAM = g_repid* I_CALLBACK_PF_STATUS_SET = ' 'i_callback_user_command = 'ABCDEF'IS_LAYOUT = GS_LAYOUTIT_FIELDCAT = G_FIELDCAT* IT_EXCLUDING =* IT_SPECIAL_GROUPS =* IT_SORT =* IT_FILTER =* IS_SEL_HIDE =* I_SCREEN_START_COLUMN = 0* I_SCREEN_START_LINE = 0* I_SCREEN_END_COLUMN = 0* I_SCREEN_END_LINE = 0* I_DEFAULT = 'X'* I_SAVE = ' '* IS_VARIANT =IT_EVENTS = GT_EVENTS[]* IT_EVENT_EXIT =*I_TABNAME_HEADER = G_TABNAME_HEADER*I_TABNAME_ITEM = G_TABNAME_ITEM* I_STRUCTURE_NAME_HEADER =* I_STRUCTURE_NAME_ITEM =*IS_KEYINFO = GS_KEYINFO* IS_PRINT =* IS_REPREP_ID =* I_BUFFER_ACTIVE =* I_BYPASSING_BUFFER =* IMPORTING* E_EXIT_CAUSED_BY_CALLER =* ES_EXIT_CAUSED_BY_USER =TABLEST_OUTTAB = ITAB*T_OUTTAB_ITEM = ITAB1* 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.* -----------------------------------------------------------*form ABCDEF using r_ucomm like sy-ucomm rs_selfield typeslis_selfield.* -----------------------------------------------------------*case r_ucomm. when '&IC1'. read table itab index rs_selfield-tabindex. if sy-subrc eq 0. write : / 'sdfdsf'. endif. CLEAR r_ucomm.endcase.endform.*&---------------------------------------------------------------------**& Form pc_fld*&---------------------------------------------------------------------** text*----------------------------------------------------------------------** -->P_1 text* -->P_1 text* -->P_0057 text* -->P_0058 text* -->P_10 text* -->P_0060 text* -->P_0061 text*----------------------------------------------------------------------*FORM pc_fld USING L P F D O R T.DATA : T_FLD TYPE SLIS_FIELDCAT_ALV.CLEAR T_FLD.MOVE : L TO T_FLD-ROW_POS.MOVE : P TO T_FLD-COL_POS.MOVE : F TO T_FLD-FIELDNAME.MOVE D TO : T_FLD-SELTEXT_L,T_FLD-SELTEXT_M,T_FLD-SELTEXT_S.MOVE 'L' TO T_FLD-DDICTXT.MOVE O TO T_FLD-OUTPUTLEN.MOVE T TO T_FLD-TABNAME.MOVE ' ' TO T_FLD-DO_SUM.APPEND T_FLD TO G_FIELDCAT.ENDFORM. " pc_fld*---------------------------------------------------------------------** FORM E03_EVENTTAB_BUILD **---------------------------------------[...]

Adding custom buttons on ALV grid controls

2009-02-12T17:12:34.821+05:30

This report shows you how to add a custom button to your ALV grid control. DATA * Predefine a local class for event handling to allow the * declaration of a reference variable before the class is defined. CLASS lcl_event_receiver DEFINITION DEFERRED. DATA: custom_container1 TYPE REF TO cl_gui_custom_container, cont_on_main TYPE scrfname VALUE 'ALV_GRID', grid1 TYPE REF TO cl_gui_alv_grid, event_receiver TYPE REF TO lcl_event_receiver, okcode LIKE sy-ucomm. DATA: gt_fieldcat TYPE slis_t_fieldcat_alv, gt_fieldcat1 TYPE lvc_t_fcat, gs_layout TYPE slis_layout_alv, gs_layout1 TYPE lvc_s_layo, gs_print TYPE slis_print_alv, gt_sort TYPE slis_t_sortinfo_alv, gt_sp_group TYPE slis_t_sp_group_alv, gt_events TYPE slis_t_event, gt_list_top_of_page TYPE slis_t_listheader. DATA:t_out TYPE TABLE OF zstruct, t_out_wa LIKE zstruct. **************************************************************** * LOCAL CLASSES: Definition **************************************************************** *=============================================================== * class lcl_event_receiver: local class to * define and handle own functions. * Definition: * ~~~~~~~~~~~ CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION. METHODS: handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive, handle_user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm. PRIVATE SECTION. ENDCLASS. **************************************************************** * LOCAL CLASSES: Implementation **************************************************************** *=============================================================== * class lcl_event_receiver (Implementation) CLASS lcl_event_receiver IMPLEMENTATION. METHOD handle_toolbar. * § 2.In event handler method for event TOOLBAR: Append own functions * by using event parameter E_OBJECT. DATA: ls_toolbar TYPE stb_button. *.................................................................... * E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET. * This class has got one attribute, namly MT_TOOLBAR, which * is a table of type TTB_BUTTON. One line of this table is * defined by the Structure STB_BUTTON (see data deklaration above). * * A remark to the flag E_INTERACTIVE: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 'e_interactive' is set, if this event is raised due to * the call of 'set_toolbar_interactive' by the user. * You can distinguish this way if the event was raised * by yourself or by ALV * (e.g. in method 'refresh_table_display'). * An application of this feature is still unknown... :-) * append a separator to normal toolbar CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO e_object->mt_toolbar. * append an icon to show booking table CLEAR ls_toolbar. MOVE 'COMMENT' TO ls_toolbar-function. MOVE icon_annotation TO ls_toolbar-icon. MOVE 'Insert Comment'(001) TO ls_toolbar-quickinfo. MOVE 'Notes'(004) TO ls_toolbar-text. MOVE ' ' TO ls_toolbar-dis[...]