Field catalog in OOP
I have an internal table that needs to be displayed in ALV using abap objects. I have tried to use the sflight templates but I get error in i_structure and it_outtab , when I directly pass my internal table to them
What is the solutions to this problem.
If I am building a field catalog , then how to pass it to the screen
Thankyou
Hi
refer this program you will find all the things
reward if usefull
*& Report Z_ALV_OOPS
REPORT Z_ALV_OOPS.
*Event class Definition "Event handler class
class event_handle definition.
public section.
methods: handle_user
for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass.
*Event class Implementation
class event_handle implementation.
method handle_user.
write:/ ''.
endmethod.
endclass.
Data: t_alv type ref to cl_gui_alv_grid, "ALV control
t_cont type ref to cl_gui_custom_container, "Cust Container
t_alv2 type ref to cl_gui_alv_grid, "ALV control
t_cont2 type ref to cl_gui_custom_container, "Cust Container
t_fieldcat type lvc_t_fcat with header line, "Field Cat
t_fieldcat2 type lvc_t_fcat with header line, "Field Cat
t_layout type lvc_s_layo, "Layout
t_event type ref to event_handle, "Event handler
t_sort type LVC_T_SORT with header line, "Sort
t_toolbar type ui_functions with header line. "Toolbar xclude
Types: begin of g_vbak, "Header Table
vbeln like vbak-vbeln,
auart like vbak-auart,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
spart like vbak-spart,
kunnr like vbak-kunnr,
bstnk like vbak-bstnk,
seltab,
end of g_vbak.
Types: begin of g_vbap, "Item Table
vbeln like vbap-vbeln,
posnr(6) type c,
* posrn like vbap-posnr,
matnr like vbap-matnr,
netwr like vbap-netwr,
waerk like vbap-waerk,
end of g_vbap.
Data: t_vbak type g_vbak occurs 0,
t_vbap type g_vbap occurs 0.
Start-Of-Selection.
*Fetch data from DB Table
select vbeln auart vkorg vtweg spart kunnr bstnk
from vbak into table t_vbak up to 20 rows.
End-Of-Selection.
*Call ALV screen
call screen 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ALV'.
SET TITLEBAR 'VBAK'.
if t_cont is initial.
create object t_cont
exporting
container_name = 'ALV'.
create object t_alv
exporting
i_parent = t_cont.
*Create event handlers
create object t_event.
set handler t_event->handle_user for t_alv.
perform build_fieldcatlog.
perform build_layout.
perform xclude_toolbar.
CALL METHOD t_alv->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
IS_LAYOUT = t_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = t_toolbar[]
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = t_vbak[]
IT_FIELDCATALOG = t_fieldcat[]
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
Data: lt_rows type lvc_t_row,
wa_rows type line of lvc_t_row,
wa_vbak type g_vbak,
l_lines type i.
refresh: t_vbap.
case sy-ucomm.
when 'DET'. "Item details
* Get selected rows from ALV
call method t_alv->get_selected_rows
importing
et_index_rows = lt_rows.
* Fetch corresponding Item details from VBAP
loop at lt_rows into wa_rows.
read table t_vbak into wa_vbak index wa_rows-index transporting
vbeln.
select vbeln posnr matnr netwr waerk from vbap
appending corresponding fields of table t_vbap
where vbeln = wa_vbak-vbeln.
endloop.
* Prepare fieldcatlog
* Display Item details in ALV
call screen 200 starting at 8 5.
when 'SHOW'. "Display order
call method t_alv->get_selected_rows
importing
et_index_rows = lt_rows.
Describe table lt_rows lines l_lines.
if l_lines > 1.
message e999(z_error).
else.
read table lt_rows into wa_rows index 1.
read table t_vbak into wa_vbak index wa_rows-index transporting
vbeln.
set parameter id 'AUN' field wa_vbak-vbeln.
call transaction 'VA03' and skip first screen.
endif.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form build_fieldcatlog
* text
form build_fieldcatlog .
clear t_fieldcat.
t_fieldcat-col_pos = '1'.
t_fieldcat-fieldname = 'VBELN'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VBELN'.
append t_fieldcat.
t_fieldcat-col_pos = '2'.
t_fieldcat-fieldname = 'AUART'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'AUART'.
append t_fieldcat.
t_fieldcat-col_pos = '3'.
t_fieldcat-fieldname = 'VKORG'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VKORG'.
append t_fieldcat.
t_fieldcat-col_pos = '4'.
t_fieldcat-fieldname = 'VTWEG'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VTWEG'.
append t_fieldcat.
t_fieldcat-col_pos = '5'.
t_fieldcat-fieldname = 'SPART'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'SPART'.
append t_fieldcat.
t_fieldcat-col_pos = '6'.
t_fieldcat-fieldname = 'KUNNR'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'KUNNR'.
append t_fieldcat.
t_fieldcat-col_pos = '7'.
t_fieldcat-fieldname = 'BSTNK'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'BSTNK'.
append t_fieldcat.
endform. " build_fieldcatlog
*& Module LEAVE INPUT
* text
module LEAVE input.
case sy-ucomm.
when 'BACK' or 'EXIT' or 'CANCEL'.
leave program.
endcase.
endmodule. " LEAVE INPUT
*& Form build_layout
* text
* --> p1 text
* <-- p2 text
form build_layout .
t_layout-zebra = 'X'.
t_layout-sel_mode = 'A'.
t_layout-grid_title = 'Header Details'.
endform. " build_layout
*& Form build_fcat_vbap
* text
form build_fcat_vbap .
clear t_fieldcat2.
t_fieldcat2-scrtext_m = 'Sales Doc'.
t_fieldcat2-col_pos = 1.
t_fieldcat2-fieldname = 'VBELN'.
t_fieldcat2-tabname = 'T_VBAP'.
t_fieldcat2-no_zero = 'X'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'VBELN'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 2.
t_fieldcat2-scrtext_m = 'Item'.
t_fieldcat2-fieldname = 'POSNR'.
t_fieldcat2-tabname = 'T_VBAP'.
t_fieldcat2-intlen = '6'.
t_fieldcat2-inttype = 'C'.
t_fieldcat2-no_zero = 'X'.
* t_fieldcat2-ref_table = 'VBAP'.
* t_fieldcat2-ref_field = 'POSNR'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 3.
t_fieldcat2-fieldname = 'MATNR'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'MATNR'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 4.
t_fieldcat2-fieldname = 'NETWR'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'NETWR'.
t_fieldcat2-do_sum = 'X'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 5.
t_fieldcat2-fieldname = 'WAERK'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'WAERK'.
append t_fieldcat2.
endform. " build_fcat_vbap
*& Module STATUS_0200 OUTPUT
* text
module STATUS_0200 output.
SET PF-STATUS 'ITEM1'.
SET TITLEBAR 'VBAP'.
perform build_fcat_vbap.
perform sort_alv2.
if t_cont2 is initial.
create object t_cont2
exporting
container_name = 'ITEM'.
create object t_alv2
exporting
i_parent = t_cont2.
t_layout-grid_title = 'Item Details'.
CALL METHOD t_alv2->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
IS_LAYOUT = t_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = t_toolbar[]
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
it_outtab = t_vbap[]
IT_FIELDCATALOG = t_fieldcat2[]
IT_SORT = t_sort[]
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
else.
CALL METHOD t_alv2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
* EXCEPTIONS
* FINISHED = 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.
endmodule. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
* text
module USER_COMMAND_0200 input.
case sy-ucomm.
when 'GOBACK'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
*& Form sort_alv2
* text
* --> p1 text
* <-- p2 text
form sort_alv2 .
clear t_sort.
t_sort-spos = '1'.
t_sort-fieldname = 'VBELN'.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
append t_sort.
endform. " sort_alv2
*& Form xclude_toolbar
* text
* --> p1 text
* <-- p2 text
form xclude_toolbar .
t_toolbar = '&DETAIL'.
append t_toolbar.
t_toolbar = '&&SEP00'.
append t_toolbar.
t_toolbar = '&&SEP01'.
append t_toolbar.
t_toolbar = '&&SEP02'.
append t_toolbar.
t_toolbar = '&SORT_ASC'.
append t_toolbar.
t_toolbar = '&SORT_DSC'.
append t_toolbar.
t_toolbar = '&FIND'.
append t_toolbar.
t_toolbar = '&MB_FILTER'.
append t_toolbar.
t_toolbar = '&&SEP04'.
append t_toolbar.
t_toolbar = '&MB_SUM'.
append t_toolbar.
t_toolbar = '&MB_SUB_TOTAL'.
append t_toolbar.
t_toolbar = '&PRINT_BACK'.
append t_toolbar.
t_toolbar = '&MB_VIEW'.
append t_toolbar.
t_toolbar = '&MB_EXPORT'.
append t_toolbar.
t_toolbar = '&GRAPH'.
append t_toolbar.
t_toolbar = '&COLO'.
append t_toolbar.
t_toolbar = '&&SEP06'.
append t_toolbar.
t_toolbar = '&&SEP07'.
append t_toolbar.
t_toolbar = '&INFO'.
append t_toolbar.
t_toolbar = '&&SEP03'.
append t_toolbar.
endform. " xclude_toolbar
Similar Messages
-
Field catalog in alv with classes(OOPS)
please refer the code below of field catalog prepared.
this code is for preparing field catalog using ALV and OOPS.In the below field catalog, do_sum is not working.it is going to dump.
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'VBELN1'.
ls_fcat-ref_field = 'VBELN'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Invoice No'.
ls_fcat-seltext = 'Invoice No'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DMBTR'.
ls_fcat-ref_field = 'DMBTR'.
ls_fcat-ref_table = 'BSAD'.
ls_fcat-coltext = 'Value of Invoice'.
ls_fcat-seltext = 'Value of Invoice'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ENDFORM. "PREPARE_FIELD_CATALOG
I would apreciate u response.
regards,
veera.Hello Veeranjaneyulu
I prefer to use function module <b>LVC_FIELDCATALOG_MERGE</b> to build my fieldcatalogs.
If you need fields from different structure that is no problem. Simply call the function module for each structure and collect the result in the same itab (e.g. lt_fcat).
Finally, you delete all fields that you do not need.
If the order is important to you then re-order the fields:
LOOP AT lt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY lt_fcat from ls_fcat.
ENDLOOP.
Regards
Uwe -
How do I define Field-Catalog and Event-Catalog in OOPs ALV
Hi All,
This is the piece of the code on which I'm working upon. This program is giving an exception "No Field-Catalog Found".
I'm new to OOPs ALV. Could anybody please tell me how to define the field-catalog and event-catalog in this.
module PBO output.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
CREATE OBJECT g_grid EXPORTING I_PARENT = g_custom_container.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING I_STRUCTURE_NAME = 'IT_MATERIAL'
is_layout = layout
CHANGING IT_OUTTAB = gt_it_material.
ENDIF.
endmodule.
Regards,
Saurabhhi,
chk this sampl ceode.
TYPE-POOLS: slis.
CLASS lcl_event_receiver DEFINITION DEFERRED.
TABLES : zmpets_shipactiv, zmpets_chargebk, zmpets_shiphdr.
DATA : BEGIN OF int_crb OCCURS 0,
sel TYPE char1,
icon TYPE icon_d,
pernr LIKE zmpets_cil-pernr,
vorna LIKE pa0002-vorna,
movreason LIKE zmpets_shiphdr-movreason,
shipdocnum LIKE zmpets_chargebk-shipdocnum,
createdon LIKE zmpets_chargebk-createdon,
chargeamount LIKE zmpets_chargebk-chargeamount,
version LIKE zmpets_shipactiv-version,
activity LIKE zmpets_shipactiv-activity,
vendor LIKE zmpets_shiphdr-vendor,
smtp_addr LIKE adr6-smtp_addr,
empperid LIKE zmpets_167doc-empperid,
celltab TYPE lvc_t_styl,
END OF int_crb.
DATA : int_crb_ver LIKE int_crb OCCURS 0 WITH HEADER LINE.
DATA : int_crb_mail LIKE int_crb OCCURS 0 WITH HEADER LINE.
DATA : int_shipactiv LIKE zmpets_shipactiv OCCURS 0 WITH HEADER LINE.
DATA: gt_fieldcatalog TYPE lvc_t_fcat.
DATA : wf_flag TYPE i.
DATA : wf_res TYPE c.
DATA : wf_tabix TYPE sy-tabix.
DATA: BEGIN OF int_sin OCCURS 0,
shipdocnum LIKE zmpets_chargebk-shipdocnum,
shipdocnum LIKE zmpets_shipactiv-petsdocnumber,
END OF int_sin.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA l_num(3).
DATA: ok_code LIKE sy-ucomm,
w_repid LIKE sy-repid,
wl_sno TYPE i VALUE 0,
w_max TYPE i VALUE 100,
wf_layout TYPE lvc_s_layo,
cont_on_main TYPE scrfname VALUE 'GRID_CONTROL',
cont_on_dialog TYPE scrfname VALUE 'GRID_CONTROL',
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
custom_container1 TYPE REF TO cl_gui_custom_container,
custom_container2 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver,
lt_exclude TYPE ui_functions,
ls_celltab TYPE lvc_s_styl,
lt_celltab TYPE lvc_t_styl.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-001.
PARAMETERS : p_cash AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b3.
PERFORM fieldcatalog_init USING gt_fieldcatalog[].
Selection-Screen----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
SELECT-OPTIONS:s_chdate FOR zmpets_chargebk-createdon,
s_pernr FOR zmpets_shiphdr-pernr,
s_mvrsn FOR zmpets_shiphdr-movreason,
s_sin FOR zmpets_chargebk-shipdocnum NO INTERVALS
NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK b1.
PERFORM f_clear_fields.
CALL SCREEN 100.
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
§ 2.In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
new button -
MOVE 'PROCESSED' TO ls_toolbar-function.
MOVE icon_execute_object TO ls_toolbar-icon.
MOVE 'Process the Record'(110) TO ls_toolbar-quickinfo.
MOVE ' Process '(200) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
§ 3.In event handler method for event USER_COMMAND: Query your
function codes defined in step 2 and react accordingly.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'PROCESSED'.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = 'Do you want to process the selected documents?'
TEXTLINE2 = ' '
titel = 'Process Documents'
START_COLUMN = 25
START_ROW = 6
CANCEL_DISPLAY = 'X'
IMPORTING
answer = wf_res.
*--IF THE USER CONFIRMS 'YES',
IF wf_res = 'J'.
PERFORM f_modify_activity.
CALL METHOD grid1->refresh_table_display.
PERFORM SENDINGMAIL.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
MODULE pbo_100 OUTPUT
MODULE pbo_100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
w_repid = sy-repid.
IF custom_container1 IS INITIAL.
*get the data from charge back table
PERFORM select_table_chb.
create a custom container control for our ALV Control
CREATE OBJECT custom_container1
EXPORTING
container_name = cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = w_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
CREATE OBJECT grid1
EXPORTING i_parent = custom_container1.
Set a titlebar for the grid control
wf_layout-grid_title = 'Charge Back'(100).
allow to select multiple lines
wf_layout-sel_mode = 'C'.
wf_layout-stylefname = 'CELLTAB'.
Exclude all edit functions in this example since we do not need them:
PERFORM exclude_tb_functions CHANGING lt_exclude.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = wf_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = lt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
CHANGING
it_outtab = int_crb[]
it_fieldcatalog = gt_fieldcatalog.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR grid1.
SET HANDLER event_receiver->handle_toolbar FOR grid1.
CALL METHOD grid1->set_toolbar_interactive.
ENDIF. "IF grid1 IS INITIAL
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDMODULE. "pbo_100 OUTPUT
MODULE pai_100 INPUT
MODULE pai_100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
PERFORM f_clear_fields.
LEAVE PROGRAM.
WHEN 'CANCEL'.
PERFORM f_clear_fields.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
PERFORM f_clear_fields.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "pai_100 INPUT
**& Form select_table_chb
text
FORM select_table_chb.
IF p_cash = 'X'.
*Consider the pending documents also.
*get the documents which are not processed yet,
*Doctype -> 06 = Charge Back document type.
SELECT zmpets_shiphdrpernr pa0002vorna
zmpets_shiphdrmovreason zmpets_chargebkshipdocnum
zmpets_chargebkcreatedon zmpets_chargebkchargeamount
zmpets_shipactivversion zmpets_shipactivactivity
zmpets_shiphdr~vendor
adr6~smtp_addr
zmpets_167doc~empperid
INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
FROM zmpets_chargebk
JOIN zmpets_shiphdr
ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
JOIN zmpets_shipactiv
ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
JOIN pa0002
ON zmpets_shiphdrpernr = pa0002pernr
JOIN lfa1
ON lfa1lifnr = zmpets_shiphdrvendor
JOIN adr6
ON adr6addrnumber = lfa1adrnr
JOIN zmpets_167doc
ON zmpets_167docpernr = pa0002pernr
WHERE zmpets_shipactiv~doctype = '06'
zmpets_shipactiv~activity NE '30'
ZMPETS_CHARGEBK~CREATEDON IN s_chdate
AND ZMPETS_SHIPHDR~pernr IN s_pernr
AND ZMPETS_SHIPHDR~MOVREASON IN s_mvrsn
AND ZMPETS_CHARGEBK~SHIPDOCNUM IN s_sin
AND zmpets_chargebk~loekz NE 'X'
AND zmpets_shipactiv~loekz NE 'X'
AND zmpets_shiphdr~loekz NE 'X'.
IF sy-subrc <> 0.
*Message is 'No Pending Documents Available.'.
MESSAGE s196(zm050).
ELSE.
LOOP AT int_crb_ver.
*Not yet processed. set to red
int_crb_ver-icon = '@0A@'.
MODIFY int_crb_ver.
ENDLOOP.
PERFORM f_filter_data_pending.
ENDIF.
ELSE.
*Get the document details from pa0002,zmpets_shipactiv,ZMPETS_CHARGEBK
*table.
*Consider document type as '01' during the selection.
*Doctype -> 06 = Charge Back document type.
SELECT zmpets_shiphdrpernr pa0002vorna zmpets_shiphdr~movreason
zmpets_chargebkshipdocnum zmpets_chargebkcreatedon
zmpets_chargebkchargeamount zmpets_shipactivversion
zmpets_shipactivactivity zmpets_shiphdrvendor
*adr6~smtp_addr
zmpets_167doc~empperid
INTO CORRESPONDING FIELDS OF TABLE int_crb_ver
FROM zmpets_chargebk
JOIN zmpets_shiphdr
ON zmpets_chargebkshipdocnum = zmpets_shiphdrshipdocno
JOIN zmpets_shipactiv
ON zmpets_chargebkshipdocnum = zmpets_shipactivpetsdocnumber
JOIN pa0002
ON zmpets_shiphdrpernr = pa0002pernr
JOIN lfa1
ON lfa1lifnr = zmpets_shiphdrvendor
JOIN adr6
ON adr6addrnumber = lfa1adrnr
JOIN zmpets_167doc
ON zmpets_167docpernr = pa0002pernr
WHERE zmpets_chargebk~createdon IN s_chdate
AND zmpets_shiphdr~pernr IN s_pernr
AND zmpets_shiphdr~movreason IN s_mvrsn
AND zmpets_chargebk~shipdocnum IN s_sin
AND zmpets_shipactiv~activity NE '30'
AND zmpets_shipactiv~doctype = '06'
AND zmpets_chargebk~loekz NE 'X'
AND zmpets_shipactiv~loekz NE 'X'
AND zmpets_shiphdr~loekz NE 'X'.
IF sy-subrc <> 0.
*Message is 'No Charge Back Documents Available.'.
MESSAGE s201(zm050).
ELSE.
PERFORM f_filter_data.
ENDIF.
ENDIF.
ENDFORM. "select_table_chb
*& Form UPDATE_RECORDS
text
--> p1 text
<-- p2 text
FORM update_records TABLES p_et_index_rows
STRUCTURE lvc_s_row.
DATA: ls_selected_line LIKE lvc_s_row,
lf_row_index TYPE lvc_index.
LOOP AT p_et_index_rows INTO ls_selected_line.
lf_row_index = ls_selected_line-index.
ENDLOOP.
ENDFORM. " UPDATE_RECORDS
**& Form fieldcatalog_init
text
-->P_GT_FIELDCATALOG[] text
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat.
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'SEL'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-col_pos = 1.
ls_fieldcatalog-edit = 'X'.
ls_fieldcatalog-reptext = 'Select for Processing'.
ls_fieldcatalog-coltext = 'Select for Processing'.
ls_fieldcatalog-seltext = 'Select for Processing'.
ls_fieldcatalog-tooltip = 'Select for Processing'.
ls_fieldcatalog-checkbox = 'X'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ICON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'CHAR'.
ls_fieldcatalog-col_pos = 2.
ls_fieldcatalog-intlen = '4'.
ls_fieldcatalog-reptext = 'Status'.
ls_fieldcatalog-coltext = 'Status'.
ls_fieldcatalog-seltext = 'Status'.
ls_fieldcatalog-tooltip = 'Status'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'PERNR'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-col_pos = 2.
ls_fieldcatalog-intlen = '8'.
ls_fieldcatalog-reptext = 'Employee Number'.
ls_fieldcatalog-coltext = 'Employee Number'.
ls_fieldcatalog-seltext = 'Employee Number'.
ls_fieldcatalog-tooltip = 'Employee Number'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'VORNA'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 3 .
ls_fieldcatalog-datatype = 'CHAR'.
ls_fieldcatalog-outputlen = '20'.
ls_fieldcatalog-reptext = 'Employee Name'.
ls_fieldcatalog-coltext = 'Employee Name'.
ls_fieldcatalog-seltext = 'Employee Name'.
ls_fieldcatalog-tooltip = 'Employee Name'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'MOVREASON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 4.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-outputlen = '10'.
ls_fieldcatalog-reptext = 'Move Reason'.
ls_fieldcatalog-coltext = 'Move Reason'.
ls_fieldcatalog-seltext = 'Move Reason'.
ls_fieldcatalog-tooltip = 'Move Reason'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'SHIPDOCNUM'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-datatype = 'NUMC'.
ls_fieldcatalog-outputlen = '10'.
ls_fieldcatalog-col_pos = 5.
ls_fieldcatalog-reptext = 'Shipping Document Number'.
ls_fieldcatalog-coltext = 'Shipping Document Number'.
ls_fieldcatalog-seltext = 'Shipping Document Number'.
ls_fieldcatalog-tooltip = 'Shipping Document Number'.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'CREATEDON'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 6.
ls_fieldcatalog-datatype = 'DATS'.
ls_fieldcatalog-outputlen = '8'.
ls_fieldcatalog-reptext = 'Created On'.
ls_fieldcatalog-coltext = 'Created On'.
ls_fieldcatalog-seltext = 'Created On'.
ls_fieldcatalog-tooltip = 'Created On'.
ls_fieldcatalog-DO_sum = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'CHARGEAMOUNT'.
ls_fieldcatalog-tabname = 'INT_CRB'.
ls_fieldcatalog-col_pos = 7.
ls_fieldcatalog-datatype = 'CURR'.
ls_fieldcatalog-outputlen = '13'.
ls_fieldcatalog-reptext = 'Charge Back Amount'.
ls_fieldcatalog-coltext = 'Charge Back Amount'.
ls_fieldcatalog-seltext = 'Charge Back Amount'.
ls_fieldcatalog-tooltip = 'Charge Back Amount'.
ls_fieldcatalog-DO_sum = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM. "fieldcatalog_init
*& Form f_modify_activity
Modify the activity to 79 in zmpets_shipaciv table.
--> p1 text
<-- p2 text
FORM f_modify_activity .
REFRESH int_crb_mail.
int_crb_mail[] = int_crb[].
*All the document number which is to be processed is stored in
*the internel table 'INT_SIN'.
LOOP AT int_crb INTO int_crb.
IF int_crb-sel ='X'.
MOVE int_crb-shipdocnum TO int_sin.
APPEND int_sin.
CLEAR int_sin.
*Removing the processed documents.
DELETE int_crb.
ENDIF.
CLEAR int_crb.
ENDLOOP.
*Get the details from shipactiv table.
IF int_sin[] IS NOT INITIAL.
SELECT * FROM zmpets_shipactiv
INTO TABLE int_shipactiv
FOR ALL ENTRIES IN int_sin
WHERE petsdocnumber = int_sin-shipdocnum.
*Modify the activity code, version, actual date and last changed date.
SORT int_shipactiv BY petsdocnumber version DESCENDING.
CLEAR wf_tabix.
LOOP AT int_shipactiv.
wf_tabix = sy-tabix.
AT NEW petsdocnumber.
READ TABLE int_shipactiv INDEX wf_tabix.
int_shipactiv-activity = '030'.
int_shipactiv-version = int_shipactiv-version + 1.
int_shipactiv-actdate = sy-datum.
int_shipactiv-lastchangedby = sy-uname.
int_shipactiv-lastchangedt = sy-datum.
*Modify the data base table
MODIFY zmpets_shipactiv FROM int_shipactiv.
ENDAT.
CLEAR int_shipactiv.
AT LAST.
*Message is 'Data Processed Successfully.'.
MESSAGE s203(zm050).
ENDAT.
ENDLOOP.
*-send mail to the vendor and employee that the shipment is cleared for
LOOP AT int_crb_mail WHERE sel = 'X'.
PERFORM f_send_mail.
ENDLOOP.
REFRESH int_crb_mail.
CALL SELECTION-SCREEN 1000.
ELSE.
*Message is 'No Data Selected for Processing.'.
MESSAGE s200(zm050).
ENDIF.
ENDFORM. " f_modify_activity
*& Form f_clear_fields
text
--> p1 text
<-- p2 text
FORM f_clear_fields .
CLEAR int_crb.
CLEAR int_crb_ver.
CLEAR int_sin.
REFRESH int_crb.
REFRESH int_crb_ver.
REFRESH int_sin.
CLEAR int_shipactiv.
REFRESH int_shipactiv.
CLEAR wf_flag.
CLEAR wf_tabix.
ENDFORM. " f_clear_fields
*& Form f_filter_data
text
--> p1 text
<-- p2 text
FORM f_filter_data .
*Take the latest Version Data.
*take all the activities, including the activity '30'.
then put the details in internal table 'INT_CRB'.
SORT int_crb_ver BY shipdocnum version DESCENDING.
CLEAR wf_tabix.
CLEAR int_crb.
REFRESH int_crb.
LOOP AT int_crb_ver.
wf_tabix = sy-tabix.
AT NEW shipdocnum.
READ TABLE int_crb_ver INDEX wf_tabix.
MOVE-CORRESPONDING int_crb_ver TO int_crb.
APPEND int_crb.
CLEAR int_crb.
ENDAT.
ENDLOOP.
IF int_crb[] IS INITIAL.
*Message is 'No Records Available.'.
MESSAGE s202(zm050).
ELSE.
CLEAR wf_tabix.
LOOP AT int_crb.
wf_tabix = sy-tabix.
REFRESH lt_celltab.
ls_celltab-fieldname = 'SEL'.
IF int_crb-activity = '030'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
*status becomes green. ie processed
int_crb-icon = '@08@'. "Green
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
*status set to red. ie not yet processed
int_crb-icon = '@0A@'. "Red
ENDIF.
INSERT ls_celltab INTO TABLE lt_celltab.
INSERT LINES OF lt_celltab INTO TABLE int_crb-celltab.
MODIFY int_crb INDEX wf_tabix.
ENDLOOP.
ENDIF.
ENDFORM. " f_filter_data
*& Form f_filter_data
text
--> p1 text
<-- p2 text
FORM f_filter_data_pending.
*Take the latest Version Data.
*take all the activities, including the activity '30'.
*then filter it with out the activities '30' and having the lastest
*version. then put the details in internal table 'INT_CRB'.
SORT int_crb_ver BY shipdocnum version DESCENDING.
CLEAR wf_tabix.
CLEAR int_crb.
REFRESH int_crb.
LOOP AT int_crb_ver.
wf_tabix = sy-tabix.
AT NEW shipdocnum.
READ TABLE int_crb_ver INDEX wf_tabix.
IF int_crb_ver-activity NE '030'.
MOVE-CORRESPONDING int_crb_ver TO int_crb.
APPEND int_crb.
CLEAR int_crb.
ENDIF.
ENDAT.
ENDLOOP.
IF int_crb[] IS INITIAL.
*Message is 'No Records Available.'.
MESSAGE s202(zm050).
ENDIF.
ENDFORM. " f_filter_data_pending
*& Form EXCLUDE_TB_FUNCTIONS
text
<--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form f_send_mail
text
--> p1 text
<-- p2 text
FORM f_send_mail .
*store the vendor name, vendor email id , employee name and employee
*email id in the internal table int_crb
Creation of the document to be sent
CLEAR doc_chng.
REFRESH objpack.
REFRESH objhead.
REFRESH reclist.
REFRESH objtxt.
File Name
doc_chng-obj_name = 'SHIPMENT'.
Mail Subject
CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
'Cleared.'
INTO doc_chng-obj_descr SEPARATED BY ' '.
Mail Contents
objtxt-line = 'Hi,'.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
CLEAR objtxt.
objtxt-line = 'Regards '.
APPEND objtxt.
objtxt-line = ' '.
APPEND objtxt.
objtxt-line = 'SAP '.
APPEND objtxt.
CLEAR objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
objtxt ).
Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Completing the recipient list
target recipent
CLEAR reclist.
reclist-receiver = int_crb_mail-empperid. "employee email ID
"wf_empperid.
reclist-express = 'X'.
reclist-rec_type = 'U'.
APPEND reclist.
copy recipents
CLEAR reclist.
reclist-receiver = 'anversha.shahul@'."int_crb_mail-smtp_addr
reclist-express = 'X'.
reclist-rec_type = 'U'.
reclist-copy = 'X'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
COMMIT WORK.
SUBMIT rsconn01
WITH mode = 'INT'
WITH output = ' '
AND RETURN.
ENDFORM. " f_send_mail
rgds
anver
pls mark hlpful answers -
ALV program with Field Catalog
Hi ,
Can any body please provide me sample ALV programs with Field Catalog and GRID DISPLAY. and also please give me the steps for writing the program.
Thanks in advance.
KPHi,
For ALV GRID DISPLAY (using <b>OOPS</b>),
1)Create an object of the <b>container</b>(an instance of a class like cl_gui_custom_container).
2)Create an object of the <b>ALV using class cl_gui_alv_grid</b> and give the CONTAINER name that you define in your screen layout as the parent of the ALV.
3)Call the method <b>SET_TABLE_FOR_FIRST_DISPLAY</b> of the class cl_gui_alv_grid.
4)<b>Field catalog</b> is used when you want a variation of the standard structure to be displayed on your ALV.A variable of table type <b>LVC_T_FCAT</b> is defined and variations can be made as per the requirements.The variable is then passed in the method SET_TABLE_FOR_FIRST_DISPLAY.
<b>A SAMPLE PROGRAM:</b>
REPORT SAMPLE:
*-- GLOBAL DATA DECLARATIONS FOR ALV
<b>DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.</b>
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
<b>DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.</b>
DATA gt_fieldcat TYPE lvc_t_fcat.
Data:i_spfli type table of spfli.
*The value CC_ALV is given to the custom container in the screen layout
START-OF-SELECTION.
select * from spfli into table i_spfli.
Call screen 100.
MODULE STATUS_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
*Create container
<b>CREATE OBJECT gr_ccontainer
EXPORTING container_name = gc_custom_control_name.</b>
*Create ALV
<b>CREATE OBJECT gr_alvgrid
EXPORTING i_parent = gr_ccontainer.</b>
*field catalog
<b>PERFORM prepare_field_catalog CHANGING gt_fieldcat.</b>
*to display the ALV
<b>CALL METHOD gr_alvgrid->set_table_for_first_display</b>
EXPORTING
I_STRUCTURE_NAME = 'SPFLI'
CHANGING
it_outtab = i_spfli[]
it_fieldcatalog = gt_fieldcat.
ENDMODULE. "display_alv OUTPUT
MODULE USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
IF sy-ucomm = 'BACK' OR
sy-ucomm = 'EXIT' OR
sy-ucomm = 'CANCEL'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
*& Form prepare_field_catalog
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-ref_table = 'SPFLI'.
ls_fcat-fieldname = 'CARRID'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'CONNID'.
ls_fcat-ref_table = 'SPFLI'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'DEPTIME'.
ls_fcat-ref_table = 'SPFLI'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'ARRTIME'.
ls_fcat-ref_table = 'SPFLI'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
endform.
<b>For more sample programs refer:</b>http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
<b>-->download the PDF from following link.</b>
www.abap4.it/download/ALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
<b>Some more:</b>
http://www.sap-hefte.de/download/dateien/1025/087_leseprobe.pdf
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
http://www.alvgmbh.de/dwnload/gonio_t.pdfhttp://
<b>You can get all demo programs for ALV:</b>Go to se38 and type BCALV* and press F4 for all demo porgrams.
Regards,
Beejal
**Reward if this helps -
hi friends,
i am using factory method to display my alv. now some of the fields in my internal table i have declared them as char fields, i want certain type of headings for these fields,so where can i give heading to these fields.
where exactly do we create a field catalog for factory method.
pls advice me on thishi
good
go throgh this code
*& Report Z_ALV_OOPS
REPORT Z_ALV_OOPS.
*Event class Definition "Event handler class
class event_handle definition.
public section.
methods: handle_user
for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass.
*Event class Implementation
class event_handle implementation.
method handle_user.
write:/ ''.
endmethod.
endclass.
Data: t_alv type ref to cl_gui_alv_grid, "ALV control
t_cont type ref to cl_gui_custom_container, "Cust Container
t_alv2 type ref to cl_gui_alv_grid, "ALV control
t_cont2 type ref to cl_gui_custom_container, "Cust Container
t_fieldcat type lvc_t_fcat with header line, "Field Cat
t_fieldcat2 type lvc_t_fcat with header line, "Field Cat
t_layout type lvc_s_layo, "Layout
t_event type ref to event_handle, "Event handler
t_sort type LVC_T_SORT with header line, "Sort
t_toolbar type ui_functions with header line. "Toolbar xclude
Types: begin of g_vbak, "Header Table
vbeln like vbak-vbeln,
auart like vbak-auart,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
spart like vbak-spart,
kunnr like vbak-kunnr,
bstnk like vbak-bstnk,
seltab,
end of g_vbak.
Types: begin of g_vbap, "Item Table
vbeln like vbap-vbeln,
posnr(6) type c,
posrn like vbap-posnr,
matnr like vbap-matnr,
netwr like vbap-netwr,
waerk like vbap-waerk,
end of g_vbap.
Data: t_vbak type g_vbak occurs 0,
t_vbap type g_vbap occurs 0.
Start-Of-Selection.
*Fetch data from DB Table
select vbeln auart vkorg vtweg spart kunnr bstnk
from vbak into table t_vbak up to 20 rows.
End-Of-Selection.
*Call ALV screen
call screen 100.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ALV'.
SET TITLEBAR 'VBAK'.
if t_cont is initial.
create object t_cont
exporting
container_name = 'ALV'.
create object t_alv
exporting
i_parent = t_cont.
*Create event handlers
create object t_event.
set handler t_event->handle_user for t_alv.
perform build_fieldcatlog.
perform build_layout.
perform xclude_toolbar.
CALL METHOD t_alv->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = t_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = t_toolbar[]
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = t_vbak[]
IT_FIELDCATALOG = t_fieldcat[]
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
Data: lt_rows type lvc_t_row,
wa_rows type line of lvc_t_row,
wa_vbak type g_vbak,
l_lines type i.
refresh: t_vbap.
case sy-ucomm.
when 'DET'. "Item details
Get selected rows from ALV
call method t_alv->get_selected_rows
importing
et_index_rows = lt_rows.
Fetch corresponding Item details from VBAP
loop at lt_rows into wa_rows.
read table t_vbak into wa_vbak index wa_rows-index transporting
vbeln.
select vbeln posnr matnr netwr waerk from vbap
appending corresponding fields of table t_vbap
where vbeln = wa_vbak-vbeln.
endloop.
Prepare fieldcatlog
Display Item details in ALV
call screen 200 starting at 8 5.
when 'SHOW'. "Display order
call method t_alv->get_selected_rows
importing
et_index_rows = lt_rows.
Describe table lt_rows lines l_lines.
if l_lines > 1.
message e999(z_error).
else.
read table lt_rows into wa_rows index 1.
read table t_vbak into wa_vbak index wa_rows-index transporting
vbeln.
set parameter id 'AUN' field wa_vbak-vbeln.
call transaction 'VA03' and skip first screen.
endif.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form build_fieldcatlog
text
form build_fieldcatlog .
clear t_fieldcat.
t_fieldcat-col_pos = '1'.
t_fieldcat-fieldname = 'VBELN'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VBELN'.
append t_fieldcat.
t_fieldcat-col_pos = '2'.
t_fieldcat-fieldname = 'AUART'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'AUART'.
append t_fieldcat.
t_fieldcat-col_pos = '3'.
t_fieldcat-fieldname = 'VKORG'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VKORG'.
append t_fieldcat.
t_fieldcat-col_pos = '4'.
t_fieldcat-fieldname = 'VTWEG'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'VTWEG'.
append t_fieldcat.
t_fieldcat-col_pos = '5'.
t_fieldcat-fieldname = 'SPART'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'SPART'.
append t_fieldcat.
t_fieldcat-col_pos = '6'.
t_fieldcat-fieldname = 'KUNNR'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'KUNNR'.
append t_fieldcat.
t_fieldcat-col_pos = '7'.
t_fieldcat-fieldname = 'BSTNK'.
t_fieldcat-ref_table = 'VBAK'.
t_fieldcat-ref_field = 'BSTNK'.
append t_fieldcat.
endform. " build_fieldcatlog
*& Module LEAVE INPUT
text
module LEAVE input.
case sy-ucomm.
when 'BACK' or 'EXIT' or 'CANCEL'.
leave program.
endcase.
endmodule. " LEAVE INPUT
*& Form build_layout
text
--> p1 text
<-- p2 text
form build_layout .
t_layout-zebra = 'X'.
t_layout-sel_mode = 'A'.
t_layout-grid_title = 'Header Details'.
endform. " build_layout
*& Form build_fcat_vbap
text
form build_fcat_vbap .
clear t_fieldcat2.
t_fieldcat2-scrtext_m = 'Sales Doc'.
t_fieldcat2-col_pos = 1.
t_fieldcat2-fieldname = 'VBELN'.
t_fieldcat2-tabname = 'T_VBAP'.
t_fieldcat2-no_zero = 'X'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'VBELN'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 2.
t_fieldcat2-scrtext_m = 'Item'.
t_fieldcat2-fieldname = 'POSNR'.
t_fieldcat2-tabname = 'T_VBAP'.
t_fieldcat2-intlen = '6'.
t_fieldcat2-inttype = 'C'.
t_fieldcat2-no_zero = 'X'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'POSNR'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 3.
t_fieldcat2-fieldname = 'MATNR'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'MATNR'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 4.
t_fieldcat2-fieldname = 'NETWR'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'NETWR'.
t_fieldcat2-do_sum = 'X'.
append t_fieldcat2.
clear t_fieldcat2.
t_fieldcat2-col_pos = 5.
t_fieldcat2-fieldname = 'WAERK'.
t_fieldcat2-ref_table = 'VBAP'.
t_fieldcat2-ref_field = 'WAERK'.
append t_fieldcat2.
endform. " build_fcat_vbap
*& Module STATUS_0200 OUTPUT
text
module STATUS_0200 output.
SET PF-STATUS 'ITEM1'.
SET TITLEBAR 'VBAP'.
perform build_fcat_vbap.
perform sort_alv2.
if t_cont2 is initial.
create object t_cont2
exporting
container_name = 'ITEM'.
create object t_alv2
exporting
i_parent = t_cont2.
t_layout-grid_title = 'Item Details'.
CALL METHOD t_alv2->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = t_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = t_toolbar[]
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = t_vbap[]
IT_FIELDCATALOG = t_fieldcat2[]
IT_SORT = t_sort[]
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
else.
CALL METHOD t_alv2->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
endmodule. " STATUS_0200 OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
module USER_COMMAND_0200 input.
case sy-ucomm.
when 'GOBACK'.
leave to screen 0.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
*& Form sort_alv2
text
--> p1 text
<-- p2 text
form sort_alv2 .
clear t_sort.
t_sort-spos = '1'.
t_sort-fieldname = 'VBELN'.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
append t_sort.
endform. " sort_alv2
*& Form xclude_toolbar
text
--> p1 text
<-- p2 text
form xclude_toolbar .
t_toolbar = '&DETAIL'.
append t_toolbar.
t_toolbar = '&&SEP00'.
append t_toolbar.
t_toolbar = '&&SEP01'.
append t_toolbar.
t_toolbar = '&&SEP02'.
append t_toolbar.
t_toolbar = '&SORT_ASC'.
append t_toolbar.
t_toolbar = '&SORT_DSC'.
append t_toolbar.
t_toolbar = '&FIND'.
append t_toolbar.
t_toolbar = '&MB_FILTER'.
append t_toolbar.
t_toolbar = '&&SEP04'.
append t_toolbar.
t_toolbar = '&MB_SUM'.
append t_toolbar.
t_toolbar = '&MB_SUB_TOTAL'.
append t_toolbar.
t_toolbar = '&PRINT_BACK'.
append t_toolbar.
t_toolbar = '&MB_VIEW'.
append t_toolbar.
t_toolbar = '&MB_EXPORT'.
append t_toolbar.
t_toolbar = '&GRAPH'.
append t_toolbar.
t_toolbar = '&COLO'.
append t_toolbar.
t_toolbar = '&&SEP06'.
append t_toolbar.
t_toolbar = '&&SEP07'.
append t_toolbar.
t_toolbar = '&INFO'.
append t_toolbar.
t_toolbar = '&&SEP03'.
append t_toolbar.
endform. " xclude_toolbar
reward point if helpful.
thanks
mrutyun^ -
Error in updating ALV field catalog in selection tool for Planning Book
Hi ,
I am Implementing BADI '/SAPAPO/SDP_SELECTOR' to upload Custom Fields Data in Planning Book Selection Window under APO Location Product. These Custom Fields are maintained in Custom Table.So from Table whatever Custom Fields are availabe all the fields needs to be available in for selection. Once selection is done the same data to be uploaded into Planning Book.
This BADI is working Fine upto 4 fields but if any extra fields are added in the table 'Error in updating ALV field catalog in selection tool' error Pop Up is coming. Here i am using Folloowing Methods
1). INIT_OBJECT_LIST
2). F4
3). LOC_PROD_VALUE_LIST
Please help on the same if u have any idea or clue.
Thanks.Hi Srinivas!
Where did you get your implementation from?
It would be nice if you could debug your code!
For the F4 method, have you seen this note?
Note 544904 - Sample source code f.BAdI /SAPAPO/SDP_SELECTOR ('F4'method)
Also check this note. It contains selection modifications in the BAdI:
Note 376902 - SDP selector: Basis corrections for BADI
I do not know your release and support package in your SCM, but you can find a lot of notes related to this BAdI.
Thank you!
Will
SCM Support Consultant -
Error in updating ALV field catalog in selection
Dear all,
I'm trying to use the standard transaction /SAPAPO/TSKEYFMAIN in order to check the TS values.
After filling the selection variant, the system shows the following error:
'Error in updating ALV field catalog in selection'
Could you please provide me with further details about the error? What could be the possible solution to avoid it?
Many thanks,
SMHi Marius,
thanks for your answer.
I would like to use the /SAPAPO/TSKEYFMAIN transaction to check massively the values in the time series KFs and not just the consistency of them.
So do you know any other transaction to do it or do you have an idea about the error of /SAPAPO/TSKEYFMAIN?
Thanks for your help!
SM -
Field catalog for internal table in ALV
In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
In order to get output in ALV grid following FM has been used
REUSE_ALV_GRID_DISPLAY
for field catalog the fields are defined specifically.
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-outputlen = 10.
l_fieldcat-seltext_l = 'Billing doc'.
l_fieldcat-no_zero = 'X'.
l_fieldcat-hotspot = 'X'.
append l_fieldcat to p_fieldtab.
..............and so on for all the fields.
Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
anyaHi
Try this instead:
*& Form create_fieldcatalog
* Create a field catalogue from any internal table
* -->PT_TABLE Internal table
* -->PT_FIELDCAT Field Catalogue
FORM create_fieldcatalog
USING pt_table TYPE ANY TABLE
CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA:
lr_tabdescr TYPE REF TO cl_abap_structdescr
, lr_data TYPE REF TO data
, lt_dfies TYPE ddfields
, ls_dfies TYPE dfies
, ls_fieldcat TYPE lvc_s_fcat
CLEAR pt_fieldcat.
CREATE DATA lr_data LIKE LINE OF pt_table.
lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
LOOP AT lt_dfies
INTO ls_dfies.
CLEAR ls_fieldcat.
MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
APPEND ls_fieldcat TO pt_fieldcat.
ENDLOOP.
ENDFORM. "create_fieldcatalog -
Field not present in the Field Catalog also getting displayed in the ALV
Hi Experts,
I am trying to display some to an ALV grid. But since i don't need all the fields from the internal table, i have deleted those fields from the field catalog. But in-spite of doing this the field heading is still getting displayed. I am not able to figure out the reason for this. Also note that the i have not deleted that field from my internal table which contains the actual data.
Regards,
KushHi,
If your giving your internal table to the below field then ALV try to disply those many coloumn.
wa_fcat-tabname = 'IT_OUTPUT'.
You can add for that field name.
wa_fcat--NO_OUT = 'X'.
Please check the field name on the output will be same as before column name . -
Field Catalog Not Found in ALV
Hi Experts,
I am trying to exceute the below code its shows the Field CataLog Not Found
Code is:
TYPE-POOLS:slis.
TABLES:ekpo,mseg.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
END OF ty_ekpo.
TYPES: BEGIN OF ty_mseg,
ebeln TYPE mseg-ebeln,
ebelp TYPE mseg-ebelp,
matnr TYPE mseg-matnr,
menge TYPE mseg-menge,
bwart TYPE mseg-bwart,
END OF ty_mseg.
TYPES: BEGIN OF ty_final,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
qtysup TYPE MENGE_D,
qtyact TYPE MENGE_D,
qtyrej TYPE MENGE_D,
END OF ty_final.
DATA: it_mseg TYPE TABLE OF ty_mseg WITH HEADER LINE,
it_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE,
it_final TYPE TABLE OF ty_final WITH HEADER LINE.
DATA: wa_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv.
DATA:wa_mseg LIKE LINE OF it_mseg,
wa_ekpo LIKE LINE OF it_ekpo ,
wa_final LIKE LINE OF it_final.
SELECT-OPTIONS: p_ebeln FOR ekpo-ebeln.
START-OF-SELECTION.
SELECT ebeln ebelp matnr menge FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln IN p_ebeln.
IF it_ekpo[] IS NOT INITIAL.
SELECT ebeln ebelp matnr menge bwart FROM mseg
INTO TABLE it_mseg
FOR ALL ENTRIES IN it_ekpo[]
WHERE ebeln EQ it_ekpo-ebeln
AND ebelp EQ it_ekpo-ebelp
AND bwart EQ '122'.
ENDIF.
LOOP AT it_mseg .
READ TABLE it_ekpo WITH KEY ebeln = it_mseg-ebeln.
IF sy-subrc EQ 0.
it_final-qtyrej = it_mseg-menge.
it_final-qtysup = it_ekpo-menge.
it_final-ebeln = it_mseg-ebeln.
it_final-ebelp = it_mseg-ebelp.
ENDIF.
IF sy-subrc EQ 0.
it_final-qtyact = ( it_final-qtysup ) - ( it_final-qtyrej ).
ENDIF.
APPEND it_final.
ENDLOOP.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_l = 'Purchase Doc'.
wa_fieldcat-seltext_m = wa_fieldcat-seltext_l.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_l.
wa_fieldcat-col_pos = 1.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_l = 'Item'.
wa_fieldcat-seltext_m = wa_fieldcat-seltext_l.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_l.
wa_fieldcat-col_pos = 2.
wa_fieldcat-outputlen = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'QTYSUP'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_l = 'QuatitySupply'.
wa_fieldcat-seltext_m = wa_fieldcat-seltext_l.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_l.
wa_fieldcat-col_pos = 3.
wa_fieldcat-outputlen = 13.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'QTYACT'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_l = 'QualityAccepted'.
wa_fieldcat-seltext_m = wa_fieldcat-seltext_l.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_l.
wa_fieldcat-col_pos = 4.
wa_fieldcat-outputlen = 13.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'QTYREJ'.
wa_fieldcat-tabname = 'IT_FINAL'.
wa_fieldcat-seltext_l = 'QualityRejected'.
wa_fieldcat-seltext_m = wa_fieldcat-seltext_l.
wa_fieldcat-seltext_s = wa_fieldcat-seltext_l.
wa_fieldcat-col_pos = 5.
wa_fieldcat-outputlen = 13.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
DATA: repid LIKE sy-repid.
repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = repid
TABLES
t_outtab = it_final[]
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.
Thanks In Advance
PoornaHi,
pass parametrs as it is given below...
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_final[]
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.
Thanks & Regards
Ashu -
Hi Friends,
Please help me out, I am new to ABAP.
Please anybody explain me the functionality of Field catalogs in ALVs?
How many methods are there to pass data to ALVs, i.e., in how many ways?
Hope u will help me.hi,
this will be very helpful for ALV REPORTING.....
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain upto 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
The different steps used for getting the above function modules into use are:
Step 1
DATA DECLARATION
Sap standard type pools: SLIS , KKBLO .
Sap standard tables types taken from the type pools are: SLIS_LAYOUT_ALV ,
SLIS_T_FIELDCAT_ALV,
SLIS_T_LISTHEADER,
SLIS_T_EVENT,
SLIS_SELFIELD.
Internal tables to used in the program declared based on the above table types
DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
I_HEADING TYPE SLIS_T_LISTHEADER,
I_EVENTS TYPE SLIS_T_EVENT.
TYPES: KKBLO_SELFIELD TYPE SLIS_SELFIELD.
Step 2 (Optional)
SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
Sample code:
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = variant save condition ( A=all, U = user-specific )
CHANGING
cs_variant = internal table containing the program name (and the default variant---optional )
EXCEPTIONS
not_found = 2.
The user can also choose from the list of existing variants using the function module REUSE_ALV_VARIANT_F4.
Step 3
DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOG
A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
1. The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE. In this case the attributes of the different fields is taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly.
2. all fields in this structure are to be output
3. The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.
All the values entered in the catalog is specific to the particular field whose name is entered in the fieldname FIELDNAME of the fieldcat structure. The name of the table is also entered in the corr. Fieldname TABNAME of the structure.
The different possible attributes are:
Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output.
Value set: 0, 1 3
Col_pos (column position): This parameter is relevant when the fields in the output are to be different from the sequence of the fields in the internal table used for display. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the internal table field sequence.
Value set: 0, 1 60
Fieldname (field name): This is the name of the internal table field for which the parameters are passed in the catalog.
Value set: internal output table field name (required parameter)
Tabname (internal output table): Name of the internal output table that contains the field FIELDCAT-FIELDNAME above.
Value set: SPACE, internal output table name.
Ref_fieldname (reference field name): Name of the Data Dictionary field referred to. This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
Value set: SPACE, Data Dictionary field name.
Ref_tabname (reference table/structure field name): Structure or table name of the referred Data Dictionary field. This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
Value set: SPACE, name of a Data Dictionary structure or table
Link to currency unit
Cfieldname (currency unit field name): This is used for currency fields that have a reference to any unit field. This is only relevant for amount columns with associated unit. This parameter contains the Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
Value set: SPACE, output table field name
Ctabname (internal currency unit field output table): Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
Value set: SPACE, output table field name.
Link to measurement unit
Qfieldname (measurement unit field name): Only relevant for quantity columns with unit link. Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME. The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
Value set: SPACE, output table field name.
Qtabname (internal measurement unit field output table): Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
Value set: SPACE, output table field name.
Outputlen (column width): This parameter is used if the desired output length for a field is desired to be different from the internal output table field. For fields with a Data Dictionary link this parameter can be left initial. For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
Initial = column width is the output length of the referred Data Dictionary field (domain).
N = column width is n characters.
Value set: 0 (initial), n.
Key (key column): By default, the system makes some fields in the output as key fields, provided the fields are key fields in their referencing table. Using this parameter, fields other than key fields of the referencing table can be made key field. This parameter is most important if the output needs to contain some field which are not scrollable or cannot be hidden.
If the internal output table contains fields that are key fields from different tables, then all those fields in the report output becomes unscrollable and cannot be hidden. So, the fields in the output internal table should not be referenced from tables in which they are key fields. Instead, they should be referenced to the tables in which they are not key fields, incase they are not desired as key field in the output.
'X' = key field (key field output in color) and Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
Value set: SPACE, 'X'.
Key_sel (hideable key column): This parameter is only relevant for the fields which are made key fields using FIELDCAT-KEY = 'X'. Using this parameter the Key field can be hidden interactively.
The key column sequence cannot be changed interactively by the user. The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
Value set: SPACE, 'X'.
No_out (field in field list): This parameter is used to remove certain fields from the output during initial display. The user can however interactively choose the field for output from the field list in the display variant.
'X' = field is not displayed in the current list.
Value set: SPACE, 'X'.
Tech (technical field): This parameter is used to make certain field display only in the field catalog. The fields with this parameter set cannot be output in the list nor can they be displayed interactively from the catalog.
'X' = technical field.
Value set: SPACE, 'X'.
Emphasize (highlight columns in color): As name suggests, this field parameter is used to highlight certain field with chosen colors.
Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
- C: Color (coding must begin with C)
- X: color number
- Y: bold
- Z: inverse
Hotspot (column as hotspot): This parameter is used to make certain field appear as hotspot i.e. a hand is displayed if the cursor is positioned on the field value. Single click on such fields cause the PICK OR F2 events to happen.
Value set: SPACE, 'X'.
'X' = column cells are output as hotspots.
Fix_column (fix column): This parameter is used to fix certain columns in the output. All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively.
Value set: SPACE, 'X'.
'X' = column fixed (does not scroll horizontally).
Do_sum (sum over column): the user can also call this function interactively.
Value set: SPACE, 'X'.
'X' = a sum is calculated over this internal output table field.
No_sum (sums forbidden): No sum can be calculated over this field, although the data type of the field would allow summing.
Value set: SPACE, 'X'.
Icon: The parameter displays certain column contents as icons. The internal output table column contents must be valid icon strings.
Value set: SPACE, 'X'.
'X' = column contents to be output as an icon.
Symbol: The internal output table column must be a valid symbol character.
Value set: SPACE, 'X'
'X' = column contents are to be output as a symbol.
Just (justification): This parameter is used for alignment of the contents of the output table. This is only relevant for CHAR or NUMC fields in the output internal table. The justification of the column header always follows the justification of the columns. Independent justification of the column header is not possible.
Value set: SPACE, 'R', 'L', and C.
' ' = Default justification for this data type
'R' = right-justified output
'L' = left-justified output
'C' = centered output.
Lzero (leading zeros): By default ALV outputs NUMC fields right-justified without leading zeros. Using this parameter only the NUMC fields can be displayed with leading zeroes.
Value set: SPACE, 'X'.
'X' = output with leading zeros.
No_sign (no +/- sign): This parameter is used to suppress the signs of the output fields. It is only relevant for the value fields.
Value set: SPACE, 'X'.
'X' = value output without +/ sign.
No_zero (suppress zeros): Only relevant for value fields.
Value set: SPACE, 'X'.
'X' = suppress zeros.
Edit_mask (field formatting): To apply the report output formatting options same as in the WRITE statement in report writing.
Value set: SPACE, template.
The following parameters are used for customizing the texts in the heading of the output of the columns. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored.
If the user changes the column width interactively, the column header text with the appropriate length is always used.
The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
The 'long field label' is also used in display variant definition,
Sort, etc. Popup.
seltext_l (long field label)
seltext_m (medium field label)
seltext_s (short field label)
reptext_ddic(header) Analogous to the Data element main header
Ddictxt (specify text) : You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
Value set: SPACE, 'L', 'M', and S.
Sample code:
Suppose I_PO_DETAILS is an internal table containing two fields EBELN (PO number) and EBELP (PO item no).
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV. Local variable to hold the parameters
for a particular field of the field catalog
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-KEY = 'X'. The PO no is made the key field,
Colored and non scrollable
L_FIELDCAT-HOTSPOT = 'X'. The po no becomes a hotspot
L_FIELDCAT-SELTEXT_S = P.O No.
L_FIELDCAT-SELTEXT_M = 'P order No'.
L_FIELDCAT-SELTEXT_L = 'Purchase order No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-KEY = 'X'. The po item no is made the key field,
Colored and non scrollable
L_FIELDCAT-SELTEXT_S = 'Item No'.
L_FIELDCAT-SELTEXT_M = 'Item No`.
L_FIELDCAT-SELTEXT_L = 'PO Item No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT
Thus the catalog for the report output is prepared.
Step 4
The next step is to build an event table, which are used for firing both user commands and the system dependent events i.e. top of page, end of page etc.
A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
The function module contains following import and export parameters.
IMPORTING PARAMETERS: I_LIST_TYPE
This parameter has possible values from 0-4.
The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .
EXPORTING PARAMETERS: I_EVENTS table.
This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.
The table structure contains the fields:
I_EVENTS-NAME: Name of the Callback event.
I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.
Only events with a form routine name are processed.
The I_EVENTS table returns with the following possible constants:
1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.
Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.
2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.
RS_SELFIELD is initial in this case.
3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.
Is called at the beginning of the function module to make special settings. It is not usually used.
4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
Equivalent to the list processing TOP-OF-PAGE event.
6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.
The selection information and list status are output together (if they exist) on a separate page by default
7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.
Analogously to TOP_OF_COVERPAGE the user can add other information
to the information output by ALV (selection information, list status) at this event.
8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE FOREIGN_TOP_OF_PAGE'.
The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.
The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.
LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX.
12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.
Information output at the start of the list
13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
Information output at the end of a page. This is only called for printing.
14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.
Information output at the end of the list
15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.
Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.
Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.
Sample code :
FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
CLEAR L_I_EVENT.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
This will prepare the events table for the report.
The report will contain three forms for the above events:
1. FORM TOP_OF_PAGE : This form will contain the top of page event for the report i.e header etc
Using the function module REUSE_ALV_COMMENTARY_WRITE, the internal table containing the headings for top of page event can be passed to the list output. Also, any logo specific to the report can be passed to the function module.
2. FORM END_OF_PAGE : This form will contain the end of page event for the report i.e footer etc
3. FORM USER_COMMAND : This form will contain the desired user command i.e pick/line selection
Step 5
A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
Output list description structure.
The parameters are described under the following heads:
Display options
Exceptions
Totals
Interaction
Detail screen
Display variants (only for hierarchical-sequential lists)
Color
Other
The layout table is of type slis_layout_alv_spec and has the following fields:
Display options
1. Colwidth_optimize (1) TYPE c: This parameter optimizes the length of the different columns in the output. The width of the different col. now depends on the max. Length of the data in the column.
Value set: SPACE, 'X'
'X' = optimizes the column width so that all contents are displayed completely.
2. No_colhead(1) TYPE c : This parameter suppresses the column headings
Value set: SPACE, 'X'.
'X' = column headers are not output
3. No_hotspot(1) TYPE c : The heading of the report output are not output as hotspot.
Value set: SPACE, 'X'.
'X' = column headers are not output as hotspot
4. Zebra(1) TYPE c : The report is output in the striped pattern.
Value set: SPACE, 'X'.
'X' = striped pattern (e.g. for wide lists)
5. No_vline(1) TYPE c : The report output contains columns only separated by space and no lines. It is not relevant for: hierarchical-sequential lists and multiple-line lists.
Value set: SPACE, 'X'.
'X' = columns separated by SPACE
6. No_min_linesize(1) TYPE c : The report line size is equal to the width of the list. It is not relevant for block lists.
Value set: SPACE, 'X.
'X' = line size depends on list width
' ' = Line size is set to 80 or MIN_LINESIZE (if > 0) .
7. Min_linesize LIKE sy-linsz: The report output contains a minimum possible length of line. If initial min_linesize is set to 80 by default, then this parameter is used to customize it. The prerequisite for this is that the parameter no_min_linesize should be ' '.
Value set: 0, 10 - 250
If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).
8. Max_linesize LIKE sy-linsz: The default max. Linesize is 250. To change this default value, this parameter can interactively-define the maximum list width setting.
Value set: 0, 80 - 1020
9. Window_titlebar LIKE rsmpe-tittext: To set the titlebar on the report output.
10. No_uline_hs(1) TYPE c.
Exceptions
11. Lights_fieldname TYPE slis_fieldname: Internal output table field containing the codes of exceptions to be output.
Output table field code: '1' = red traffic light
'2' = yellow traffic light
'3' = green traffic light Fieldname for exception
Value set: SPACE, internal output table field name.
12. Lights_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter LIGHTS_FIELDNAME. If LIGHTS_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists. Only relevant for hierarchical-sequential lists.
. Value set: SPACE, internal output table name.
13. Lights_rollname LIKE dfies-rollname: The documentation of this data element is displayed when you call F1 help for an exception column.
Value set: SPACE, data element name.
14. Lights_condense(1) TYPE c : If a list record is output with 'red traffic light', each
Subtotal that includes this record is also output with 'red traffic light'.
Value set: SPACE, 'X'
'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level.
Sums
15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
Only by fieldcatalog.
Value set: SPACE, 'X'
'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
Value set: SPACE, 'X'
'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
Value set: SPACE, 'X'
'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
18. No_subtotals(1) TYPE c : No subtotals possible
Value set: SPACE, 'X'
'X' = no subtotals.
19. Numc_sum(1) TYPE c : Totals only possible for NUMC-Fields.
20. No_unit_splitting TYPE c: No separate total lines by inh.units
21.totals_before_items TYPE c: Display totals before the items
22. Totals_only(1) TYPE c : Show only totals
Value set: SPACE, 'X'
'X' = only total records are output.
23. Totals_text(60) TYPE c : Text for 1st col. in totals
Value set: SPACE, string (max.60)
' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
'String = The string passed is output after the total indicated by '*', if the column is wide enough.
24. Subtotals_text(60) TYPE c : Texts for subtotals
Value set: SPACE, string (max.60)
' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
'String = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
Interaction
25. Box_fieldname TYPE slis_fieldname: Fieldname for checkbox in the report output. If the list has checkboxes at the start of records (for selecting several records), this parameter contains the internal output table field name indicated by the checkbox selection column. The field is a checkbox at the start of list records without a list header.
Value set: SPACE, internal output table field name
26. Box_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter BOX_FIELDNAME. If BOX_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.
Value set: SPACE, internal output table name.
27. Box_rollname LIKE dd03p-rollname: rollname for checkbox
28. Expand_fieldname TYPE slis_fieldname: fieldname flag expand. The user can show or hide the items by clicking on the folder symbol (hotspot). If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively, this can be controlled via the CALLBACK event 'ITEM_DATA_EXPAND'.
29. Hotspot_fieldname TYPE slis_fieldname: Used to make the fieldname flag hotspot.
30. No_input(1) TYPE c : The fields are only display fields.
Value set: SPACE, 'X'
'X' = all ready-for-input fields in a list are displayed as not ready-for-input. (Record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = 'X')
31. F2code LIKE sy-ucomm: To assign an ALV standard function code to double-click (F2), assign the function code to this parameter. Ex.: to assign the ALV standard function 'Detail' ('&ETA') to F2.
=> LAYOUT-F2CODE = '&ETA'.
Value set: SPACE, function code
32. Confirmation_prompt: confirm. Prompt when leaving
Value set: SPACE, 'X'
'X' = if one of the functions Back (F03)', Exit (F15)' or Cancel (F12)' occurs, a confirmation prompt appears.
33. Key_hotspot(1) TYPE c : The key fields are displayed as hotspot. The columns defined in the field catalog as key fields (FIELDCAT-KEY = 'X') are output as hotspots, i.e. clicking on a key column (highlighted in color in the list) calls the function under F2.
Value set: SPACE, 'X'.
34. Reprep(1) TYPE c : report report interface active.
35. Group_buttons(1) TYPE c : group-buttons for COL1 - COL5 . Group output fields via FIELDCAT-SP_GROUP in the field list, and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS.
Value set: SPACE, 'X'.
36. No_keyfix(1) TYPE c : Used to make the key fields scrollable.
Value set: SPACE, 'X'.
' ' = The key columns defined in the field catalog by FIELDCAT-KEY = 'X' are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in hierarchical-sequential lists. The header table key fields are not considered here.
'X' = key columns not fixed
37. Get_selinfos(1) TYPE c : To read selection screen.
Value set: SPACE, 'X'.
If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup which lists the report selections in a simple form, becomes active on the results list output by ALV.
38. group_change_edit(1) TYPE c : Settings by user for new group
Value set: SPACE, 'X'
'X' = the user can enter a format option for each sort criterion in the sort/subtotal popup, for the list format when this value changes (e.g. new page or underline).
39. No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right.
Value set: SPACE, 'X'.
40. Expand_all(1) TYPE c : Expand all positions
Detailed screen
40. Detail_popup(1) TYPE c : show detail in popup.
Value set: SPACE, 'X'
' ' = List record detail display in full-screen mode, with top-of-page.
'X' = list record detail display in popup (without top-of-page).
41. Detail_initial_lines(1) TYPE c : show also initial lines
Value set: SPACE, 'X'
' ' = Only fields whose contents are not initial are output in the detail view.
'X' = initial field contents are also output in detail.
41. detail_titlebar(30) type c : Titlebar for detail screen
Value set: SPACE, string (max.30)
` ' = ' Detail: Display' is output as the title of the detail window.
'String = the string passed is output as the title of the detail window.
Display variants
42. Header_text (20) TYPE c: Text for header button. Only relevant for hierarchical-sequential lists. You can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20)
' ' = The header table field pushbutton text is 'Header' by default.
CHAR (20) = header table field pushbutton text.
43.item_text(20) TYPE c : Text for item button. Only relevant for hierarchical-sequential lists. You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.
Value set: SPACE, CHAR (20)
' ' = The pushbutton text for the item table fields is 'Item' by default.
CHAR (20) = item table field pushbutton text.
44.default_ item(1) TYPE c : Items as default. Only relevant for hierarchical-sequential lists.
Value set: SPACE, 'X'
' ' = The header table fields are displayed by default in the display variant definition popup. The user can switch to the item table fields interactively.
'X' = the item table fields are displayed by default in the display variant Definition Popup. The user can switch to the header table fields interactively.
Colour
45. Info_fieldname TYPE slis_fieldname: infofield for listoutput. A whole list record can be colored individually using a color code in a column of the internal output table for the record. Assign the name of the field containing the color code to this parameter.
Value set: SPACE, internal output table field name
The internal output table field must be of type CHAR(3).
The code must have the following syntax: 'Cxy':
C = color (all codes must start with 'C')
X = color number ('1'-'9')
Y = bold ('0' = off, '1' = on)
46. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell. Assign the name of the field to this parameter.
Others
47. List_append(1) TYPE c : no call screen. It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or may exceed, the maximum number specified in the block module documentation. These operations are not possible for user-defined block lists.
Example code :
I_LAYOUT-f2code = ws_fcode.
I_LAYOUT-zebra = 'X'.
I_LAYOUT-colwidth_optimize = 'X'.
I_LAYOUT-no_keyfix = 'X'.
I_LAYOUT-get_selinfos = 'X'.
I_LAYOUT-no_hotspot = 'X'.
I_LAYOUT-no_input = 'X'.
I_LAYOUT-hotspot_fieldname = FIELDNAME.
I_LAYOUT-no_input = X.
I_LAYOUT-no_vline = `X.
I_LAYOUT-no_colhead = .
I_LAYOUT-lights_condense = ` `.
I_LAYOUT-totals_text = ` `.
I_LAYOUT-subtotals_text = ` `.
I_LAYOUT-totals_only = ` `.
I_LAYOUT-key_hotspot = X.
I_LAYOUT-detail_popup = X.
I_LAYOUT-group_change_edit = X.
I_LAYOUT-GROUP_BUTTONS = X.
Step 6
This step is required to get the selection screen information in the report output.
The prerequisite for this is to set the parameter LAYOUT-GET_SELINFOS of the IMPORTING structure.
The parameters to be passed in the IS_SEL_HIDE table are:
o mode: 'R' = only the entries passed in the internal table IS_SEL_HIDE-T_ENTRIES
Are output in the pop up. Selection info, which the list tool read in the selection screen (when called by a report with a selection screen), is replaced by the values passed.
'S' = the selection info which the list tool read in the selection screen of the calling report are modified by the entries in the table IS_SEL_HIDE-T_ENTRIES.
o t_entries: Selection info table
o t_entries-mode: 'A' = output the selection info for the current table record in the info popup.
'D' = do not output select option or SELNAME parameter selection info in the popup.
o t_entries-selname: (only used in t_entries-mode = 'D') : Name of the select option or parameter.
The following table fields are only used in t_entries-mode = 'A'. They contain the selection information to be added.
t_entries-field: DDIC field name of the field for which selection information is to be output.
t_entries-table: DDIC table names of t_entries-field.
t_entries-stext: Field name in info popup.
If t_entries-field and t_entries-table have been entered, this text is taken from DDIC.
t_entries-valuf: Selection condition 'from' value (external format)
t_entries-valut: Selection condition 'to' value (external format)
t_entries-sign0: (I)nclusive (E)xclusive
t_entries-option: All values of the select options Option field allowed.
Step 6
The Table IT_SORT is populated with the sort criteria for the different fields.
The caller specifies the sorting and/or subtotaling of the basic list in the internal table IT_SORT.
This internal table has the following fields:
o spos : Sort sequence
o fieldname : Internal output table field name
o tabname : Only relevant for hierarchical-sequential lists. Name of the internal output table.
o up : 'X' = sort in ascending order
o down : 'X' = sort in descending order
o subtot : 'X' = subtotal at group value change
o group : '* ' = new page at group value change ,'UL' = underline at group value change
Step 7
The final step in the output of the report is the use of two ALV functions modules.
1. REUSE_ALV_FIELDCATALOG_MERGE
2. REUSE_ALV_LIST_DISPLAY
The first function module is used to pass the field catalog to the report output and merge it with the internal output table.
FUNCTION reuse_alv_fieldcatalog_merge.
""Lokale Schnittstelle:
* IMPORTING
*" VALUE(I_PROGRAM_NAME) LIKE SY-REPID OPTIONAL
*" VALUE(I_INTERNAL_TABNAME) TYPE SLIS_TABNAME OPTIONAL
*" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
*" VALUE(I_CLIENT_NEVER_DISPLAY) TYPE SLIS_CHAR_1
*" DEFAULT 'X'
*" VALUE(I_INCLNAME) LIKE TRDIR-NAME OPTIONAL
*" CHANGING
*" VALUE(CT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
*" EXCEPTIONS
*" INCONSISTENT_INTERFACE
*" PROGRAM_ERROR
Import parameters
I_PROGRAM_NAME: Program in which the internal output table is declared and populated
I_INTERNAL_TABNAME: Internal output table name
I_STRUCTURE_NAME: Structure name (structure, table, and view)
I_CLIENT_NEVER_DISPL: Hide client fields default X
I_INCLNAME: Data declarations include name
CHANGING parameter
CT_FIELDCAT: Field catalog with field descriptions
The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:
1. Performance is affected since the code of the table definition must always be read and interpreted at runtime.
2. Dictionary reference are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.
Step 8
The other function module is used to display the internal output table with the contents
FUNCTION reuse_alv_list_display.
""Lokale Schnittstelle:
* IMPORTING
*" VALUE(I_INTERFACE_CHECK) DEFAULT SPACE
*" VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID DEFAULT SPACE
*" VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME
*" DEFAULT SPACE
*" VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
*" DEFAULT SPACE
*" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
*" VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL
*" VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
*" VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
*" VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV
*" OPTIONAL
*" VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
*" VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
*" VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL
*" VALUE(I_DEFAULT) DEFAULT 'X'
" VALUE(I_SAVE) DEFAULT SPACE
" VALUE(IS_VARIANT) LIKE DISVARIANT
" STRUCTURE DISVARIANT DEFAULT SPACE
" VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL
" VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL
" VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL
" VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL
" VALUE(I_SCREEN_START_COLUMN) DEFAULT 0
" VALUE(I_SCREEN_START_LINE) DEFAULT 0
" VALUE(I_SCREEN_END_COLUMN) DEFAULT 0
" VALUE(I_SCREEN_END_LINE) DEFAULT 0
" EXPORTING
" VALUE(E_EXIT_CAUSED_BY_CALLER)
" VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER
" TABLES
" T_OUTTAB
" EXCEPTIONS
" PROGRAM_ERROR
Import parameters
I_INTERFACE_CHECK: Interface consistency check log output.
I_CALLBACK_PROGRAM: Name of the calling program
I_CALLBACK_PF_STATUS_SET: Set EXIT routine to status.
I_CALLBACK_USER_COMMAND: EXIT routine for command handling
I_STRUCTURE_NAME: Internal output table structure name
IS_LAYOUT: List layout specifications
IT_FIELDCAT: Field catalog with field descriptions
IT_EXCLUDING: Table of inactive function codes
IT_SPECIAL_GROUPS: Grouping fields for column selection
IT_SORT: Sort criteria for first list display
IT_FILTER: Filter criteria for first list output
IS_SEL_HIDE : Selection information modification
I_DEFAULT: Initial variant active/inactive logic
I_SAVE: Variants can be saved
IS_VARIANT : Variant information
IT_EVENTS: Table of events to perform IT_EVENT_EXIT : Standard fcode exit requests table
IS_PRINT: Print information
IS_REPREP_ID: Initialization keys for Re/Re interface
I_SCREEN_START_COLUMN: Coordinates for list in dialog box
I_SCREEN_START_LINE: Coordinates for list in dialog box
I_SCREEN_END_COLUMN: Coordinates for list in dialog box
I_SCREEN_END_LINE: Coordinates f -
ALV report using the field catalog
which is the quickest way to generate an ALV report using the field catalog merge. without needing to build the field catalog manually .
is it easier to create a structure and passe it in the field catalog merge . if yes can i have an example plzzzzhI
Supports the creation of the field catalog for the ALV function modules
based either on a structure or table defined in the ABAP Data
Dictionary, or a program-internal table.
The program-internal table must either be in a TOP Include or its
Include must be specified explicitly in the interface.
The variant based on a program-internal table should only be used for
rapid prototyping since the following restrictions apply:
o Performance is affected since the code of the table definition must
always be read and interpreted at runtime.
o Dictionary references are only considered if the keywords LIKE or
INCLUDE STRUCTURE (not TYPE) are used.
If the field catalog contains more than 90 fields, the first 90 fields
are output in the list by default whereas the remaining fields are only
available in the field selection.
If the field catalog is passed with values, they are merged with the
'automatically' found information.
Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
display it using the basic ALV grid functionality(including column total). The example details the main
sections of coding required to implement the ALV grid functionality:
Data declaration
Data retrieval
Build fieldcatalog
Build layout setup
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
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'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL -
ALV Display - Error in field catalog
Hi ,
I am facing a problem in ALV... Field catalot is not getting populated... I am getting a message field catalog not found...
Can anyone please help me....... <URGENT DOES NOT EXIST HERE>...
I am enclosing my code also.. please go thourh it and help it....
REPORT ZINVENTORY
LINE-SIZE 120
LINE-COUNT 64.
MESSAGE-ID Z2
NO STANDARD PAGE HEADING..
type-pools : slis.
Tables *
tables: zasset,
anla,
itob,
equi.
data: v_repid LIKE sy-repid.
Selection Screen *
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
SELECT-OPTIONS : S_bukrs FOR anla-bukrs OBLIGATORY ,
S_kostl FOR itob-kostl .
SELECTION-SCREEN : END OF BLOCK B1 .
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
PARAMETERS: p_screen RADIOBUTTON GROUP gr1,
p_list RADIOBUTTON GROUP gr1 DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b2.
Internal Tables *
types: BEGIN OF ty_zasset, " occurs 0,
equnr like zasset-equnr,
ANLN1 LIKE zasset-ANLN1, " Asset number
ANLN2 LIKE zasset-ANLN2, " Sub Asset number
BUKRS LIKE zasset-BUKRS, " Company Code
KOSTL like zasset-kostl,
SCANNEDBY type zasset-scannedby,
SCANNINGDATE type zasset-SCANNINGDATE,
SCANNINGTIME type zasset-scanningtime,
UPDATEDATE type zasset-updatedate,
UPDATETIME type zasset-updatetime,
END OF ty_zasset.
DATA: wa_zasset TYPE ty_zasset.
DATA: it_zasset TYPE TABLE OF ty_zasset with header line..
types: BEGIN OF ty_zasset1, " occurs 0,
equnr TYPE equi-equnr,
ANLN1 LIKE anla-ANLN1, " Asset number
ANLN2 LIKE anla-ANLN2, " Sub Asset number
BUKRS LIKE anla-BUKRS, " Company Code
ernam like anla-ernam,
erdat like anla-erdat,
KOSTL like anlz-kostl,
SCANNEDBY type zasset-scannedby,
SCANNINGDATE type zasset-SCANNINGDATE,
SCANNINGTIME type zasset-scanningtime,
UPDATEDATE type zasset-updatedate,
UPDATETIME type zasset-updatetime,
END OF ty_zasset1.
DATA: wa_zasset1 TYPE ty_zasset1.
DATA: it_zasset1 TYPE TABLE OF ty_zasset1 with header line..
types: BEGIN OF ty_zasset2, " occurs 0,
equnr like itob-equnr,
ANLNr LIKE itob-ANLNr, " Asset number
ANLuN LIKE itob-ANLuN, " Sub Asset number
BUKRS LIKE itob-BUKRS, " Company Code
timbi like itob-timbi,
kostl like itob-kostl,
KOSTL like anlz-kostl,
SCANNEDBY type zasset-scannedby,
SCANNINGDATE type zasset-SCANNINGDATE,
SCANNINGTIME type zasset-scanningtime,
UPDATEDATE type zasset-updatedate,
UPDATETIME type zasset-updatetime,
END OF ty_zasset2.
DATA: wa_zasset2 TYPE ty_zasset2.
DATA: it_zasset2 TYPE TABLE OF ty_zasset2 with header line..
types: begin of ty_final , "occurs 0,
equnr like itob-equnr,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
ernam
erdat
kostl like itob-kostl,
end of ty_final.
DATA: wa_final TYPE ty_final.
DATA: it_final TYPE TABLE OF ty_final with header line..
*DATA: it_zasset TYPE TABLE OF ty_zasset.
*data: it_zasset1 type table of ty_zasset1.
*data:wa_zasset type ty_zasset.
*data:wa_zasset1 type ty_zasset1.
Flags and Variables *
DATA : F_ERROR. " Flag for No Data
*pop field cat for f7
data: V_SYREPID LIKE SY-REPID,
IT_FLDCAT type slis_t_fieldcat_alv , "with header line,
wa_fldcat type slis_fieldcat_alv.
*DATA : IT_FLDCATS TYPE SLIS_T_FIELDCAT_ALV.
data: itab_events type slis_t_event,
wa_events type slis_alv_event.
*data: wa_layout type slis_layout_alv.
DATA : IT_COMMENTS TYPE SLIS_T_LISTHEADER,
WA_COMMENTS TYPE SLIS_LISTHEADER.
DATA : IT_SORTINFO TYPE SLIS_T_SORTINFO_ALV,
WA_SORTINFO TYPE SLIS_SORTINFO_ALV.
Initialization *
initialization.
SY-REPID = V_REPID.
At Selection Screen *
AT SELECTION-SCREEN.
PERFORM validation.
Start Of Selection *
start-of-selection.
perform select_data.
IF P_LIST = 'X'.
perform get_field_catalog.
PERFORM MODIFYFIELDCAT.
perform get_events.
perform write_comments.
perform grid_display.
*perform list_display.
ENDIF.
IF sy-subrc = 0.
IF p_list = 'X'.
loop at it_final.
perform get_events.
endloop.
endif.
endloop.
else.
*endif.
End Of Selection *
END-OF-SELECTION.
*perform display_Recorsds.
*loop at zasset.
*& Form validation
text
--> p1 text
<-- p2 text
FORM validation.
*Local variables.
DATA:
lv_bukrs type anla-bukrs,
lv_kostl type itob-kostl,
lv_anln1 TYPE anla-anln1, "MAterial Number
lv_anln2 TYPE anla-anln2.
*Validation for company code
if not s_bukrs is initial.
select single bukrs from anla
into lv_bukrs
where bukrs in s_bukrs.
if sy-subrc <> 0.
*Message used : Invalid company code.
endif.
endif .
Validation for cost center
if not s_kostl is initial.
select single kostl from itob
into lv_kostl
where kostl in s_kostl.
if sy-subrc <> 0.
*Message used : Invalid company code.
endif.
endif .
ENDFORM. " validation
*& Form display
text
--> p1 text
<-- p2 text
FORM display.
write :/15 it_final-anln1,
it_final-anln2,
sy-vline.
*-bukrs,
it_zasset-anln1.
ENDFORM. " display
*& Form get_field_catalog
text
--> p1 text
<-- p2 text
FORM get_field_catalog.
*REFRESH IT_FLDCAT.
*CLEAR IT_FLDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_FINAL'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FLDCAT
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.
ENDFORM. " get_field_catalog
*& Form get_events
text
--> p1 text
<-- p2 text
FORM get_events.
WA_COMMENTS-TYP = 'H'.
WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
APPEND WA_COMMENTS TO IT_COMMENTS.
ENDFORM. " get_events
*& Form grid_display
text
--> p1 text
<-- p2 text
FORM grid_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'FIRST PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'LIST OF FLIGHT DETAILS'
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = it_fldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = itab_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = it_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " grid_display
*& Form write_comments
text
--> p1 text
<-- p2 text
FORM write_comments.
WA_COMMENTS-TYP = 'H'.
WA_COMMENTS-KEY = 'THIS IS THE HEADING.'.
WA_COMMENTS-INFO = 'LIST OF SALES ORDERS'.
APPEND WA_COMMENTS TO IT_COMMENTS.
ENDFORM. " write_comments
*& Form select_data
text
--> p1 text
<-- p2 text
FORM select_data.
clear: it_zasset, it_zasset[].
select equnr "bukrs
anln1
anln2
bukrs
KOSTL
SCANNEDBY
SCANNINGDATE
SCANNINGTIME
UPDATEDATE
UPDATETIME
into table it_zasset "(g_anln1,g_anln2)
from zasset
where bukrs = zasset-bukrs..
and kostl = zasset-kostl.
if sy-subrc = 0.
sort it_zasset by anln1 anln2.
endif.
append it_zasset.
clear it_zasset1.
select
equnr
anln1
anln2
bukrs
ernam
erdat
bukrs
KOSTL
SCANNEDBY
SCANNINGDATE
SCANNINGTIME
UPDATEDATE
UPDATETIME
into table it_zasset1 "(g_anln1,g_anln2)
from anla
where bukrs = it_zasset-bukrs.
WHERE BUKRS IN S_BUKRS.
and kostl = anla-kostl.
if sy-subrc = 0.
select equnr
anlnr
anlun
bukrs
timbi
kostl
into table it_zasset2
from itob
for all entries in it_zasset1
where bukrs = it_zasset1-bukrs
WHERE anlnr = it_zasset1-anln1.
endif.
APPEND IT_ZASSET1.
IF SY-SUBRC = 0.
*loop at it_zasset1 into wa_zasset1.
loop at it_ZASSET1 into wa_zasset1.
move wa_zasset1-bukrs to wa_final-bukrs.
move wa_zasset1-anln1 to wa_final-anln1.
move wa_zasset1-anln2 to wa_final-anln2.
append wa_final to it_final.
endloop.
ENDIF.
sort it_final.
*LOOP AT IT_FINAL.
*ENDLOOP.
*ENDIF.
*if sy-subrc = 0.
*loop at it_zasset into wa_asset.
*read table it_zasset into wa_asset with key anln2 = wa_asset-anln2
*binary search.
*read table it_final into wa_final with key anln2 = wa_final-anln2
*binary search.
*if wa_asset-anln2 = wa_final-anln2.
*write : / 'error'.
*endif.
If sy-subrc <> 0.
f_error = 'X'.
write : 'No data Exists for the given selection in FA table'.
else.
loop at it_final.
perform display.
endloop.
records exits in anla table also.
endif.
ENDFORM. " select_data
*& Form MODIFYFIELDCAT
text
--> p1 text
<-- p2 text
FORM MODIFYFIELDCAT.
LOOP AT IT_FLDCAT INTO WA_FLDCAT.
CASE WA_FLDCAT-FIELDNAME.
WHEN 'EQUNR'.
WA_FLDCAT-COL_POS = 1.
WA_FLDCAT-SELTEXT_L = 'aSSET'.
WHEN 'ANLN1'.
wa_FLDCAT-KEY = 'X'.
WA_FLDCAT-COL_POS = 5.
WA_FLDCAT-SELTEXT_L = 'aSSET'.
WHEN 'ANLN2'.
WA_FLDCAT-KEY = 'X'.
WA_FLDCAT-COL_POS = 6.
wa_FLDCAT-HOTSPOT = 'X'.
WHEN 'BUKRS'.
WA_FLDCAT-CURRENCY = 'INR'.
WA_FLDCAT-SYMBOL = 'X'.
ENDCASE.
MODIFY IT_FLDCAT FROM WA_FLDCAT.
*IT_FLDCAT-fieldname = 'EQUNR'.
IT_FLDCAT-seltext_m = 'DOCUM_TYPE'.
IT_FLDCAT-col_pos = 1.
IT_FLDCAT-outputlen = 10.
IT_FLDCAT-emphasize = 'X'.
IT_FLDCAT-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append IT_FLDCAT TO IT_FLDCAT.
IT_FLDCAT-fieldname = 'ANLN1'.
IT_FLDCAT-seltext_m = 'DOCUM_TYPE'.
IT_FLDCAT-col_pos = 1.
IT_FLDCAT-outputlen = 10.
IT_FLDCAT-emphasize = 'X'.
IT_FLDCAT-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append IT_FLDCAT TO IT_FLDCAT.
ENDLOOP.
ENDFORM. " MODIFYFIELDCAT
*& Form list_display
text
--> p1 text
<-- p2 text
*FORM list_display.
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_SYREPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT = wa_layout
IT_FIELDCAT = IT_FLDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = ITAB_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_FINAL
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. " list_display
Edited by: Craig Cmehil on Jul 18, 2008 10:01 AMThe problem is with this...
types: begin of ty_final , "occurs 0,
equnr like itob-equnr,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
ernam
erdat
kostl like itob-kostl,
end of ty_final.
DATA: wa_final TYPE ty_final.
DATA: it_final TYPE TABLE OF ty_final with header line.
when you are using Fieldcatalog merge you have to avoid using the TYPES Declaration of the internal table.
Instead of that you can do this
data: begin of it_final occurs 0,
equnr like itob-equnr,
anln1 like anla-anln1,
anln2 like anla-anln2,
bukrs like anla-bukrs,
ernam
erdat
kostl like itob-kostl,
end of it_final. -
"Field Catalog not found" ...problem in ALV reporting !!
Hi,
When i execute my report program where in I generate a Selection screen, I am able to select the values in the selection screen. Once I click on the execute button I get the message
"Field Catalog not found"...
The elabore message is
"Field Catalog cannot be determined becaus the output table structure name was not specified"
Where am I wrong ??
Find below my code ...
*& Report Z_MIGO_TXJCD_REPORT
REPORT Z_MIGO_TXJCD_REPORT.
TYPE-POOLS: slis.
TABLES: makt,mseg,zmigo_extend,ttxj,mkpf.
DATA: BEGIN OF migo_data OCCURS 0,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
lgpla LIKE mseg-lgpla,
bwart LIKE mseg-bwart,
menge LIKE mseg-menge,
dmbtr LIKE mseg-dmbtr,
budat LIKE mkpf-budat,
txjcd LIKE zmigo_extend-txjcd,
END OF migo_data.
DATA: it_cat TYPE slis_t_fieldcat_alv,
wa_lay TYPE slis_layout_alv.
FIELD-SYMBOLS: <fs_cat> LIKE LINE OF it_cat.
SELECT-OPTIONS: so_matnr FOR makt-matnr,
so_budat FOR mkpf-budat,
so_werks FOR mseg-werks,
so_lgpla FOR mseg-lgpla,
so_bwart FOR mseg-bwart,
so_txjcd FOR ttxj-txjcd.
START-OF-SELECTION.
SELECT amatnr awerks algpla abwart
amenge admbtr bbudat ctxjcd INTO TABLE
migo_data
FROM mseg AS a INNER JOIN mkpf AS b ON amblnr = bmblnr INNER JOIN
zmigo_extend AS c ON amblnr = cmblnr
WHERE a~matnr IN so_matnr
AND b~budat IN so_budat
AND a~werks IN so_werks
AND a~lgpla IN so_lgpla
AND a~bwart IN so_bwart
AND c~txjcd IN so_txjcd.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_internal_tabname = 'migo_data'
i_inclname = sy-cprog
CHANGING
ct_fieldcat = it_cat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LOOP AT it_cat ASSIGNING <fs_cat>.
CLEAR <fs_cat>-key.
ENDLOOP.
wa_lay-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_grid_title = 'MIGO report with Tax Jurisdiction Code'
is_layout = wa_lay
it_fieldcat = it_cat
TABLES
t_outtab = migo_data
EXCEPTIONS
program_error = 1
OTHERS = 2.Give 'migo_data' in uppercase as ''MIGO_DATA'.
-
How to display the fields in ALV Output without using Field catalog?
How to display the fields in ALV Output without using Field catalog?
Could you pls tell me the coding?
Akshitha.Hi,
u mean without building field catalog. is it? I that case, we can use the FM REUSE_ALV_FIELDCATALOG_MERGE.
data: itab type table of mara.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = itab
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*Pass that field catalog into the fillowing FM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_grid_title = 'REPORTING'
is_layout = gt_layout
it_fieldcat = lt_fieldcat[]
tables
t_outtab = itab.
Maybe you are looking for
-
Time machine backup on network drive
i have a netgear router with readyshare usb network drive i have a 2TB external hdd that i use for a central location to view files for both my imac 10.7.5 and multiple pc's windows 7 i currently have a external hdd connected to my imac just for time
-
The Quicktime manual indicates that .pdf is an acceptable format, however I can't open a pdf file in Quicktime. Any suggestions?
-
Not starting MakBook Pro (possible SSD failure)
Not starting MakBook Pro with message "com.apple.launchd 1 com.apple.coreservices.appleevents 63 Exit timeout elapsed (1 seconds). Killing". Is there a way to do something at home, or just give it to service?
-
Macbook Pro vertical LCD Striping
very distressed right now - my MBP was working fine this morning but when I brought it to work and opened, there was a thick vertical band that's obscuring about half the screen - I'm thinking this is a LCD hardware problem, but wanted to know if any
-
How do I get a moving image as a screensaver on Apple tv?
I Am trying to get a moving picture of what lookslike a burning fire a background for my Apple TV, but I am not sure how?