Refresh ALV Report
I am using call method cl_salv_table=>factory to display an ALV report. How to add a refresh button and then add functionality to it.
Hi,
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 = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)
I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).
Regards,
Bhaskar
Similar Messages
-
Refresh ALV Report after return from dialog screen
Hi All,
I have developed an alv report which lists new products, when user clicks on a product it will take to custom dialog screen where user makes neccessary changes. Once the changes are done user clicks back the control comes back to the ALV report.
My question is when they come back to ALV report it should refresh and list the new products. Basically I want to know is it possible to refresh the report when control is coming back from dialog screen to ALV report.
Pls provide me a best way to handle this scenario.
Regards,
AnandHi Archna
This is the code I am using
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = i_title
it_fieldcat = it_fcat
it_events = v_events
i_save = 'A'
TABLES
t_outtab = it_alv_cvg.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
READ TABLE it_alv_map INTO wa_alv INDEX rs_selfield-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'ZCR' FIELD wa_alv-product.
CALL TRANSACTION 'ZSD_PRODUCT_DIV' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
After it goes to dialog when I clcik back it comes back to the alv report.
Now can you Pls tell me where to use the refresh.
Regards,
Anand -
HI
I WANT TO REFREAH ALV AFTER I PRES ON BUTTON.
WHEN I USE REUSE_ALV_GRID_DISPLAY
IN USER-COMMAND I USE
FORM USER_COMMAND USING P_UCOMM TYPE SYUCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
P_SELFIELD-REFRESH = 'X'
how can i refresh when i use class
CL_SALV_TABLE?
thanks
have nice dayhi yossi,
check these links..
Refresh in ALV.
Alv Grid and Refresh Button
ALV grid Refresh.
http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm
http://sap.ittoolbox.com/groups/career/SAP-CAREER/refresh-alv-report-421919
Re: Refresh ALV with a new value
Re: Update/refresh ALV grid -
hi masters,
i m working on alv report where i have to change the data. after changing the data i have to do the refresh for that i m using the method below
wa_STBL-ROW = 'X'.
wa_STBL-COL = 'X'.
CALL METHOD grid_obj->refresh_table_display
EXPORTING
IS_STABLE = wa_stbl
I_SOFT_REFRESH = 'X '
EXCEPTIONS
finished = 1
OTHERS = 2.
but after executing this method its giving run time error saying that ' Access via 'NULL' object reference not possible. You attempted to use a 'NULL' object reference (points to 'nothing') access a component (variable: "GRID_OBJ").'. can u plz help me where i m going wrong. and how to implement the refresh in alv report in details..
thanks in advance.
regards,
vickyhi,
when i clicked on refresh button it is going to pf-status after that as i shown in below code it goes to refresh_report. but in this 'form refresh_report' it won't display the data. it goes into the infinite loop. within that form- endform. plz can u give me solution for this problem?
set pf-status 'STANDARD_FULLSCREEN'.
case sy-ucomm.
when '&REFRESH'.
perform refresh_report.
endcase.
form refresh_report .
perform build_fieldcatlog.
perform event_call.
perform populate_event.
perform data_retrieval.
perform build_listheader using it_listheader.
perform display_alv_report_fm.
endform. " REFRESH_REPORT -
How to refresh after delete the records in ALV report ?
Hi Friends,
How to refresh after delete the records in ALV report.
I am deleting records in ALV report .
After successful delete the screen should refresh.
u201C Deleted records should not appear in the screen u201C.
Please guide me.
Regards,
SubashHi subhash,
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
WHEN 'BACK'.
Refresh the internal table from the ALV grid
PERFORM update_alv_tab.
ENDFORM. "user_command
FORM update_alv_tab .
DATA : e_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = e_grid.
CALL METHOD e_grid->check_changed_data.
"update_alv_tab
CALL METHOD e_grid->refresh_table_display.
ENDFORM. " UPDATE_ALV_TAB
Then see in Debug mode is it updating or not..
Please confirm .
And please paste the code if you can.
Regards. -
Add new line in ALV report and Refresh button
How to add a new line in a ALV report?
How to add a refresh button in a report?Hi,
First of all u have to Create ur own PF-status and Assign Fcode e.g 'INSERTROW'.
So, whenevr you will click Insertrow button it will be triggered in your User Command and then just Append the blank line in your Final Internal Table.
And Refresh Icon will be there by default...
To Trigger it You have to write rs_selfield-refresh = 'X'
You can also follow the below link...
Try it.
Link:[http://wiki.sdn.sap.com/wiki/display/ABAP/ALVeasytutorial].
Regards
Arbind -
Logic for Refreshing the ALV Report (Very Urgent)
Hi Experts,
My <b>ALV report</b> needs a <b>refresh button</b> on the output.
The <b>Refresh button</b> should be available to allow user to keep this report on screen and <b>refresh regularly</b> rather than <b>going back</b> and <b>running it again.</b>
I am using <b>Function modules</b> and not <b>OOPS Concept</b> here.............As i am<b> unaware</b> of OOPS Please provide me solution in <b>FM's Only</b>.
Kindly send me <b>sample logic</b> for this, <b>Very urgent</b> if ur reply is helpfull.... u will be <b>rewarded heavily</b>.......................
THanks in advance.
Rajesh KumarHi,
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 = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)
I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).
Regards,
Bhaskar -
hi,
How to use PF STATUS IN ALV REPORT?HI,
see this code.
TABLES:MARA.
SELECT-OPTIONS: MATNR FOR MARA-MATNR.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
MTART LIKE MARA-MTART,
MBRSH LIKE MARA-MBRSH,
END OF ITAB.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
IN MATNR.
TYPE-POOLS SLIS.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVE TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
SORT-UP = 'X'.
SORT-SPOS = 1.
SORT-FIELDNAME = 'ERSDA'.
SORT-tabname = 'MARA'.
APPEND SORT.
SORT-SPOS = 2.
SORT-FIELDNAME = 'MTART'.
SORT-tabname = 'MARA'.
APPEND SORT.
EVE-NAME = 'TOP_OF_PAGE'.
EVE-FORM = 'TOPOFPAGE'.
APPEND EVE.
EVE-NAME = 'TOP_OF_LIST'.
EVE-FORM = 'TOPOFLIST'.
APPEND EVE.
EVE-NAME = 'END_OF_LIST'.
EVE-FORM = 'ENDOFLIST'.
APPEND EVE.
LAYOUT-ZEBRA = 'X'.
LAYOUT-no_hline = 'X'.
LAYOUT-NO_VLINE = 'X'.
LAYOUT-window_titlebar = 'MATERIAL DETAILS'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = FCAT
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_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
<b> I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'UCOMM'</b>
I_STRUCTURE_NAME =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = EVE[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 5
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 25
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
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 TOPOFPAGE.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM TOPOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTTOP'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM ENDOFLIST.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = 'MATERIALS-LISTEND'.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
<b>FORM STATUS USING MYMENU.
SET PF-STATUS 'MENU' excluding MYMENU.
ENDFORM.
FORM UCOMM USING CODE STEXT.
CASE CODE.
WHEN 'ABC'.
WRITE:/ 'YOU HAVE CLICKED ON ABC'.
WHEN 'XYZ'.
WRITE:/ 'YOU HAVE CLICKED ON XYZ'.
ENDCASE.
ENDFORM.</b>
rgds,
bharat. -
Hi Friends,
I have the following 2 problems in ALV report
1) Logo is not getting displayed in the report.
2) When i click on the Purchase order number in the report the interactive report is not working,i am not able to see report of First interactive level.
can you help it out friends.
Thanks and regards
Dinesh
REPORT YSDBALV1
tables: ekko , ekpo .
type-pools: slis .
Table for Display Header
data:i_header type slis_t_listheader with header line.
*Fieldcat Declaration
data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.
*Table of Events
data:i_event type slis_t_event with header line .
For Layout
data:i_layout type slis_layout_alv .
data: text(30) .
*Internal Table Declaration
data: begin of it_final occurs 0 ,
ebeln like ekko-ebeln , "Purchasing Document No.
bedat like ekko-bedat , "Purchasing Document Date
matnr like ekpo-matnr , "Material No.
netwr like ekpo-netwr , "Net Order Value in PO Currancy
meins like ekpo-meins , "UOM
chk(1) ,
light(1) ,
change like ekpo-menge ,
end of it_final .
**select option Declaration
selection-screen begin of block block.
select-options: s_ebeln for ekko-ebeln .
selection-screen end of block block .
selection-screen begin of block block1 .
parameters:grid radiobutton group r .
parameters:list radiobutton group r .
selection-screen end of block block1 .
at selection screen
at selection-screen .
select single * from ekko where ebeln in s_ebeln .
if sy-subrc <> 0 .
message e000(8I) WITH 'No Data Exists' .
endif .
start-of-selection .
if grid = 'X' .
perform get_data .
perform event using i_event[] .
perform field using fieldcatalog[] .
perform layout using i_layout .
perform grid_display .
endif .
*& Form get_data
text
--> p1 text
<-- p2 text
form get_data .
*DATA Retrieval from tables
SELECT EKKO~EBELN
EKKO~BEDAT
EKPO~EBELP
EKPO~MATNR
EKPO~NETWR
EKPO~MEINS
EKPO~MENGE
EKPO~BPRME
INTO CORRESPONDING FIELDS OF table IT_FINAL
FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
WHERE EKKO~EBELN IN S_EBELN.
APPEND IT_FINAL.
endform. " get_data
*Getting the Event for Top of Page display.
*& Form event
text
-->P_I_event[] text
form event using p_i_event type slis_t_event.
clear p_i_event .
refresh p_i_event .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = p_i_event
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
read table p_i_event with key name = slis_ev_top_of_page into i_event.
if sy-subrc = 0.
move 'TOP_OF_PAGE_PO' to i_event-form.
modify p_i_event from i_event index sy-tabix transporting form.
endif.
clear i_event.
endform. " event
*Display Top-of Page Details and Logo
form top_of_page_po .
clear i_header .
refresh i_header .
write sy-datum to text.
i_header-typ = 'H'.
i_header-info = 'PURCHASE OREDER DETAILS'.
append i_header.
*Logo Display
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header[]
I_LOGO = 'ENJOYSAPLOGO'.
endform .
*Field Catalog Append
*& Form field
text
-->P_fieldCATALOG[] text
form field using p_fieldcatalog type slis_t_fieldcat_alv.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order No'.
fieldcatalog-col_pos = 1.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'BEDAT'.
fieldcatalog-seltext_m = 'PO Date'.
fieldcatalog-col_pos = 2.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material No'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 20.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'NETWR'.
fieldcatalog-seltext_m = 'Net Value '.
fieldcatalog-col_pos = 5.
fieldcatalog-outputlen = 20.
fieldcatalog-do_sum = 'X'.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Units'.
fieldcatalog-col_pos = 6.
fieldcatalog-outputlen = 4.
append fieldcatalog .
clear fieldcatalog.
endform. " field
*& Form layout
text
form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .
i_layout-zebra = 'X'.
i_layout-lights_fieldname = 'LIGHT'.
i_layout-lights_tabname = 'IT_FINAL'.
i_layout-box_fieldname = 'CHK'.
i_layout-box_tabname = 'IT_FINAL'.
i_layout-edit = ' '.
endform.
*To display Buttons in the MENU BAR if needed
FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE
SLIS_T_EXTAB.
SET PF-STATUS 'MENUPO'.
ENDFORM.
*Event for Interactive display of ALV report
form USER_COMMAND using r_ucomm like sy-ucomm
rs_selfield type slis_selfield .
if r_ucomm = '&IC1'.
READ TABLE IT_FINAL index rs_selfield-tabindex.
write:/ IT_FINAL-ebeln.
endif.
endform .
*Parameters of FM REUSE_ALV_GRID_DISPLAY
*& Form grid_display
text
--> p1 text
<-- p2 text
form grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
IT_EVENTS = I_EVENT[]
TABLES
t_outtab = IT_FINAL.
endform. " grid_display*& Report YSDBALV1
REPORT YSDBALV1.
tables: ekko , ekpo .
type-pools: slis .
Table for Display Header
data:i_header type slis_t_listheader with header line.
*Fieldcat Declaration
data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.
*Table of Events
data:i_event type slis_t_event with header line ,
wa_event type line of slis_t_event.
For Layout
data:i_layout type slis_layout_alv .
data: text(30) .
*Internal Table Declaration
data: begin of it_final occurs 0 ,
ebeln like ekko-ebeln , "Purchasing Document No.
bedat like ekko-bedat , "Purchasing Document Date
matnr like ekpo-matnr , "Material No.
netwr like ekpo-netwr , "Net Order Value in PO Currancy
meins like ekpo-meins , "UOM
chk(1) ,
light(1) ,
change like ekpo-menge ,
end of it_final .
**select option Declaration
selection-screen begin of block block.
select-options: s_ebeln for ekko-ebeln .
selection-screen end of block block .
selection-screen begin of block block1 .
parameters:grid radiobutton group r .
parameters:list radiobutton group r .
selection-screen end of block block1 .
at selection screen
at selection-screen .
select single * from ekko where ebeln in s_ebeln .
if sy-subrc <> 0 .
message e000(8I) WITH 'No Data Exists' .
endif .
start-of-selection .
if grid = 'X' .
perform get_data .
perform event using i_event[] .
perform field using fieldcatalog[] .
perform layout using i_layout .
perform grid_display .
endif .
*& Form get_data
text
--> p1 text
<-- p2 text
form get_data .
*DATA Retrieval from tables
SELECT EKKO~EBELN
EKKO~BEDAT
EKPO~EBELP
EKPO~MATNR
EKPO~NETWR
EKPO~MEINS
EKPO~MENGE
EKPO~BPRME
INTO CORRESPONDING FIELDS OF table IT_FINAL
FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
WHERE EKKO~EBELN IN S_EBELN.
APPEND IT_FINAL.
endform. " get_data
*Getting the Event for Top of Page display.
*& Form event
text
-->P_I_event[] text
form event using p_i_event type slis_t_event.
clear p_i_event .
refresh p_i_event .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = p_i_event.
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
read table p_i_event with key name = slis_ev_top_of_page into wa_event.
if sy-subrc = 0.
move 'TOP_OF_PAGE_PO' to i_event-form.
modify p_i_event from i_event index sy-tabix transporting form.
endif.
clear i_event.
endform. " event
*Display Top-of Page Details and Logo
form top_of_page_po .
clear i_header .
refresh i_header .
write sy-datum to text.
i_header-typ = 'H'.
i_header-info = 'PURCHASE OREDER DETAILS'.
append i_header.
*Logo Display
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header[]
I_LOGO = 'ENJOYSAP_LOGO'.
endform .
*Field Catalog Append
*& Form field
text
-->P_fieldCATALOG[] text
form field using p_fieldcatalog type slis_t_fieldcat_alv.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order No'.
fieldcatalog-col_pos = 1.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'BEDAT'.
fieldcatalog-seltext_m = 'PO Date'.
fieldcatalog-col_pos = 2.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material No'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 20.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'NETWR'.
fieldcatalog-seltext_m = 'Net Value '.
fieldcatalog-col_pos = 5.
fieldcatalog-outputlen = 20.
fieldcatalog-do_sum = 'X'.
append fieldcatalog .
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Units'.
fieldcatalog-col_pos = 6.
fieldcatalog-outputlen = 4.
append fieldcatalog .
clear fieldcatalog.
endform. " field
*& Form layout
text
form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .
i_layout-zebra = 'X'.
i_layout-lights_fieldname = 'LIGHT'.
i_layout-lights_tabname = 'IT_FINAL'.
i_layout-box_fieldname = 'CHK'.
i_layout-box_tabname = 'IT_FINAL'.
i_layout-edit = ' '.
endform.
*To display Buttons in the MENU BAR if needed
FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE
SLIS_T_EXTAB.
SET PF-STATUS 'MENUPO'.
ENDFORM.
*Event for Interactive display of ALV report
form USER_COMMAND using r_ucomm like sy-ucomm
rs_selfield type slis_selfield .
if r_ucomm = '&IC1'.
READ TABLE IT_FINAL index rs_selfield-tabindex.
set parameter id 'VL1' field it_final-ebeln.
call transaction 'ME23N'.
endif.
endform .
*Parameters of FM REUSE_ALV_GRID_DISPLAY
*& Form grid_display
text
--> p1 text
<-- p2 text
form grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
IT_EVENTS = I_EVENT[]
TABLES
t_outtab = IT_FINAL.
endform. " grid_display
Regards,
Rusidar S. -
My ALV Report is taking too much time to execute
Hi Friends,
My ALV Report is taking long time for execution(more than 1.5 Hrs).Pls suggest the changes to be done to improove the performance.Its very urgent.Pls respond as soon as possible.
Thanks & Regards,
Sunil Maurya
Report is as follows :
REPORT YSEG_PROFIT.
TABLES : ZSEGMENT, coep.
TYPE-POOLS: slis.
DATA : BEGIN OF I_COEP OCCURS 0,
BELNR LIKE COEP-BELNR,
BUZEI LIKE COEP-BUZEI,
PERIO LIKE COEP-PERIO,
WOGBTR LIKE COEP-WOGBTR,
OBJNR LIKE COEP-OBJNR,
KSTAR LIKE COEP-KSTAR,
PAOBJNR LIKE COEP-PAOBJNR,
KVGR5 LIKE ZSEGMENT-KVGR5,
KAUFN LIKE CE4KBL1_ACCT-KAUFN,
END OF I_COEP.
DATA : BEGIN OF I_SECTOR OCCURS 0,
KVGR5 LIKE ZSEGMENT-KVGR5,
END OF I_SECTOR.
DATA : BEGIN OF I_AUFK OCCURS 0,
OBJNR LIKE AUFK-OBJNR,
PSPEL LIKE AUFK-PSPEL,
KDAUF LIKE AUFK-KDAUF,
KDPOS LIKE AUFK-KDPOS,
END OF I_AUFK.
DATA : BEGIN OF I_VBAKP OCCURS 0,
OBJNR LIKE VBAP-OBJNR,
KVGR5 LIKE VBAK-VBELN,
END OF I_VBAKP.
DATA : BEGIN OF I_PRPS OCCURS 0,
OBJNR LIKE PRPS-OBJNR,
PSPHI LIKE PRPS-PSPHI,
ASTNR LIKE PROJ-ASTNR,
END OF I_PRPS.
DATA : BEGIN OF I_OUTPUT OCCURS 0,
KSTAR LIKE COEP-KSTAR,
MCTXT LIKE CSKU-MCTXT,
S01 LIKE COEP-WOGBTR,
S02 LIKE COEP-WOGBTR,
S03 LIKE COEP-WOGBTR,
S04 LIKE COEP-WOGBTR,
S05 LIKE COEP-WOGBTR,
S06 LIKE COEP-WOGBTR,
S07 LIKE COEP-WOGBTR,
S08 LIKE COEP-WOGBTR,
S09 LIKE COEP-WOGBTR,
OTH like COEP-WOGBTR,
TOTAL LIKE COEP-WOGBTR,
END OF I_OUTPUT.
DATA : BEGIN OF I_AFVC OCCURS 0,
OBJNR LIKE AFVC-OBJNR,
PROJN LIKE AFVC-PROJN,
PROJ LIKE PROJ-PSPID,
PSPNR LIKE PROJ-PSPNR,
END OF I_AFVC.
DATA : BEGIN OF I_PROJ OCCURS 0,
PSPNR LIKE PROJ-PSPNR,
ASTNR LIKE PROJ-ASTNR,
END OF I_PROJ.
DATA : I_NP LIKE STANDARD TABLE OF I_COEP WITH HEADER LINE.
DATA : I_NV LIKE STANDARD TABLE OF I_COEP WITH HEADER LINE.
DATA : I_DETAIL LIKE STANDARD TABLE OF I_COEP WITH HEADER LINE.
DATA : I_WB LIKE STANDARD TABLE OF I_COEP WITH HEADER LINE.
DATA : I_PR LIKE STANDARD TABLE OF I_COEP WITH HEADER LINE.
data : t_fieldcat_sum_rep TYPE slis_t_fieldcat_alv.
data : t_fieldcat_det_rep TYPE slis_t_fieldcat_alv.
DATA: k_fieldcat TYPE slis_fieldcat_alv.
Declaration by Sunil Maurya for sorting
DATA : GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_SORT TYPE SLIS_SORTINFO_ALV.
DATA : GT_SORT1 TYPE SLIS_T_SORTINFO_ALV,
GS_SORT1 TYPE SLIS_SORTINFO_ALV.
*data : it_sortcat type slis_t_sortinfo_alv.
*DATA : k_sortcat like line of it_sortcat.
**data : wa_sort like line of it_sortcat.
Declaration by Sunil Maurya for sorting
constants : c_user_command TYPE char30 VALUE 'USER_COMMAND'.
*Selection screen
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
PARAMETER : P_PERIO1 LIKE COEP-PERIO obligatory,
P_PERIO2 LIKE COEP-PERIO MODIF ID D1,
P_GJAHR LIKE COEP-GJAHR obligatory.
select-options : P_KSTAR for COEP-KSTAR,
P_GSBER FOR COEP-GSBER.
SELECT-OPTIONS : S_KVGR5 FOR ZSEGMENT-KVGR5 MODIF ID D1.
SELECTION-SCREEN END OF BLOCK A.
INITIALIZATION.
S_KVGR5-OPTION = 'BT' .
S_KVGR5-LOW = 'S01'.
S_KVGR5-HIGH = 'S09'.
APPEND S_KVGR5.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'D1'.
SCREEN-INPUT = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
PERFORM GET_SECTORS.
PERFORM GET_DATA_COEP.
PERFORM VALIDATE_SECTOR.
PERFORM GROUP_OUTPUT.
PERFORM BUILD_SORTCAT. " Inserted by by Sunil Maurya for sorting
PERFORM BUILD_CATLOG.
PERFORM DISPLAY_OUTPUT.
*& Form GET_DATA_COEP
text
--> p1 text
<-- p2 text
FORM GET_DATA_COEP .
SELECT BELNR BUZEI PERIO WOGBTR OBJNR KSTAR PAOBJNR
FROM COEP INTO TABLE I_COEP WHERE
KOKRS = 'KBL' AND
PERIO >= P_PERIO1 AND
PERIO <= P_PERIO2 AND
PERIO = P_PERIO1 AND
GJAHR = P_GJAHR AND
KSTAR NE '' AND
OBJNR NE '' AND
KSTAR in P_KSTAR AND
GSBER IN P_GSBER. "AND
BELNR = '0103991827' .
SORT I_COEP BY OBJNR.
DELETE I_COEP WHERE OBJNR+0(2) <> 'VB' AND
OBJNR+0(2) <> 'PR' AND
OBJNR+0(2) <> 'NV' AND
OBJNR+0(2) <> 'NP' AND
OBJNR+0(2) <> 'AO'.
SORT I_COEP BY KSTAR.
DELETE I_COEP WHERE KSTAR+0(5) <> '00003' AND
KSTAR+0(5) <> '00004'.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'NP'.
MOVE I_COEP TO I_NP.
APPEND I_NP.
CLEAR : I_NP, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'NV'.
MOVE I_COEP TO I_NV.
APPEND I_NV.
CLEAR : I_NV, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'VB' .
MOVE I_COEP TO I_WB.
APPEND I_WB.
CLEAR : I_WB, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'PR' .
MOVE I_COEP TO I_PR.
APPEND I_PR.
CLEAR : I_PR, I_COEP.
ENDLOOP.
*Inserted by Sunil Maurya for PAOBJNR = "AO....."
Data : ind type sy-tabix.
loop at i_coep where OBJNR+0(2) = 'AO'.
ind = sy-tabix.
select single KAUFN into i_coep-KAUFN from CE4KBL1_ACCT where PAOBJNR =
i_coep-PAOBJNR.
select single KVGR5 into i_coep-kvgr5 from vbak where vbeln =
i_coep-kaufn.
modify i_coep index ind.
clear i_coep.
endloop.
*Inserted by Sunil Maurya for PAOBJNR = "AO....."
*LOOP AT I_COEP WHERE OBJNR+0(2) = 'AO' .
MOVE I_COEP TO I_AO.
APPEND I_AO.
CLEAR : I_AO, I_COEP.
*ENDLOOP.
ENDFORM. " GET_DATA_COEP
*& Form GET_SECTORS
text
--> p1 text
<-- p2 text
FORM GET_SECTORS .
DATA : L_FR TYPE I,
L_TO TYPE I.
DATA : L_CH1(1).
LOOP AT S_KVGR5.
IF S_KVGR5-OPTION = 'EQ'.
I_SECTOR-KVGR5 = S_KVGR5-LOW.
APPEND I_SECTOR.
CLEAR : I_SECTOR.
CONCATENATE '5' S_KVGR5-LOW+1(2) INTO I_SECTOR-KVGR5.
APPEND I_SECTOR.
CLEAR : I_SECTOR.
ENDIF.
IF S_KVGR5-OPTION = 'BT'.
L_FR = S_KVGR5-LOW+1(2).
L_TO = S_KVGR5-HIGH+1(2).
WHILE L_FR <= L_TO.
L_CH1 = L_FR.
CONCATENATE 'S0' L_CH1 INTO I_SECTOR-KVGR5.
APPEND I_SECTOR.
CONCATENATE '50' L_CH1 INTO I_SECTOR-KVGR5.
APPEND I_SECTOR.
CLEAR : I_SECTOR, L_CH1.
L_FR = L_FR + 1.
ENDWHILE.
ENDIF.
ENDLOOP.
ENDFORM. " GET_SECTORS
*& Form VALIDATE_SECTOR
text
--> p1 text
<-- p2 text
FORM VALIDATE_SECTOR .
*get data from AUFK for NP & NV type intab
IF I_NP[] IS NOT INITIAL.
SELECT OBJNR PSPEL KDAUF KDPOS FROM AUFK
INTO TABLE I_AUFK
FOR ALL ENTRIES IN I_NP
WHERE OBJNR = I_NP-OBJNR.
*Push this data in I_WB where order no exist in AUFK
LOOP AT I_AUFK WHERE KDAUF NE ''.
I_WB-OBJNR = I_AUFK-OBJNR.
APPEND I_WB.
CLEAR : I_AUFK, I_WB.
ENDLOOP.
*Push this data in I_PR where order no exist in AUFK
LOOP AT I_AUFK WHERE PSPEL NE ''.
I_PR-OBJNR = I_AUFK-OBJNR.
APPEND I_PR.
CLEAR : I_AUFK, I_PR.
ENDLOOP.
ENDIF.
SELECT BOBJNR AKVGR5 FROM VBAK AS A INNER JOIN VBAP AS B
ON AVBELN = BVBELN
INTO TABLE I_VBAKP
FOR ALL ENTRIES IN I_WB
WHERE B~VBELN = I_WB-OBJNR+2(10).
SORT I_VBAKP BY OBJNR.
SORT I_COEP BY OBJNR.
LOOP AT I_WB.
READ TABLE I_VBAKP WITH KEY OBJNR = I_WB-OBJNR.
IF SY-SUBRC = 0.
READ TABLE I_SECTOR WITH KEY KVGR5 = I_VBAKP-KVGR5.
IF SY-SUBRC <> 0.
DELETE I_COEP WHERE OBJNR = I_WB-OBJNR.
loop at i_coep where objnr = i_wb-objnr.
i_coep-kvgr5 = 'OTH'.
modify i_coep.
clear : i_coep.
endloop.
ELSE.
READ TABLE I_COEP WITH KEY BELNR = I_WB-BELNR BUZEI = I_WB-BUZEI.
READ TABLE I_COEP WITH KEY OBJNR = I_WB-OBJNR.
IF SY-SUBRC = 0.
I_COEP-KVGR5 = I_SECTOR-KVGR5.
MODIFY I_COEP INDEX SY-TABIX.
LOOP AT I_COEP WHERE OBJNR = I_WB-OBJNR.
I_COEP-KVGR5 = I_SECTOR-KVGR5.
MODIFY I_COEP.
CLEAR : I_COEP.
ENDLOOP.
ENDIF.
ENDIF.
ELSE.
DELETE I_COEP WHERE OBJNR = I_WB-OBJNR.
loop at i_coep where objnr = i_wb-objnr.
i_coep-kvgr5 = 'OTH'.
modify i_coep.
clear : i_coep.
endloop.
ENDIF.
CLEAR : I_VBAKP, I_SECTOR, I_COEP.
ENDLOOP.
IF I_PR[] IS NOT INITIAL.
SELECT AOBJNR APSPHI B~ASTNR
FROM PRPS AS A INNER JOIN PROJ AS B
ON APSPHI = BPSPNR
INTO TABLE I_PRPS
FOR ALL ENTRIES IN I_PR
WHERE A~OBJNR = I_PR-OBJNR.
ENDIF.
IF I_NV[] IS NOT INITIAL.
SELECT OBJNR PROJN FROM AFVC INTO TABLE I_AFVC
FOR ALL ENTRIES IN I_NV
WHERE OBJNR = I_NV-OBJNR AND
PROJN <> '' .
LOOP AT I_AFVC.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
INPUT = I_AFVC-PROJN
IMPORTING
OUTPUT = I_AFVC-PROJ
I_AFVC-PROJ = I_AFVC-PROJ+0(9).
CALL FUNCTION 'CONVERSION_EXIT_KONPD_INPUT'
EXPORTING
INPUT = I_AFVC-PROJ
IMPORTING
OUTPUT = I_AFVC-PSPNR.
MODIFY I_AFVC.
CLEAR : I_AFVC.
ENDLOOP.
SELECT PSPNR ASTNR FROM PROJ INTO TABLE I_PROJ
FOR ALL ENTRIES IN I_AFVC
WHERE PSPNR = I_AFVC-PSPNR.
LOOP AT I_NV.
I_PRPS-OBJNR = I_NV-OBJNR.
READ TABLE I_AFVC WITH KEY OBJNR = I_NV-OBJNR.
IF SY-SUBRC = 0.
READ TABLE I_PROJ WITH KEY PSPNR = I_AFVC-PSPNR.
IF SY-SUBRC = 0.
I_PRPS-ASTNR = I_PROJ-ASTNR.
ENDIF.
ENDIF.
APPEND I_PRPS.
I_PR-OBJNR = I_NV-OBJNR.
APPEND I_PR.
CLEAR : I_NV, I_AFVC, I_PROJ, I_PR.
ENDLOOP.
ENDIF.
SORT I_PRPS BY OBJNR.
LOOP AT I_PR.
READ TABLE I_PRPS WITH KEY OBJNR = I_PR-OBJNR.
IF SY-SUBRC = 0.
READ TABLE I_SECTOR WITH KEY KVGR5 = I_PRPS-ASTNR+5(3).
IF SY-SUBRC <> 0.
DELETE I_COEP WHERE OBJNR = I_PR-OBJNR.
loop at i_coep where objnr = i_pr-objnr.
i_coep-kvgr5 = 'OTH'.
modify i_coep.
clear : i_coep.
endloop.
ELSE.
READ TABLE I_COEP WITH KEY OBJNR = I_PR-OBJNR.
IF SY-SUBRC = 0.
CONCATENATE 'S' I_SECTOR-KVGR5+1(2) INTO I_COEP-KVGR5.
MODIFY I_COEP INDEX SY-TABIX.
LOOP AT I_COEP WHERE OBJNR = I_PR-OBJNR.
CONCATENATE 'S' I_SECTOR-KVGR5+1(2) INTO I_COEP-KVGR5.
MODIFY I_COEP.
CLEAR : I_COEP.
ENDLOOP.
ENDIF.
ENDIF.
ELSE.
DELETE I_COEP WHERE OBJNR = I_PR-OBJNR.
loop at i_coep where objnr = i_pr-objnr.
i_coep-kvgr5 = 'OTH'.
modify i_coep.
clear : i_coep.
endloop.
ENDIF.
CLEAR : I_PR, I_PRPS, I_SECTOR, I_COEP.
ENDLOOP.
ENDFORM. " VALIDATE_SECTOR
*& Form GROUP_OUTPUT
text
--> p1 text
<-- p2 text
FORM GROUP_OUTPUT .
LOOP AT I_COEP.
I_OUTPUT-KSTAR = I_COEP-KSTAR.
IF I_COEP-KVGR5 = 'S01'.
I_OUTPUT-S01 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S02'.
I_OUTPUT-S02 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S03'.
I_OUTPUT-S03 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S04'.
I_OUTPUT-S04 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S05'.
I_OUTPUT-S05 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S06'.
I_OUTPUT-S06 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S07'.
I_OUTPUT-S07 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S08'.
I_OUTPUT-S08 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'S09'.
I_OUTPUT-S09 = I_COEP-WOGBTR.
ENDIF.
IF I_COEP-KVGR5 = 'OTH' OR I_COEP-KVGR5 = ''.
I_OUTPUT-OTH = I_COEP-WOGBTR.
ENDIF.
COLLECT I_OUTPUT.
CLEAR : I_COEP, I_OUTPUT.
ENDLOOP.
LOOP AT I_OUTPUT.
SELECT SINGLE MCTXT FROM CSKU
INTO I_OUTPUT-MCTXT
WHERE KTOPL = 'KBL' AND
SPRAS = SY-LANGU AND
KSTAR = I_OUTPUT-KSTAR.
I_OUTPUT-TOTAL = I_OUTPUT-S01 + I_OUTPUT-S02 + I_OUTPUT-S03
+ I_OUTPUT-S04 + I_OUTPUT-S05 + I_OUTPUT-S06
+ I_OUTPUT-S07 + I_OUTPUT-S08 + I_OUTPUT-S09
+ I_OUTPUT-OTH.
MODIFY I_OUTPUT.
CLEAR : I_OUTPUT.
ENDLOOP.
ENDFORM. " GROUP_OUTPUT
*& Form BUILD_CATLOG
text
--> p1 text
<-- p2 text
FORM BUILD_CATLOG .
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'KSTAR'.
k_fieldcat-seltext_l = text-002.
k_fieldcat-hotspot = 'X'.
APPEND k_fieldcat TO t_fieldcat_sum_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'MCTXT'.
k_fieldcat-seltext_l = text-003.
k_fieldcat-hotspot = 'X'.
APPEND k_fieldcat TO t_fieldcat_sum_rep.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S01'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S01'.
k_fieldcat-seltext_l = text-004.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S02'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S02'.
k_fieldcat-seltext_l = text-005.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S03'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S03'.
k_fieldcat-seltext_l = text-006.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S04'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S04'.
k_fieldcat-seltext_l = text-007.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S05'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S05'.
k_fieldcat-seltext_l = text-008.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S06'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S06'.
k_fieldcat-seltext_l = text-009.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S07'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S07'.
k_fieldcat-seltext_l = text-010.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S08'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S08'.
k_fieldcat-seltext_l = text-011.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
READ TABLE I_SECTOR WITH KEY KVGR5 = 'S09'.
IF SY-SUBRC = 0.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'S09'.
k_fieldcat-seltext_l = text-012.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
ENDIF.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'OTH'.
k_fieldcat-seltext_l = text-019.
k_fieldcat-hotspot = 'X'.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'TOTAL'.
k_fieldcat-seltext_l = text-020.
k_fieldcat-do_sum = 'X'. "Statement inserted by Sunil Maurya
APPEND k_fieldcat TO t_fieldcat_sum_rep.
*=======================================================================
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'BELNR'.
k_fieldcat-seltext_l = text-013.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'BUZEI'.
k_fieldcat-seltext_l = text-014.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'PERIO'.
k_fieldcat-seltext_l = text-015.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'WOGBTR'.
k_fieldcat-seltext_l = text-016.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'OBJNR'.
k_fieldcat-seltext_l = text-018.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'KSTAR'.
k_fieldcat-seltext_l = text-002.
APPEND k_fieldcat TO t_fieldcat_det_rep.
CLEAR k_fieldcat.
k_fieldcat-fieldname = 'KVGR5'.
k_fieldcat-seltext_l = text-017.
APPEND k_fieldcat TO t_fieldcat_det_rep.
*==============================================================
Statements inserted by Sunil Maurya for sorting
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'KSTAR'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT1.
GS_SORT1-FIELDNAME = 'KSTAR'.
GS_SORT1-SPOS = 1.
GS_SORT1-UP = 'X'.
GS_SORT1-SUBTOT = 'X'.
APPEND GS_SORT1 TO GT_SORT1.
*CLEAR GS_SORT1.
*GS_SORT1-FIELDNAME = 'WOGBTR'.
*GS_SORT1-SPOS = 2.
*GS_SORT1-UP = 'X'.
*GS_SORT1-SUBTOT = 'X'.
*APPEND GS_SORT1 TO GT_SORT1.
FORM build_sortcat.
k_sortcat-spos = 1.
k_sortcat-fieldname = 'KSTAR'.
k_sortcat-up = 'X'.
k_sortcat-down = 'X'.
APPEND k_sortcat TO it_sortcat.
clear k_sortcat.
ENDFORM.
Statements inserted by Sunil Maurya for sorting
ENDFORM. " BUILD_CATLOG
*& Form DISPLAY_OUTPUT
text
--> p1 text
<-- p2 text
FORM DISPLAY_OUTPUT .
DATA l_repid TYPE syrepid.
l_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
it_fieldcat = t_fieldcat_sum_rep
i_callback_user_command = c_user_command
i_save = 'A'
it_sort = GT_SORT[] "Statements inserted by Sunil
TABLES
t_outtab = I_OUTPUT
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " DISPLAY_OUTPUT
*& Form user_command
text
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: l_repid TYPE syrepid.
l_repid = sy-repid.
CASE r_ucomm.
WHEN '&IC1'.
clear : i_detail. refresh : i_detail.
LOOP AT I_COEP WHERE KVGR5 = rs_selfield-fieldname.
MOVE i_coep to i_detail.
append i_detail.
clear : i_detail, i_coep.
endloop.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
it_fieldcat = t_fieldcat_det_rep
i_callback_user_command = c_user_command
i_save = 'A'
it_sort = GT_SORT1[] "Inserted by Sunil
TABLES
t_outtab = i_detail
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.
ENDCASE.
ENDFORM.Run the SE30 with internal tables, then examine the top lines.
see
SE30
The ABAP Runtime Trace (SE30) - Quick and Easy
Define you tables as sorted tables or use at least binary search, otherwise this sorts are useless
and the nested loop is slow.
SORT I_VBAKP BY OBJNR.
SORT I_COEP BY OBJNR.
LOOP AT I_WB.
READ TABLE I_VBAKP WITH KEY OBJNR = I_WB-OBJNR.
IF SY-SUBRC = 0.
READ TABLE I_SECTOR WITH KEY KVGR5 = I_VBAKP-KVGR5.
IF SY-SUBRC 0.
DELETE I_COEP WHERE OBJNR = I_WB-OBJNR.
loop at i_coep where objnr = i_wb-objnr.
i_coep-kvgr5 = 'OTH'.
modify i_coep.
clear : i_coep.
endloop.
ELSE.
READ TABLE I_COEP WITH KEY BELNR = I_WB-BELNR BUZEI = I_WB-BUZEI.
READ TABLE I_COEP WITH KEY OBJNR = I_WB-OBJNR.
IF SY-SUBRC = 0.
I_COEP-KVGR5 = I_SECTOR-KVGR5.
MODIFY I_COEP INDEX SY-TABIX.
LOOP AT I_COEP WHERE OBJNR = I_WB-OBJNR.
I_COEP-KVGR5 = I_SECTOR-KVGR5.
MODIFY I_COEP.
CLEAR : I_COEP.
ENDLOOP.
This is all very slow.
Read my blog on internal tables:
Measurements on internal tables: Reads and Loops:
Runtimes of Reads and Loops on Internal Tables
If you really wnat to identify all bugs, then try this
Z_SE30_COMPARE
A Tool to Compare Runtime Measurements: Z_SE30_COMPARE
Nonlinearity Check
Nonlinearity Check Using the Z_SE30_COMPARE
It needs at bit of experience but then it is very powerful!!!
That is also a waste of time, but not a nested loop. You sort and resort the same table,
but the sort is useless the deletes are still sequential on standard tables.
Put all the stuff into ONE loop on I_COEP.
SORT I_COEP BY OBJNR.
DELETE I_COEP WHERE OBJNR+0(2) <> 'VB' AND
OBJNR+0(2) <> 'PR' AND
OBJNR+0(2) <> 'NV' AND
OBJNR+0(2) <> 'NP' AND
OBJNR+0(2) <> 'AO'.
SORT I_COEP BY KSTAR.
DELETE I_COEP WHERE KSTAR+0(5) <> '00003' AND
KSTAR+0(5) <> '00004'.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'NP'.
MOVE I_COEP TO I_NP.
APPEND I_NP.
CLEAR : I_NP, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'NV'.
MOVE I_COEP TO I_NV.
APPEND I_NV.
CLEAR : I_NV, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'VB' .
MOVE I_COEP TO I_WB.
APPEND I_WB.
CLEAR : I_WB, I_COEP.
ENDLOOP.
LOOP AT I_COEP WHERE OBJNR+0(2) = 'PR' .
MOVE I_COEP TO I_PR.
APPEND I_PR.
CLEAR : I_PR, I_COEP.
ENDLOOP.
There is probably more. BBut with the compare tool you can find everything.
Siegfried -
Alv Report for invoice details
Dear All,
I need to develop one alv report for following details. i developed coding for this requirment but i am getting some error.kindley help me to how to move data from different internal table to final internal table. I used LOOP AT and READ Statement even i didn't get any output.
kindley help me out.
TYPES: BEGIN OF XT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD1 LIKE LFA1-STCD1,
STCD2 LIKE LFA1-STCD2,
STCD3 LIKE LFA1-STCD3,
STCD4 LIKE LFA1-STCD4,
END OF XT_TAB.
TYPES: BEGIN OF YT_TAB,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
GJAHR LIKE BSEG-GJAHR,
END OF YT_TAB.
TYPES: BEGIN OF ZT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD2 LIKE LFA1-STCD2,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
GJAHR LIKE BSEG-GJAHR,
END OF ZT_TAB.
I N T E R N A L T A B L E D E C L A R A T I O N S *
*-----Internal table to store data
DATA: ITAB1 TYPE STANDARD TABLE OF XT_TAB INITIAL SIZE 0,
WA_TAB1 TYPE XT_TAB.
DATA: ITAB2 TYPE STANDARD TABLE OF YT_TAB INITIAL SIZE 0,
WA_TAB2 TYPE YT_TAB.
DATA: ITAB TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE,
WA_ITAB TYPE ZT_TAB,
ITAB_FINAL2 TYPE STANDARD TABLE OF ZT_TAB.
DATA: ITAB_TEMP1 TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE.
Selection Screen Declarations *
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN begin OF LINE.
SELECTION-SCREEN COMMENT (23) text-003 FOR FIELD P_LIFNR.
PARAMETERS P_LIFNR LIKE LFA1-LIFNR OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
PERFORM XTRACT_DATA.
END-OF-SELECTION.
*-----Filling the Output table
PERFORM populate_main_table.
PERFORM BUILD_FIELDCATALOG.
PERFORM SORTING.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_ALV_GRID_DISPLAY.
Form XTRACT_DATA
FORM XTRACT_DATA .
*SELECT
a~LIFNR
a~NAME1
a~STCD2
b~BELNR
b~BUZEI
b~GJAHR
INTO TABLE ITAB
FROM LFA1 as a INNER JOIN BSEG as b
ON aLIFNR = bLIFNR
WHERE a~LIFNR = P_LIFNR.
SELECT LIFNR
NAME1
STCD1
STCD2
STCD3
STCD4
FROM LFA1
INTO TABLE ITAB1
WHERE LIFNR = P_LIFNR.
IF NOT ITAB1[] IS INITIAL.
SORT ITAB1 BY LIFNR.
SELECT BELNR
BUZEI
LIFNR
GJAHR
INTO TABLE ITAB2
FROM BSEG
FOR ALL ENTRIES IN ITAB1
WHERE LIFNR = ITAB1-LIFNR.
ENDIF.
ENDFORM. " XTRACT_DATA
*& Form POPULATE_MAIN_TABLE
text
--> p1 text
<-- p2 text
FORM POPULATE_MAIN_TABLE .
LOOP AT ITAB1 INTO WA_TAB1.
ITAB-LIFNR = ITAB1-LIFNR.
ITAB-NAME1 = ITAB1-NAME1.
ITAB-STCD2 = ITAB1-STCD2.
READ TABLE ITAB2 INTO WA_TAB2 WITH KEY LIFNR = WA_TAB1-LIFNR.
IF sy-subrc = 0.
ITAB-BELNR = ITAB1-BELNR.
ITAB-BUZEI = ITAB1-BUZEI.
ITAB-GJAHR = ITAB1-GJAHR.
ENDIF.
ENDLOOP.
ENDFORM. " POPULATE_MAIN_TABLE
Form BUILD_FIELDCATALOG
FORM BUILD_FIELDCATALOG .
REFRESH t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 1.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Number'.
wa_fcat-seltext_m = 'Vendor Number'.
wa_fcat-seltext_l = 'Vendor Number'.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 2.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Name'.
wa_fcat-seltext_m = 'Vendor Name'.
wa_fcat-seltext_l = 'Vendor Name'.
wa_fcat-fieldname = 'NAME1'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 3.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor TIN Number'.
wa_fcat-seltext_m = 'Vendor TIN Number'.
wa_fcat-seltext_l = 'Vendor TIN Number'.
wa_fcat-fieldname = 'STCD2'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 4.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Document No'.
wa_fcat-seltext_m = 'Document No'.
wa_fcat-seltext_l = 'Document No'.
wa_fcat-fieldname = 'BELNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 5.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Item Number'.
wa_fcat-seltext_m = 'Item Number'.
wa_fcat-seltext_l = 'Item Number'.
wa_fcat-fieldname = 'BUZEI'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 6.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Fiscal Year'.
wa_fcat-seltext_m = 'Fiscal Year'.
wa_fcat-seltext_l = 'Fiscal Year'.
wa_fcat-fieldname = 'GJAHR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
ENDFORM. " BUILD_FIELDCATALOG
Form BUILD_LAYOUT
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'TOTALS'.
ENDFORM. " BUILD_LAYOUT
Form BUILD_ALV_GRID_DISPLAY
FORM BUILD_ALV_GRID_DISPLAY .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
is_layout = gd_layout
it_fieldcat = t_fcat[]
it_events = gt_events
is_print = gd_prntparams
it_sort = it_sortcat[]
i_save = 'X'
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
OTHERS = 2.
thanks and regards
MurugeshTYPES: BEGIN OF XT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD1 LIKE LFA1-STCD1,
STCD2 LIKE LFA1-STCD2,
STCD3 LIKE LFA1-STCD3,
STCD4 LIKE LFA1-STCD4,
END OF XT_TAB.
TYPES: BEGIN OF YT_TAB,
BUKRS LIKE BSEG-BUKRS,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
LIFNR LIKE BSEG-LIFNR,
GJAHR LIKE BSEG-GJAHR,
END OF YT_TAB.
TYPES: BEGIN OF ZT_TAB,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
STCD2 LIKE LFA1-STCD2,
BELNR LIKE BSEG-BELNR,
BUZEI LIKE BSEG-BUZEI,
GJAHR LIKE BSEG-GJAHR,
END OF ZT_TAB.
I N T E R N A L T A B L E D E C L A R A T I O N S *
*-----Internal table to store data
DATA: ITAB1 TYPE STANDARD TABLE OF XT_TAB INITIAL SIZE 0,
WA_TAB1 TYPE XT_TAB.
DATA: ITAB2 TYPE STANDARD TABLE OF YT_TAB INITIAL SIZE 0,
WA_TAB2 TYPE YT_TAB.
DATA: ITAB TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE,
WA_ITAB TYPE ZT_TAB,
ITAB_FINAL2 TYPE STANDARD TABLE OF ZT_TAB.
DATA: ITAB_TEMP1 TYPE STANDARD TABLE OF ZT_TAB WITH HEADER LINE.
Selection Screen Declarations *
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN begin OF LINE.
SELECTION-SCREEN COMMENT (23) text-003 FOR FIELD P_LIFNR.
PARAMETERS P_LIFNR LIKE LFA1-LIFNR OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
PERFORM XTRACT_DATA.
END-OF-SELECTION.
*-----Filling the Output table
PERFORM populate_main_table.
PERFORM BUILD_FIELDCATALOG.
PERFORM SORTING.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_ALV_GRID_DISPLAY.
Form XTRACT_DATA
FORM XTRACT_DATA .
*SELECT
a~LIFNR
a~NAME1
a~STCD2
b~BELNR
b~BUZEI
b~GJAHR
INTO TABLE ITAB
FROM LFA1 as a INNER JOIN BSEG as b
ON aLIFNR = bLIFNR
WHERE a~LIFNR = P_LIFNR.
SELECT LIFNR
NAME1
STCD1
STCD2
STCD3
STCD4
FROM LFA1
INTO TABLE ITAB1
WHERE LIFNR = P_LIFNR.
IF NOT ITAB1[] IS INITIAL.
SORT ITAB1 BY LIFNR.
SELECT BELNR
BUZEI
LIFNR
GJAHR
INTO TABLE ITAB2
FROM BSEG
FOR ALL ENTRIES IN ITAB1
WHERE LIFNR = itab1-lifnr.
ENDIF.
ENDFORM. " XTRACT_DATA
*& Form POPULATE_MAIN_TABLE
text
--> p1 text
<-- p2 text
FORM POPULATE_MAIN_TABLE .
LOOP AT ITAB1 INTO WA_TAB1.
ITAB-LIFNR = ITAB1-LIFNR.
ITAB-NAME1 = ITAB1-NAME1.
ITAB-STCD2 = ITAB1-STCD2.
READ TABLE ITAB2 INTO WA_TAB2 WITH KEY LIFNR = WA_TAB1-LIFNR.
IF sy-subrc = 0.
ITAB-BELNR = ITAB1-BELNR.
ITAB-BUZEI = ITAB1-BUZEI.
ITAB-GJAHR = ITAB1-GJAHR.
ENDIF.
ENDLOOP.
LOOP AT itab1 INTO wa_tab1.
MOVE: wa_tab1-lifnr TO itab-lifnr,
wa_tab1-name1 TO itab-name1,
wa_tab1-stcd2 TO itab-stcd2.
Append itab.
READ TABLE itab2 TRANSPORTING NO FIELDS WITH KEY lifnr = wa_tab1-lifnr.
IF sy-subrc eq 0.
MOVE: wa_tab2-lifnr TO itab-lifnr,
wa_tab2-belnr TO itab-belnr,
wa_tab2-buzei TO itab-buzei,
wa_tab2-gjahr TO itab-gjahr.
Append itab.
endif.
endloop.
*LOOP AT t_agr_tcodes INTO s_agr_tcodes.
READ TABLE t_tstc
TRANSPORTING NO FIELDS
WITH KEY tcode = s_agr_tcodes-tcode.
IF sy-subrc eq 0.
MOVE: s_agr_tcodes-tcode TO it_agr_tcodes-tcode,
s_agr_tcodes-agr_name to it_agr_tcodes-agr_name,
t_tstc-pgmna to it_agr_pgmna.
*Append it_agr_tcodes.
*endif.
*endloop.
ENDFORM. " POPULATE_MAIN_TABLE
Form BUILD_FIELDCATALOG
FORM BUILD_FIELDCATALOG .
REFRESH t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 1.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Number'.
wa_fcat-seltext_m = 'Vendor Number'.
wa_fcat-seltext_l = 'Vendor Number'.
wa_fcat-fieldname = 'LIFNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 2.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor Name'.
wa_fcat-seltext_m = 'Vendor Name'.
wa_fcat-seltext_l = 'Vendor Name'.
wa_fcat-fieldname = 'NAME1'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 3.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Vendor TIN Number'.
wa_fcat-seltext_m = 'Vendor TIN Number'.
wa_fcat-seltext_l = 'Vendor TIN Number'.
wa_fcat-fieldname = 'STCD2'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 4.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Document No'.
wa_fcat-seltext_m = 'Document No'.
wa_fcat-seltext_l = 'Document No'.
wa_fcat-fieldname = 'BELNR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 5.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Item Number'.
wa_fcat-seltext_m = 'Item Number'.
wa_fcat-seltext_l = 'Item Number'.
wa_fcat-fieldname = 'BUZEI'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
wa_fcat-col_pos = 6.
wa_fcat-row_pos = 1.
wa_fcat-seltext_s = 'Fiscal Year'.
wa_fcat-seltext_m = 'Fiscal Year'.
wa_fcat-seltext_l = 'Fiscal Year'.
wa_fcat-fieldname = 'GJAHR'.
wa_fcat-tabname = 'ITAB'.
APPEND wa_fcat TO t_fcat.
CLEAR t_fcat.
ENDFORM. " BUILD_FIELDCATALOG
Form BUILD_LAYOUT
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'TOTALS'.
ENDFORM. " BUILD_LAYOUT
Form BUILD_ALV_GRID_DISPLAY
FORM BUILD_ALV_GRID_DISPLAY .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
is_layout = gd_layout
it_fieldcat = t_fcat[]
it_events = gt_events
is_print = gd_prntparams
it_sort = it_sortcat[]
i_save = 'X'
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
OTHERS = 2.
Edited by: Murugesh P on Apr 6, 2009 10:54 AM
Edited by: Murugesh P on Apr 6, 2009 10:54 AM -
ALV Report for Purchasing Each Vendor
Hi Anybody,
I am developing Purchasing Report. But I want display records in ALV Report based Vendor ID and Name.
Like Standard Report ME2M.
Ex:
Vendor ID : A0002 Name : UMS SEMICONDUCTOR PTE LTD.,
sNO po no item Price Qty
1. 10001 10 12.30 10
2. 10002 20 30.30 50
3. 10003 30 40.30 150
Vendor ID : X0012 Name : ALPHA PTE LTD.,
sNO po no item Price Qty
1. 10004 10 1.30 10
2. 10005 20 50.30 50
3. 10006 30 620.30 150
How to I will do?. Anybody please tell me.
Tks
S.Muthu.
IT Dept.hi..follow this code..
===================================================================
===================================================================
report .
========================== Global definitions ====================
Data Types
type-pools: slis.
types: begin of tp_data,
lifnr like ekko-lifnr,
end of tp_data,
tp_tbl_data type standard table of tp_data.
Constants
Data objects (variable declarations and definitions)
Report data to be shown.
data: it_data type standard table of tp_data.
Heading of the report.
data: t_heading type slis_t_listheader.
======================= Selection Screen ==========================
selection-screen: begin of block b1 with frame title text-t01.
DATA: w_aux_lifnr like ekko-lifnr.
SELECT-OPTIONS s_lifnr for w_aux_lifnr
DEFAULT LIFNR .
selection-screen: end of block b1.
======================== Event Blocks =============================
at selection-screen.
start-of-selection.
perform get_data using it_data.
end-of-selection.
perform build_alv using it_data t_heading.
======================== Subroutines ==============================
*& Form get_data
Gets the information to be shown in the report.
form get_data using t_data type tp_tbl_data.
SELECT ekko~lifnr
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM ekko as ekko
WHERE ekko~lifnr in s_lifnr
endform. " get_data
*& Form build_alv
Builds and display the ALV Grid.
form build_alv using t_data type tp_tbl_data
t_heading type slis_t_listheader.
ALV required data objects.
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_sort type slis_t_sortinfo_alv.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
Field Catalog
perform set_fieldcat2 using:
1 'LIFNR' 'LIFNR' 'EKKO' space space space space space space space space space space space space t_fieldcat .
Layout
x_layout-zebra = 'X'.
Top of page heading
perform set_top_page_heading using t_heading t_event.
Events
perform set_events using t_event.
GUI Status
w_status = ''.
w_repid = sy-repid.
Title
w_title = <<If you want to set a title for
the ALV, please, uncomment and edit this line>>.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = t_data
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. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = ''(001).
append x_heading to t_heading.
Program name
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Program: '.
x_heading-info = sy-repid.
append x_heading to t_heading.
User who is running the report
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'User: '.
x_heading-info = sy-uname.
append x_heading to t_heading.
Date of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Date: '.
write sy-datum to x_heading-info.
append x_heading to t_heading.
Time of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Time: '.
write sy-uzeit to x_heading-info.
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
endform.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-up = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
p_colpos: Column position.
p_fieldname: Field of internal table which is being described by
* this record of the field catalog.
p_ref_fieldname: (Optional) Table field / data element which
* describes the properties of the field.
* If this field is not given, it is copied from
* the fieldname.
p_ref_tabname: (Optional) Table which holds the field referenced
* by <<p_ref_fieldname>>.
If this is not given, the parameter
<<p_ref_fieldname>> references a data element.
p_outputlen: (Optional) Column width.
p_noout: (Optional) If set to 'X', states that the field is not
* showed initially. If so, the field has to be
included in the report at runtime using the display
options.
p_seltext_m: (Optional) Medium label to be used as column header.
p_seltext_l: (Optional) Long label to be used as column header.
p_seltext_s: (Optional) Small label to be used as column header.
p_reptext_ddic: (Optional) Extra small (heading) label to be
* used as column header.
p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
or REPTEXT_DDIC as text for column header.
p_hotspot: (Optional) If set to 'X', this field will be used
* as a hotspot area for cursor, alolowing the user
* to click on the field.
p_showasicon: (Optional) If set to 'X', this field will be shown
as an icon and the contents of the field will set
* which icon to show.
p_checkbox: (Optional) If set to 'X', this field will be shown
as a checkbox.
p_edit: (Optional) If set to 'X', this field will be editable.
p_dosum: (Optional) If set to 'X', this field will be summed
(aggregation function) according to the grouping set
by the order functions.
t_fieldcat: Table which contains the whole fieldcat.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given
is a data element.
If p_ref_tabname is given, the ref_fieldname given is a
field of a table.
In case ref_fieldname is not given,
it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF NOT p_edit IS INITIAL.
wa_fieldcat-input = 'X'.
wa_fieldcat-edit = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = <<If you want to set a logo, please,
uncomment and edit this line>>
it_list_commentary = t_heading.
endform. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
Example Code
Executes a command considering the sy-ucomm.
CASE r_ucomm.
WHEN '&IC1'.
Set your "double click action" response here.
Example code: Create and display a status message.
DATA: w_msg TYPE string,
w_row(4) TYPE n.
w_row = rs_selfield-tabindex.
CONCATENATE 'You have clicked row' w_row
'field' rs_selfield-fieldname
'with value' rs_selfield-value
INTO w_msg SEPARATED BY space.
MESSAGE w_msg TYPE 'S'.
ENDCASE.
End of example code.
endform. "user_command -
hi all,
i am facing one problem regarding checkbox in alv.
i have to buttons on alv report as 'select all' (to select all) and 'send mail'(as i have to send mail to selected record)
wat i have done till now is:
1. when i run the report and cleck on checkboxes the action is reflected in internal table..n i can capture the data.
2.when i click on select all button all the records get selected and i can capture the data again.
now the problem :
when i clcik on "select all" and all the record get selected ..but when i deselect any of those record..the changes in internal table lost i.e. the checkbox field because empty for all the record.....
PLZ GIVE SOLUTION FOR FUNCTION "REUSE_ALV_GRID_DISPLAY" ONLY...
now the code:
************LAYOUT**************
DATA: gd_layout TYPE SLIS_LAYOUT_ALV.
gd_layout-colwidth_optimize = 'X'.
gd_layout-zebra = 'X'.
gd_layout-box_fieldname = 'CHECKBOX'.
gd_layout-box_tabname = 'IT_CONF'.
****alv display*************
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_grid_title = 'Detailed List'
it_fieldcat = fieldcat
i_callback_program = sy-repid
i_callback_user_command = 'USER_CMD'
i_callback_pf_status_set = 'EMAILS'
IS_LAYOUT = gd_layout
TABLES
t_outtab = it_conf
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.
endif.
endform. "alv_display
*& Form sush1
text
-->RT_EXTAB text
FORM emails USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'EMAILS'.
ENDFORM. "emails
*& Form user_cmd
text
-->P_UCOMM text
-->LS_SELFIELDtext
FORM user_cmd USING p_ucomm LIKE sy-ucomm ls_selfield type slis_selfield.
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA.
ENDIF.
IF p_ucomm = 'EMAIL'.
loop at it_conf where checkbox = 'X'.
**[[[[[[[U MAY NOT SEE THIS THIS IS FOR MAIL PUPOSE]]]]]]]]]]]]*********
select single sachn telnr into (tc_name , tc_num ) from t526
where SACHX = it_conf-zztc
and werks = it_conf-werks .
******find the emil of employee.
clear : p_0105,p_0105[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = it_conf-pernr
infty = '0105'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
if sy-subrc = 0.
read table p_0105 with key subty = 10.
move p_0105-USRID_LONG to email.
endif.
find immediate superior by Z FM.
clear pernr_s.
CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
EXPORTING
pernr = it_conf-pernr
begda = '18000101'
endda = '99991231'
IMPORTING
v_pernr = pernr_s
EXCEPTIONS
not_found = 1
OTHERS = 2.
if sy-subrc = 0.
find the email of the immed. superiors personal number..
clear : p_0105,p_0105[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr_s
infty = '0105'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
read table p_0105 with key subty = 10.
move p_0105-USRID_LONG to email_s.
endif.
if email <> ' '.
perform send_mail using it_conf-ename email email_s tc_name tc_num.
endif.
if email_s <> ' '.
perform send_mail using it_conf-ename email email_s tc_name tc_num.
endif.
****MAIL PART IS OVER*******************************************
endloop.
endif.
*****FOR "SELECT ALL " BUTTON**************
IF p_ucomm = 'SELECT'.
flag = 1.
loop at it_conf.
move 'X' to it_conf-checkbox.
MODIFY IT_CONF.
endloop.
ls_selfield-refresh = 'X'.
endif." Please see the code of myin in the 'SELECT' & 'DESELECT'.
case save_ok.
when 'EXIT'.
perform exit_program.
when 'SELECT'.
perform select_all_entries changing gt_outtab[].
when 'DESELECT'.
perform deselect_all_entries changing gt_outtab[].
when 'RESET'.
perform reset_selected_entries changing gt_outtab[].
when 'SWITCH'.
perform switch_activation changing gt_outtab[].
endcase.
form select_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c,
l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = 'X'.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
endform.
form check_lock using ps_outtab type gs_outtab
changing p_locked.
data ls_celltab type lvc_s_styl.
loop at ps_outtab-celltab into ls_celltab.
if ls_celltab-fieldname = 'CHECKBOX'.
if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
p_locked = 'X'.
else.
p_locked = space.
endif.
endif.
endloop.
endform.
form deselect_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c,
l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = ' '.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
reward points if it is usefull ......
Girish -
*& Report ZALV11 *
REPORT zalv11 LINE-SIZE 1023 MESSAGE-ID zz.
TYPE-POOLS : slis.
* T A B L E S D E C L A R A T I O N S *
TABLES : ce1eg01,
makt,
kna1,
t9zfprct,
tvkmt.
* I N T E R N A L T A B L E D E C L A R A T I O N S *
DATA : BEGIN OF itab OCCURS 0,
paledger TYPE ce1eg01-paledger, "Currency type for an operating concern
vrgar TYPE ce1eg01-vrgar, "Record Type
versi TYPE ce1eg01-versi, "Plan version (CO-PA)
perio TYPE ce1eg01-perio, "Period/year
paobjnr TYPE ce1eg01-paobjnr, "Profitability Segment no
pasubnr TYPE ce1eg01-pasubnr, "Profitability Segment changes
belnr TYPE ce1eg01-belnr, "Doc no of line item in profit
posnr TYPE ce1eg01-posnr, "Item no in CO-PA line item
hzdat TYPE ce1eg01-hzdat, "Date on which record was created
usnam TYPE ce1eg01-usnam, "Created by
gjahr TYPE ce1eg01-gjahr, "Fiscal year
perde TYPE ce1eg01-perde, "Period
kunnr LIKE ce1eg01-kndnr, "Customer
artnr TYPE ce1eg01-artnr, "Product Number
frwae TYPE ce1eg01-frwae, "Foreign currency key
kaufn TYPE ce1eg01-kaufn, "Sales order number
kdpos TYPE ce1eg01-kdpos, "Item no in Sales order
bzirk TYPE ce1eg01-bzirk, "Sales district
vkbur TYPE ce1eg01-vkbur, "Sales office
wwsap TYPE ce1eg01-wwsap, "Sales Person
ktgrm TYPE tvkmt-ktgrm, "AAG
land1 TYPE ce1eg01-land1, "Country Key
auart TYPE ce1eg01-auart, "Sales document type
kunwe TYPE ce1eg01-kunwe, "Ship-to-party
erlos TYPE ce1eg01-erlos, "Revenue
absmg TYPE ce1eg01-absmg, "Sales qty
kwfrgr TYPE ce1eg01-kwfrgr, "Freight
vvdis TYPE ce1eg01-vvdis, "Discounts
zprdgrp TYPE t9zfprct-zprdgrp, "Product group
name1 TYPE kna1-name1, "Customer Name
maktx TYPE makt-maktx, "Material Description
vtext TYPE tvkmt-vtext, "Description
name2 TYPE kna1-name1, "Sales Person Name
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
perio TYPE ce1eg01-perio, "Period/year5
kunnr TYPE ce1eg01-kndnr, "Customer
artnr TYPE ce1eg01-artnr, "Product Number 21
kaufn TYPE ce1eg01-kaufn, "Sales order number28
kdpos TYPE ce1eg01-kdpos, "Item no in Sales order29
bzirk TYPE ce1eg01-bzirk, "Sales district58
vkbur TYPE ce1eg01-vkbur, "Sales office59
ktgrm TYPE tvkmt-ktgrm, "AAG 61
land1 TYPE ce1eg01-land1, "Country Key 63
auart TYPE ce1eg01-auart, "Sales document type68
kunwe TYPE ce1eg01-kunwe, "Ship-to-party71
zprdgrp TYPE t9zfprct-zprdgrp, "Product group
paledger TYPE ce1eg01-paledger, "Currency type for an operating concern
versi TYPE ce1eg01-versi, "Plan version (CO-PA)4
paobjnr TYPE ce1eg01-paobjnr, "Profitability Segment no6
pasubnr TYPE ce1eg01-pasubnr, "Profitability Segment changes7
belnr TYPE ce1eg01-belnr, "Doc no of line item in profit 8
posnr TYPE ce1eg01-posnr, "Item no in CO-PA line item 9
hzdat TYPE ce1eg01-hzdat, "Date on which record was created10
usnam TYPE ce1eg01-usnam, "Created by11
gjahr TYPE ce1eg01-gjahr, "Fiscal year12
perde TYPE ce1eg01-perde, "Period13
frwae TYPE ce1eg01-frwae, "Foreign currency key23
wwsap TYPE ce1eg01-wwsap, "Sales Person 60
erlos TYPE ce1eg01-erlos, "Revenue76
absmg TYPE ce1eg01-absmg, "Sales qty85
kwfrgr TYPE ce1eg01-kwfrgr, "Freight97
vvdis TYPE ce1eg01-vvdis, "Discounts98
name1 TYPE kna1-name1, "Customer Name
maktx TYPE makt-maktx, "Material Description
vtext TYPE tvkmt-vtext, "Description
name2 TYPE kna1-name1, "Sales Person Name
END OF itab1.
DATA : BEGIN OF itab2 OCCURS 0,
perio TYPE ce1eg01-perio, "Period/year
hzdat TYPE ce1eg01-hzdat, "Date on which record was created
usnam TYPE ce1eg01-usnam, "Created by
gjahr TYPE ce1eg01-gjahr, "Fiscal year
perde TYPE ce1eg01-perde, "Period
kunnr LIKE ce1eg01-kndnr, "Customer
artnr TYPE ce1eg01-artnr, "Product Number
frwae TYPE ce1eg01-frwae, "Foreign currency key
kaufn TYPE ce1eg01-kaufn, "Sales order number
kdpos TYPE ce1eg01-kdpos, "Item no in Sales order
bzirk TYPE ce1eg01-bzirk, "Sales district
vkbur TYPE ce1eg01-vkbur, "Sales office
wwsap TYPE ce1eg01-wwsap, "Sales Person
ktgrm TYPE tvkmt-ktgrm, "AAG
land1 TYPE ce1eg01-land1, "Country Key
auart TYPE ce1eg01-auart, "Sales document type
kunwe TYPE ce1eg01-kunwe, "Ship-to-party
erlos TYPE ce1eg01-erlos, "Revenue
absmg TYPE ce1eg01-absmg, "Sales qty
kwfrgr TYPE ce1eg01-kwfrgr, "Freight
vvdis TYPE ce1eg01-vvdis, "Discounts
zprdgrp TYPE t9zfprct-zprdgrp, "Product group
name1 TYPE kna1-name1, "Customer Name
maktx TYPE makt-maktx, "Material Description
vtext TYPE tvkmt-vtext, "Description
name2 TYPE kna1-name1, "Sales Person Name
END OF itab2.
DATA : BEGIN OF i_kna1 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
END OF i_kna1.
DATA : BEGIN OF i_kna2 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
END OF i_kna2.
DATA : BEGIN OF i_makt OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF i_makt.
DATA : wa_t9zfprct TYPE t9zfprct,
i_t9zfprct LIKE STANDARD TABLE OF wa_t9zfprct WITH HEADER LINE.
DATA : wa_tvkmt TYPE tvkmt,
i_tvkmt LIKE STANDARD TABLE OF wa_tvkmt WITH HEADER LINE.
DATA: wa_itab like itab.
DATA: wa_itab2 like itab2.
* D A T A D E C L A R A T I O N F O R A L V *
TYPE-POOLS: slis. "ALV Declarations
DATA: t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
tt_fieldcat TYPE slis_t_fieldcat_alv,
x_fieldcat TYPE slis_fieldcat_alv.
DATA : mycat TYPE slis_t_fieldcat_alv ,
scat TYPE slis_fieldcat_alv,
gt_events TYPE slis_t_event.
DATA: g_repid LIKE sy-repid,
gd_layout TYPE slis_layout_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gd_prntparams TYPE slis_print_alv,
rs_variant LIKE disvariant.
data: p_file TYPE rlgrap-filename value 'TEST3.txt'.
data: wa_tab2 like tab2.
* D A T A D E C L A R A T I O N *
DATA : t_lineno LIKE sy-tabix,
ld_linesc(10) TYPE c.
DATA : w_erlos TYPE ce1eg01-erlos,
w_absmg TYPE ce1eg01-absmg,
w_kwfrgr TYPE ce1eg01-kwfrgr,
w_vvdis TYPE ce1eg01-vvdis.
* S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_curr FOR ce1eg01-paledger ,
s_vrgar FOR ce1eg01-vrgar,
s_perio FOR ce1eg01-perio,
s_spras FOR makt-spras NO INTERVALS,
s_auart FOR ce1eg01-auart,
s_kaufn FOR ce1eg01-kaufn.
PARAMETERS: p_layout TYPE slis_vari.
SELECTION-SCREEN END OF BLOCK blk1.
* 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_layout.
PERFORM alv_variant_f4 CHANGING p_layout.
* S T A R T O F S E L E C T I O N
START-OF-SELECTION.
PERFORM data_select.
DESCRIBE TABLE itab LINES t_lineno.
IF t_lineno = 0.
MESSAGE i000 WITH 'NO RECORD FOUND'.
ELSE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_events.
PERFORM build_print_params.
* PERFORM calculate.
PERFORM call_alv.
PERFORM dataset.
ENDIF.
*& Form DATA_SELECT
FORM data_select.
SELECT paledger vrgar versi perio paobjnr pasubnr belnr posnr hzdat usnam gjahr perde kndnr artnr frwae kaufn kdpos bzirk
vkbur wwsap ktgrm land1 auart kunwe erlos absmg kwfrgr vvdis
FROM ce1eg01 INTO TABLE itab
WHERE paledger IN s_curr
AND vrgar IN s_vrgar
AND perio IN s_perio
AND kaufn IN s_kaufn
AND auart IN s_auart.
IF sy-subrc = 0.
SELECT matnr maktx FROM makt INTO TABLE i_makt
FOR ALL ENTRIES IN itab
WHERE matnr = itab-artnr
AND spras IN s_spras.
* Reading sales person
SELECT kunnr name1 FROM kna1 INTO TABLE i_kna1
FOR ALL ENTRIES IN itab
WHERE kunnr = itab-kunnr.
* Reading ship to party
SELECT kunnr name1 FROM kna1 INTO TABLE i_kna2
FOR ALL ENTRIES IN itab
WHERE kunnr = itab-wwsap. "kunwe.
SELECT * FROM t9zfprct INTO TABLE i_t9zfprct
FOR ALL ENTRIES IN itab
WHERE ktgrm = itab-ktgrm.
SELECT * FROM tvkmt INTO TABLE i_tvkmt
FOR ALL ENTRIES IN itab
WHERE ktgrm = itab-ktgrm.
SORT i_kna1 BY kunnr.
SORT i_kna2 BY kunnr.
SORT i_t9zfprct BY ktgrm.
SORT i_tvkmt BY ktgrm.
LOOP AT itab.
MOVE-CORRESPONDING itab TO itab1.
READ TABLE i_kna1 WITH KEY kunnr = itab-kunnr BINARY SEARCH.
IF sy-subrc = 0.
itab1-name1 = i_kna1-name1.
ENDIF.
READ TABLE i_kna2 WITH KEY kunnr = itab-wwsap BINARY SEARCH.
IF sy-subrc = 0.
itab1-name2 = i_kna2-name1.
ENDIF.
READ TABLE i_t9zfprct WITH KEY ktgrm = itab-ktgrm BINARY SEARCH.
IF sy-subrc = 0.
itab1-zprdgrp = i_t9zfprct-zprdgrp.
ENDIF.
READ TABLE i_tvkmt WITH KEY ktgrm = itab-ktgrm BINARY SEARCH.
IF sy-subrc = 0.
itab1-ktgrm = i_tvkmt-ktgrm.
itab1-vtext = i_tvkmt-vtext.
ENDIF.
READ TABLE i_makt WITH KEY matnr = itab-artnr.
IF sy-subrc = 0.
itab1-maktx = i_makt-maktx.
ENDIF.
APPEND itab1.
CLEAR itab1.
ENDLOOP.
REFRESH itab.
SORT itab1 BY perio kunnr artnr kaufn kdpos bzirk vkbur ktgrm land1 auart kunwe zprdgrp paledger.
CLEAR : w_erlos ,w_absmg ,w_kwfrgr ,w_vvdis.
LOOP AT itab1.
MOVE-CORRESPONDING itab1 TO itab.
SHIFT itab-wwsap LEFT DELETING LEADING '0'.
SHIFT itab-kunnr LEFT DELETING LEADING '0'.
SHIFT itab-kaufn LEFT DELETING LEADING '0'.
SHIFT itab-kunwe LEFT DELETING LEADING '0'.
SHIFT itab-belnr LEFT DELETING LEADING '0'.
w_erlos = w_erlos + itab1-erlos.
w_absmg = w_absmg + itab1-absmg.
w_kwfrgr = w_kwfrgr + itab1-kwfrgr.
w_vvdis = w_vvdis + itab1-vvdis.
AT END OF paledger.
MOVE : w_erlos TO itab-erlos,
w_absmg TO itab-absmg,
w_kwfrgr TO itab-kwfrgr,
w_vvdis TO itab-vvdis.
APPEND itab.
CLEAR itab.
CLEAR : w_erlos ,w_absmg ,w_kwfrgr ,w_vvdis.
ENDAT.
ENDLOOP.
ENDIF.
clear itab.
loop at itab.
move-corresponding itab to itab2.
append itab2.
endloop.
ENDFORM. "data_select
*& Form build_fieldcatalog
* Fill field catalog and sort catelog with output fields
FORM build_fieldcatalog.
* PERFORM append_fldcat USING 'PALEDGER' 'ITAB' 'Currency type' 01 .
PERFORM append_fldcat USING 'ZPRDGRP' 'ITAB' 'Product group' 01 .
PERFORM append_fldcat USING 'KUNNR' 'ITAB' 'Customer' 02 .
PERFORM append_fldcat USING 'NAME1' 'ITAB' 'Customer Name' 03 .
PERFORM append_fldcat USING 'ARTNR' 'ITAB' 'Product Number' 04 .
PERFORM append_fldcat USING 'MAKTX' 'ITAB' 'Material Description' 05 .
PERFORM append_fldcat USING 'KTGRM' 'ITAB' 'AAG' 06 .
PERFORM append_fldcat USING 'VTEXT' 'ITAB' 'Description' 07 .
PERFORM append_fldcat USING 'WWSAP' 'ITAB' 'Sales Person' 08 .
PERFORM append_fldcat USING 'NAME2' 'ITAB' 'Sales Person Name' 09 .
PERFORM append_fldcat USING 'VKBUR' 'ITAB' 'Sales office' 10 .
PERFORM append_fldcat USING 'LAND1' 'ITAB' 'Country Key' 11 .
PERFORM append_fldcat USING 'KAUFN' 'ITAB' 'Sales order number' 12 .
PERFORM append_fldcat USING 'KDPOS' 'ITAB' 'Item no in Sales order' 13 .
PERFORM append_fldcat USING 'PERIO' 'ITAB' 'Period/year' 14 .
PERFORM append_fldcat USING 'HZDAT' 'ITAB' 'Date on which record was created' 15 .
PERFORM append_fldcat USING 'ABSMG' 'ITAB' 'Sales qty' 16 .
PERFORM append_fldcat USING 'ERLOS' 'ITAB' 'Revenue' 17 .
PERFORM append_fldcat USING 'VVDIS' 'ITAB' 'Discounts' 18 .
PERFORM append_fldcat USING 'KWFRGR' 'ITAB' 'Freight' 19 .
PERFORM append_fldcat USING 'FRWAE' 'ITAB' 'Foreign currency key' 20 .
PERFORM append_fldcat USING 'AUART' 'ITAB' 'Sales document type' 21 .
PERFORM append_fldcat USING 'KUNWE' 'ITAB' 'Ship-to-party' 22 .
PERFORM append_fldcat USING 'BZIRK' 'ITAB' 'Sales district' 23 .
* PERFORM append_fldcat USING 'BELNR' 'ITAB' 'Doc no of line item in profit' 24 .
* PERFORM append_fldcat USING 'VERSI' 'ITAB' 'Plan version (CO-PA)' 25 .
* PERFORM append_fldcat USING 'PAOBJNR' 'ITAB' 'Profitability Segment no' 26 .
* PERFORM append_fldcat USING 'PASUBNR' 'ITAB' 'Profitability Segment changes' 27 .
* PERFORM append_fldcat USING 'POSNR' 'ITAB' 'Item no in CO-PA line item' 28 .
PERFORM append_fldcat USING 'USNAM' 'ITAB' 'Created by' 29 .
PERFORM append_fldcat USING 'GJAHR' 'ITAB' 'Fiscal year' 30 .
PERFORM append_fldcat USING 'PERDE' 'ITAB' 'Period' 31 .
ENDFORM. "build_T_FIELDCAT
*& Form build_layout
FORM build_layout .
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
ENDFORM. " build_layout
*& Form build_events
FORM build_events .
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events[].
READ TABLE gt_events WITH KEY name = slis_ev_end_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE 'END_OF_PAGE' TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
READ TABLE gt_events WITH KEY name = slis_ev_end_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE 'END_OF_LIST' TO ls_event-form.
APPEND ls_event TO gt_events.
ENDIF.
READ TABLE gt_events
WITH KEY name = slis_ev_user_command INTO ls_event.
IF sy-subrc = 0.
ls_event-name = 'USER_COMMAND'.
ls_event-form = 'USER_COMMAND'.
APPEND ls_event TO gt_events.
ENDIF.
ENDFORM. " build_events
*& Form BUILD_PRINT_PARAMS
* Setup print parameters
FORM build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
ENDFORM. " BUILD_PRINT_PARAMS
*& Form call_alv
* text
* --> p1 text
* <-- p2 text
FORM call_alv .
g_repid = sy-repid.
rs_variant-variant = p_layout.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
is_layout = gd_layout
it_fieldcat = t_fieldcat[]
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = rs_variant
TABLES
t_outtab = itab2
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " call_alv
* Form TOP-OF-PAGE *
* ALV Report Header *
FORM top-of-page.
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info.
* Title
wa_header-typ = 'H'.
wa_header-info = 'PA Sales Book Summary report'.
APPEND wa_header TO t_header.
CLEAR wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
APPEND wa_header TO t_header.
CLEAR: wa_header.
* Total No. of Records Selected
DESCRIBE TABLE itab LINES t_lineno.
ld_linesc = t_lineno.
CONCATENATE 'Total No. of Records Selected: ' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. "top-of-page
*& Form 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. "END_OF_PAGE
*& Form END_OF_LIST
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. "END_OF_LIST
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF r_ucomm = '&IC1'.
CASE rs_selfield-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD rs_selfield-value.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDIF.
ENDFORM. "user_command
*& Form append_fldcat
* text
FORM append_fldcat USING par_fldname par_tabname par_seltext pos.
t_fieldcat-tabname = par_tabname.
t_fieldcat-fieldname = par_fldname .
* t_fieldcat-seltext_s = par_seltext.
* t_fieldcat-seltext_m = par_seltext.
t_fieldcat-seltext_l = par_seltext.
t_fieldcat-reptext_ddic = par_seltext.
t_fieldcat-col_pos = pos.
* t_fieldcat-just = 'R'.
t_fieldcat-lzero = ' '.
APPEND t_fieldcat.
ENDFORM. " append_fldcat
*& Form ALV_VARIANT_F4
* text
* -->PA_VARI text
FORM alv_variant_f4 CHANGING p_layout.
DATA nof4 TYPE c.
CLEAR nof4.
LOOP AT SCREEN.
IF screen-name = 'P_LAYOUT'.
IF screen-input = 0.
nof4 = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
rs_variant-report = sy-repid.
rs_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = rs_variant
i_save = 'A'
IMPORTING
es_variant = rs_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0 AND nof4 EQ space.
p_layout = rs_variant-variant.
ENDIF.
ENDFORM.
*& Form dataset
* text
* --> p1 text
* <-- p2 text
form dataset .
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT itab2.
TRANSFER itab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
endform. " dataset
When I execute this code and move back it shows the following error.I want to move the output to p_file in application server.Plz suggest what to do.
Only character-type data objects are supported at the argument
position "f" for the statement
"TRANSFER f TO ...".
In this case, the operand "f" has the non-character-type "u". The
current program is flagged as a Unicode program. In the Unicode context,
type X fields are seen as non-character-type, as are structures that
contain non-character-type components.Some of the fields in TAB2 may not be text. Open the dataset in binary mode and see if that resolves the issue.
If you must have the file in text mode, then copy the header line to a structure containing just text fields and then transfer to the dataset. -
ALV report for 5 Grids using Objects and Method
I have few questions in ALV 5Grids ,could you please correct me in the following program logic...
Using this program logic i am able to generate the five Grids and able to populate Header details from VBAK into Grid1,If you click in the Grid 1 and it is populating item details in Grid2 from VBAP,parallally populating the customer data in Grid5 from KNA1.
Now the pending issue is ,
if you click in the Grid2 then we should populate the shipping details in Grid3 and
if you click in the Grid3 then we should populate the billing details in Grid4.
Program Logic;
REPORT ZAREPAS20.
Tables : vbak,vbap,likp,lips,vbrk,vbrp,kna1.
DATA : OK_CODE LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV7_GRID_DEMO_0100_VASU',
DOCKING TYPE REF TO CL_GUI_DOCKING_CONTAINER,
SPLITTER_1 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
SPLITTER_2 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
splitter_3 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
CELL_TOP1 TYPE REF TO CL_GUI_CONTAINER,
CELL_BOTTOM1 TYPE REF TO CL_GUI_CONTAINER,
CELL_TOP2 TYPE REF TO CL_GUI_CONTAINER,
CELL_BOTTOM2 TYPE REF TO CL_GUI_CONTAINER,
CELL_LEFT TYPE REF TO CL_GUI_CONTAINER,
CELL_middle TYPE REF TO CL_GUI_CONTAINER,
CELL_RIGHT TYPE REF TO CL_GUI_CONTAINER,
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
GRID2 TYPE REF TO CL_GUI_ALV_GRID,
GRID3 TYPE REF TO CL_GUI_ALV_GRID,
GRID4 TYPE REF TO CL_GUI_ALV_GRID,
GRID5 TYPE REF TO CL_GUI_ALV_GRID.
DATA : GT_VBAK TYPE STANDARD TABLE OF VBAK,
GT_VBAP TYPE STANDARD TABLE OF VBAP,
GT_LIKP TYPE STANDARD TABLE OF likp,
GT_LIPS TYPE STANDARD TABLE OF lips,
GT_VBRK TYPE STANDARD TABLE OF vbrk,
GT_VBRP TYPE STANDARD TABLE OF vbrp,
GT_KNA1 TYPE STANDARD TABLE OF kna1.
DATA:begin of itab1 occurs 0,
vbeln type likp-VBELN,
erzet type likp-ERZET,
lfart type likp-LFART,
posnr type lips-POSNR,
END OF ITAB1.
DATA:begin of itab2 occurs 0,
vbeln like vbrk-vbeln,
posnr like vbrk-fktyp,
fkart like vbrk-fkart,
fklmg like vbrp-fklmg,
end of itab2.
*selection screen for selecting range of values
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
select-options: S_vbeln for VBAK-vbeln.
selection-screen end of block b1.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender. " sending control, i.e. ALV grid that raised event
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD HANDLE_DOUBLE_CLICK.
*DEFINE LOCAL DATA.
DATA : itab_vbak type VBAK,
itab_vbap type VBAP,
itab_likp type likp,
itab_lips type lips,
itab_vbrk type vbrk,
itab_vbrp type vbrp,
itab_kna1 type kna1.
*DISTINGUISH ACCORDING TO SENDING GRID INSTANCE
CASE SENDER.
WHEN GRID1.
READ TABLE gt_VBAK INTO itab_vbak INDEX e_row-index.
CHECK ( itab_vbak-vbeln IS NOT INITIAL ).
CALL METHOD GRID1->set_current_cell_via_id
EXPORTING
is_ROW_ID =
is_COLUMN_ID =
is_row_no = es_row_no.
Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
WHEN GRID2.
READ TABLE gt_VBAP INTO itab_vbap INDEX e_row-index.
CHECK ( itab_vbap-vbeln IS NOT INITIAL ).
CALL METHOD GRID2->set_current_cell_via_id
EXPORTING
is_ROW_ID =
is_COLUMN_ID =
is_row_no = es_row_no.
Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
WHEN GRID3.
READ TABLE gt_LIPS INTO itab_LIPS INDEX e_row-index.
CHECK ( itab_lips-vgbel IS NOT INITIAL ).
CALL METHOD GRID3->set_current_cell_via_id
EXPORTING
is_ROW_ID =
is_COLUMN_ID =
is_row_no = es_row_no.
Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DELIVERY_DETAILS' ).
WHEN GRID4.
READ TABLE gt_VBRP INTO itab_VBRP INDEX e_row-index.
CHECK ( itab_vbrp-vgbel IS NOT INITIAL ).
CALL METHOD GRID4->set_current_cell_via_id
EXPORTING
is_ROW_ID =
is_COLUMN_ID =
is_row_no = es_row_no.
Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'BILLING_DETAILS' ).
WHEN GRID5.
READ TABLE gt_KNA1 INTO itab_KNA1 INDEX e_row-index.
CHECK ( itab_kna1-kunnr IS NOT INITIAL ).
SET PARAMETER ID 'KUN' FIELD itab_KNA1-KUNNR.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
endmethod.
endclass. "lcl_eventhandler IMPLEMENTATION
start-of-selection.
*write :/ 'FEDEX INT''''L' .
SELECT * FROM vbak INTO TABLE gt_VBAK
where vbeln IN S_VBELN.
creating docking container
create object docking
exporting
parent = cl_gui_container=>screen0
ratio = 90
exceptions
others = 6.
if sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create splitter container
CREATE OBJECT splitter_1
EXPORTING
parent = docking
rows = 1
columns = 3
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Get cell container
CALL METHOD splitter_1->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_left.
CALL METHOD splitter_1->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = cell_middle.
CALL METHOD splitter_1->get_container
EXPORTING
row = 1
column = 3
RECEIVING
container = cell_right.
Create 2nd splitter container
CREATE OBJECT splitter_2
EXPORTING
parent = cell_left
rows = 2
columns = 1
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Get cell container
CALL METHOD splitter_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_top1.
CALL METHOD splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = cell_bottom1.
Create 3rd splitter container
CREATE OBJECT splitter_3
EXPORTING
parent = cell_middle
rows = 2
columns = 1
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Get cell container
CALL METHOD splitter_3->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_top2.
CALL METHOD splitter_3->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = cell_bottom2.
Create ALV grids
CREATE OBJECT grid1
EXPORTING
i_parent = cell_top1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid2
EXPORTING
i_parent = cell_bottom1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid3
EXPORTING
i_parent = cell_top2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid4
EXPORTING
i_parent = cell_bottom2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid5
EXPORTING
i_parent = cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid1.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid2.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid3.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid4.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid5.
Display data
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAK'
CHANGING
it_outtab = gt_VBAK
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_vbap.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAP'
CHANGING
it_outtab = gt_VBAP " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_LIPS.
CALL METHOD grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'LIPS'
CHANGING
it_outtab = gt_LIPS " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_VBRP.
CALL METHOD grid4->set_table_for_first_display
EXPORTING
i_structure_name = 'VBRP'
CHANGING
it_outtab = gt_VBRP " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_KNA1.
CALL METHOD grid5->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = gt_KNA1 " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Link the docking container to the target dynpro
CALL METHOD docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
CALL SCREEN '0100'.
Flow logic of dynpro:
*PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
end-of-selection.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
SET TITLEBAR 'xxx'.
Refresh display of detail ALV list
CALL METHOD grid2->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Refresh display of detail ALV list
CALL METHOD grid3->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Refresh display of detail ALV list
CALL METHOD grid4->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Refresh display of detail ALV list
CALL METHOD grid5->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR
'EXIT' OR
'CANCEL'.
SET SCREEN 0.LEAVE SCREEN.
USER HAS PUSHED BUTTON "DISPLAY OREDERS"
WHEN 'ORDER_DETAILS'.
PERFORM ORDER_SHOW_DETAILS.
when 'DELIVERY_DETAILS'.
PERFORM DELIVERY_SHOW_DETAILS.
WHEN 'BILLING_DETAILS'.
PERFORM BILLING_SHOW_DETAILS.
WHEN OTHERS.
ENDCASE.
CLEAR : OK_CODE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ORDER_SHOW_DETAILS
text
--> p1 text
<-- p2 text
FORM order_show_details .
define local data
DATA:
ld_row TYPE i,
itab_VBAK TYPE VBAK.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_VBAK INTO itab_VBAK INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM KNA1 INTO TABLE gt_KNA1
WHERE KUNNR = itab_VBAK-KUNNR.
SELECT * FROM VBAP INTO TABLE gt_VBAP
WHERE VBELN = ITAB_VBAK-VBELN.
*REFRESH: gt_LIPS.
ENDFORM. " ORDER_SHOW_DETAILS
*& Form DELIVERY_SHOW_DETAILS
text
--> p1 text
<-- p2 text
FORM DELIVERY_SHOW_DETAILS .
define local data
DATA:
ld_row TYPE i,
itab_VBAP TYPE VBAP.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_VBAP INTO itab_VBAP INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT LIKPVBELN LIKPERZET LIKPLFART LIPSVBELN
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FROM ( LIKP INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN )
WHERE LIKP~VBELN IN S_VBELN.
*REFRESH: gt_LIPS.
ENDFORM. " DELIVERY_SHOW_DETAILS
*& Form BILLING_SHOW_DETAILS
text
--> p1 text
<-- p2 text
FORM BILLING_SHOW_DETAILS .
define local data
DATA:
ld_row TYPE i,
itab_LIPS TYPE LIPS.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_LIPS INTO itab_LIPS INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT VBRKVBELN VBRKFKTYP VBRKFKART VBRPFKLMG
INTO CORRESPONDING FIELDS OF TABLE ITAB2
FROM ( VBRK INNER JOIN VBRP ON VBRKVBELN = VBRPVBELN )
WHERE VBRK~VBELN IN S_VBELN.
ENDFORM. " BILLING_SHOW_DETAILSHi,
ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf.
transaction se83) available from release 4.6 of SAP R/3.
ALV is available in two modes: list and grid. List mode is good old list processing with
standard functionnalities, and grid mode is using a new OCX object displaying grids.
Classical reports needs more coding to set the horizontal and vertical lines.we need to adjust
the lines manually.Even interactive also takes lot of code.
ALV reports reduces the code when compared to classical reports.we use function modules to
generate the output.
that r REUSE_ALV_LIST_DISPLAY,REUSE_ALV_GRID_DISPLAY,REUSE_ALV_HIERSEQ_LIST_DISPLAY etc..
the following threads will give some examples of the functions which you are expecting
Header
regarding function module
hide ALV field
Simply Display selection parameter values in the ALV OUTPUT
Drag and drop in a report
https://www.sdn.sap
Reprots
http://www.sapgenie.com/abap/reports.htm
http://www.allsaplinks.com/material.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you
use - ABAP Objects calls or simple function modules.
Maybe you are looking for
-
What is the best structure to use for my goal?
I am new to JavaFX but not new to Java. In fact I have my computer science degree training on java. It has been a number of years since I have worked hands on with Java as I have had a more website oriented role at my company since graduating, but we
-
How can i download logfile in session file?
Hi gurus , can give me code for download of error records stored in logfile?
-
Satellite X200-21W - Does multi DVD drive have labelfash and securedisc?
I have an Satellite X200-21W Modell Nr. : PSPB9E-03U01WGR with the multidvd TS-L632H. My question Does this drive have labellash and securedisc, or only one of those, or nothing Thx for your support
-
We have two iphones on the same itunes computer/library and now I think we set the accounts up wrong because i synced my phone under my itunes id and my contacts are gone... can i get them back?
-
Transfer existing Dreamweaver CC site to Business Catalyst
Is there any way to make an existing site connect with a Business Catalyst Account? From what I've seen, you can only do the reverse.