Header in ALV using Oops
I need to display Table header in ALV using Oops.
I need to data from 8 fields which I get in the run time of the program.
I am new to Oops ALV, I have done a similar thing in normal ALV but not in oops.
Detailed info required, Custom container settings as well.
Thanks in Advance
see this weblog TOP_OF_PAGE in ALV Using CL_GUI_ALV_GRID
Similar Messages
-
hi
i would like to have coding for total and subtotal in alv using oops concept and (not using function module).
also i would like to have coding for cell color and heading and footer.
thanx in adv
rockyHi Rocky,
please check this link
http://www.****************/Tutorials/ALV/Total/text.htm
While modifying field catalog , try the following.
Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
LOOP AT i_fieldcat ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'LOSGR'.
<lfs_fieldcat>-coltext = text-007.
<lfs_fieldcat>-do_sum = c_x.
ENDCASE.
ENDLOOP.
Or if you want to use field symbols.
data: total type ref to data,
subtotal1 type ref to data.
field-symbols <total> like gt_sflight.
field-symbols <subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
Best regards,
raam -
How to get Subtotal text in ALV using OOPS
hi,
Can any one pls help me out getting <b>subtotals text</b> in ALV using OOPS concepts....Pls provide me if any of u have sample code for that......
my code:
data:gr_grid_d0100 type ref to cl_gui_alv_grid.
data : gr_events_d0100 type ref to lcl_events_d0100.
classes**********
class lcl_events_d0100 definition.
public section.
methods:
subtotal_text for event subtotal_text
of cl_gui_alv_grid
importing es_subtottxt_info
ep_subtot_line
e_event_data.
endclass.
class lcl_events_d0100 implementation.
method subtotal_text.
perform d0100_event_subtotal_text using es_subtottxt_info
ep_subtot_line
e_event_data.
endmethod. "subtotal_text
endclass.
data : gr_event_handler type ref to lcl_events_d0100.
SET HANDLER gr_event_handler->subtotal_text FOR wcl_alv_grid_request
FORM d0100_event_subtotal_text USING
es_subtottxt_info TYPE LVC_S_STXT
ep_subtot_line TYPE REF TO data
e_event_data TYPE REF TO cl_alv_event_data.
DATA: l_text TYPE string.
l_text = es_subtottxt_info.
FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN e_event_data->m_data->* TO <fs>.
<fs> = text-007.hi vijay
check this code
if you want to use field symbols.
data: total type ref to data,
subtotal1 type ref to data.
field-symbols <total> like gt_sflight.
field-symbols <subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
or u can use
U have to do the subtotal column wise.In the field catalog specify the following in addition to the corresponding field name(i.e. Column)
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-do_sum = 'X'.
Hope this helps u out.
Thanks & Regards,
naveen -
Hello ,
Can anyone let me know how to trigger the END-of-page event in ALV using OOPs.
Thanks in advance.
Regards
JaiHello Pratuysh,
Thanks for the answer
I know that report,but that doesn't help me.
Any other way
Thanks
Jai -
Detect rows selection in ALV using oops
Hi ALL,
I HAVE An ALV OUTPUT OF RECORDS USING OOPS.
NOW I CAN SELECT ONE OR MULTIPLE ROWS OF THE OUTPUT AND I HAVE ADDED A DELETE ICON TO MY TOOL BAR.
I HAVE BACK AND EXIT BUTTON AND I HAVE CODE FOR THE SAME IN PAI.
FOR DELETE ICON SY-UCOMM IS DELE AND CONTROL COMES TO PAI
MY QUESTION IS HOW DO YOU KNOW WHICH ROW OR ROWS ARE SELETEd , IN NORMAL ABAP , a field BOX type c has a value X , but what about in ALV using OOPS.
I have no idea whether my approach is correct or wrong or do i need to something else.
ThanksHi Darren,
This is what i have . Iam new oops so i want to just make sure
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 'DELETE'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
DATA : WA_LT_ROWS LIKE LINE OF LT_ROWS.
LOOP AT LT_ROWS INTO WA_LT_ROWS.
DELETE I_ZFINAL INDEX WA_LT_ROWS-INDEX.
ENDLOOP.
ENDCASE.
call method g_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
changing
it_outtab = i_zFINAL
it_fieldcatalog = fieldcat
IT_SORT =
IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
LET ME KNOW THANKS -
Hi Friends,
I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
The code written is as follows.
=====================================================
data: gt_zsd_abcd type zsd_abcd occurs 0, "Output-Table
data l_hierarchy_header type treev_hhdr.
perform build_hierarchy_header changing l_hierarchy_header.
call method g_alv_tree->set_table_for_first_display
exporting
i_structure_name = 'zsd_abcd'
is_hierarchy_header = l_hierarchy_header
changing
it_outtab = gt_zsd_abcd. "table must be empty !
perform create_hierarchy.
call method g_alv_tree->frontend_update.
=====================================================
I would like know as to how to display only the required columns in the header part.
Pls guide me.
TIA.
Regards,
Mark KHi Mark,
i got it, in your case you will get all the fields present in the structure you mentioned in the method.
so if you want only Purchase Order then you need to Build the fieldcat only for that field and then pass that fieldcat to the method. and don't pass the structure in this case.
call method alv_tree_control->set_table_for_first_display
exporting
is_variant = l_variant
i_save = 'A'
i_default = 'X'
is_hierarchy_header = l_hierarchy_header
it_special_groups = l_special_groups
it_toolbar_excluding = l_toolbar_excluding
changing
<b>it_fieldcatalog = l_field_catalog</b>
it_outtab = l_output_tbl.
Regards
vijay -
Hi,
I want create an ALV report in which when i will double click on record will drill down the report.
I know interactive ALV report using function module. but now i want to create it using OOPs concept. Please guidme
thanks and regrds
abhishekmethods: double_click for event double_click of cl_gui_alv_grid
importing e_row e_column es_row_no
method double_click.
message s400(00) with 'documents' e_row. "#EC *
data : wa_display like line of lt_display.
if e_column = 'BELNR'.
read table lt_display index e_row into wa_display.
if sy-subrc = 0.
set parameter id 'BLN' field wa_display-belnr.
set parameter id 'BUK' field wa_display-bukrs.
set parameter id 'GJR' field wa_display-gjahr.
call transaction 'FB03' and skip first screen.
endif.
endif.
endmethod.
see this may help u.
Regards -
How can we set GUI STATUS in a alv program using oops...Is there any method we need to use for this ????
Hi,
Just call screen from your program as below .
call screen 9001.
In the PBO of the screen,write the following code
MODULE status_9001 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE'.
ENDMODULE. " STATUS_9001 OUTPUT -
Position of cursor in ALV using oops
Hi all,
i am using OOPS ALV (CL_GUI_ALV_GRID) to display data.
i have some editable fields in ALV.
While i enter value in some field and press 'ENTER' my cursor goes to the FIRST field of the alv.
i want it to keep cursor in same field.
please tell me how to do
thanksHi,
I guess you are using the method REFRESH_TABLE_DISPLAY of the alv grid. If so, pass the parameters IS_STABLE. It is a structure of type LVC_S_STBL. Pass 'X' to LS_STABLE-ROW &
LS_STABLE-COL = 'X'.
Example :
data LS_STABLE type LVC_S_STBL.
LS_STABLE-ROW = 'X'.
LS_STABLE-COL = 'X'.
call method G_GRID->REFRESH_TABLE_DISPLAY
exporting
IS_STABLE = LS_STABLE
exceptions
FINISHED = 1
others = 2.
Use the above code and it will solve the problem.
regards,
Advait -
Regarding ALV using OOPS Concept
Hi Experts,
Can abody explain to me how can i disable some settings in the tool bar of ALV Grid using oops concept??Hi Alex,
You can perform this step, before you call set_table_for_first_display and pass that to this call.
**Exculude all unnecessary standard function in ALV
PERFORM exclude_tb_functions CHANGING lt_exclude.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = l_variant
i_save = 'A'
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort[]
it_outtab = it_final[].
You can exclude all unwanted function in the subroutine.
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.
ENDFORM. " exclude_tb_functions
This will give you complete the solution for your query.
Thanks
Lakshmi -
Hi All,
How do we create a hotspot using OOPs concept in ALV? Also tell me how to call a transaction code after doing a Hotspot click on a field.try factory methods like this:
form display .
Sort output table
sort it_out by vbeln_vl vbeln_vf fkart.
try.
Using Factory classes for output display
call method cl_salv_table=>factory
importing
r_salv_table = o_table
changing
t_table = it_out.
o_functions = o_table->get_functions( ).
o_functions->set_all( abap_true ).
To sort the table by Delivery, billing document.
o_sorts = o_table->get_sorts( ).
o_sorts->add_sort( columnname = 'VBELN_VL' subtotal = abap_true ).
o_sorts = o_table->get_sorts( ).
o_sorts->add_sort( columnname = 'VBELN_VF' subtotal = abap_true ).
To goto transaction*
o_cevents = o_table->get_event( ).
create object o_levents.
set handler o_levents->on_double_click for o_cevents.
Catch exceptions
catch cx_salv_msg into o_salv_msg.
message e184 with o_salv_msg->msgv1
o_salv_msg->msgv2
o_salv_msg->msgv3
o_salv_msg->msgv4.
catch cx_salv_not_found into o_salv_not_found.
message e184 with o_salv_not_found->object
o_salv_not_found->textid
o_salv_not_found->key
o_salv_not_found->method.
catch cx_salv_data_error into o_salv_data_error .
message e184 with o_salv_data_error->object
o_salv_data_error->textid
o_salv_data_error->key
o_salv_data_error->method.
catch cx_salv_existing into o_salv_existing .
message e184 with o_salv_existing->object
o_salv_existing->textid
o_salv_existing->key
o_salv_existing->method.
endtry.
Display
o_table->display( ).
endform. " display
*& Form disp_line_item
To display the delivery data using transaction VL03n*
on double click on any row.*
form disp_line_item using fp_row type salv_de_row
fp_column type salv_de_column.
Read the output table*
read table it_out into wa_out index fp_row.
if sy-subrc eq 0 .
set parameter id 'VL' field wa_out-vbeln_vl.
call transaction 'VL03N' and skip first screen. " Call transaction vl03n
endif.
endform. " disp_line_item
Edited by: kartik tarla on Dec 15, 2008 7:35 PM -
I NEVER USED OOPS CONCEPT.BUT I GOT A TASK ON ALV REPORT USING class CL_GUI_ALV_GRID, call method SET_TABLE_FOR_FIRST_DISPLAY for ALV . I HAD PASSED THE VALUES FROM INTERNAL TABLE AND GOT OUTPUT IN ALV.
The problem is When i save an layout(default setting button ).
iam unable to get the output for all fields.
if u want i will send screenshots to ur mail
THANKS IN ADVANCE.ok fine,
In the output (alv grid) there is an icon for layout settings.
if i want to save layout (as DEFAULT SETTING) i am missing some fields in output
EX:
mat no | batch | proces order | time | date |
when i save layout (as DEFAULT SETTING) i am missing some fields in output
mat no | batch |
the rest of the field were not displayed.
if u are not clear just ask me. i will send some more examples. -
Obtaining subtotals based on 2 fields.(ALV using oops concept)
Need help on how to apply sort on 2 fields and obtain subtotals.For example if I have some records for similar tax code and some more records for a similar tax jurisdiction (under which all tax codes come).I need to calculate subtotals for same tax code as well as same tax jurisdiction code.Currently I am able to generate subtotals by sorting on 1 field only ,using OOPs concept.How do I apply for both the fields? This is what is being done currently with regard to sorting and subtotaling :
METHOD set_sorts.
lr_sorts = gr_alv_data->get_sorts( ).
TRY.
lr_sorts->add_sort( 'TXJCD' ). ---sorting based on tax jurisdiction
CATCH: cx_salv_not_found,
cx_salv_existing,
cx_salv_data_error.
ENDTRY.
TRY.
lr_sorts->add_sort( columnname = 'MSKWZ'
subtotal = if_salv_c_bool_sap=>true ).
CATCH cx_salv_data_error cx_salv_not_found
cx_salv_existing.
ENDTRY.
ENDMETHOD. "set_sorts
Thanks & Regards,
SavithaHi Savitha,
Use the other paramenters like POSITION, SEQUENCE, SUBTOTAL for both fields like as follows. Then it will work fine.
TRY.
lr_sorts->add_sort( columnname = 'TXJCD'
sequence = 1
Position = 1
subtotal = if_salv_c_bool_sap=>true ).
CATCH cx_salv_data_error cx_salv_not_found
cx_salv_existing.
ENDTRY.
TRY.
lr_sorts->add_sort( columnname = 'MSKWZ'
sequence = 2
Position = 1
subtotal = if_salv_c_bool_sap=>true ).
CATCH cx_salv_data_error cx_salv_not_found
cx_salv_existing.
ENDTRY. -
Unable to print TOP_OF_PAGE in ALV Using OOPS??plz help me in my code
*&--data declaration
TYPE-POOLS : slis.
TYPES : BEGIN OF type_vbak,
vbeln LIKE vbak-vbeln, "SD Order
ernam LIKE vbak-ernam, "Name of the person who created
audat LIKE vbak-audat, "Document Date
vbtyp LIKE vbak-vbtyp, "SD Document Category
auart LIKE vbak-auart, "Type of Order
netwr LIKE vbak-netwr,
"Net value in sales current doc currency
waerk LIKE vbak-waerk, "SD Document Currency
vkorg LIKE vbak-vkorg, "Sales Organization
vtweg LIKE vbak-vtweg, "Distribution Chanel
spart LIKE vbak-spart, "Division
END OF type_vbak.
TYPES : BEGIN OF type_vbap,
vbeln LIKE vbap-vbeln, "SD Order
posnr LIKE vbap-posnr, "Sales Document Item
matnr LIKE vbap-matnr, "Component
charg LIKE vbap-charg, "Batch Number
matkl LIKE vbap-matkl, "Material Group
arktx LIKE vbap-arktx, "Short Text for Sales Order Item
kwmeng LIKE vbap-kwmeng,
"cumulative order quantity in sales unit
vrkme LIKE vbap-vrkme, "Sales Unit
netpr LIKE vbap-netpr, "Net Price
END OF type_vbap.
TYPES : type_t_vbak TYPE type_vbak,
type_t_vbap TYPE type_vbap.
DATA : it_vbak TYPE STANDARD TABLE OF type_t_vbak,
it_vbap TYPE STANDARD TABLE OF type_t_vbap.
DATA : wa_vbak TYPE type_t_vbak,
wa_vbap TYPE type_t_vbap.
DATA : d_vbeln LIKE vbak-vbeln,
d_audat LIKE vbak-audat,
lv_vbeln TYPE vbak-vbeln.
*&---Internal table for event catalog
DATA :it_event TYPE slis_t_event,
Internal table for Header printing
i_header TYPE slis_t_listheader,
*&---Work area for event catalog
wa_event TYPE slis_alv_event,
*&---Work area for report layout
wa_layout TYPE slis_layout_alv,
Workarea for Header printing
wa_header TYPE slis_listheader.
*&---cc1 is refering to the global class 'cl_gui_custom_container'
DATA : cc1 TYPE REF TO cl_gui_custom_container.
*&----alv1 is refering to the global class 'cl_gui_alv_grid'
DATA : alv1 TYPE REF TO cl_gui_alv_grid.
*&----work area for field catalog
DATA : wa_fieldcatalog1 TYPE lvc_s_fcat.
*&----internal table for field catalog
DATA : it_fieldcatalog1 TYPE lvc_t_fcat.
*&----data declaration for ok_code
DATA: ok_code_0101 LIKE sy-ucomm.
*&---cc2 is refering to the global class 'cl_gui_custom_container'
DATA : cc2 TYPE REF TO cl_gui_custom_container.
*&----alv2 is refering to the global class 'cl_gui_alv_grid'
DATA : alv2 TYPE REF TO cl_gui_alv_grid.
*&----work area for field catalog
DATA : wa_fieldcatalog2 TYPE lvc_s_fcat.
*&----internal table for field catalog
DATA : it_fieldcatalog2 TYPE lvc_t_fcat.
*&----data declaration for ok_code
DATA: ok_code_0102 LIKE sy-ucomm.
*&--defining the selection screen
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_vbeln FOR d_vbeln OBLIGATORY, "SD Order
s_audat FOR d_audat. "Document Date
SELECTION-SCREEN END OF BLOCK bl1.
AT SELECTION-SCREEN ON s_vbeln.
IF s_vbeln[] IS INITIAL.
SET CURSOR FIELD 'S_VBELN-LOW'.
MESSAGE e001 WITH text-001.
ELSE.
SELECT SINGLE vbeln INTO wa_vbak-vbeln
FROM vbak
WHERE vbeln IN s_vbeln.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VBELN-LOW'.
MESSAGE e002 WITH text-002.
ENDIF.
ENDIF.
DATA : wa_row_id TYPE lvc_s_row.
CLASS lcl_event_reciver DEFINITION
CLASS lcl_event_reciver DEFINITION.
PUBLIC SECTION.
&--defining the method for each event
METHODS : handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_top_of_page FOR EVENT TOP_OF_PAGE OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS. "lcl_event_reciver DEFINITION
CLASS lcl_event_reciver IMPLEMENTATION
CLASS lcl_event_reciver IMPLEMENTATION.
*&--implement the event handler methods for hot spot click.
METHOD handle_hotspot_click.
CLEAR lv_vbeln.
READ TABLE it_vbak INTO wa_vbak INDEX e_row_id.
lv_vbeln = wa_vbak-vbeln.
**&--for freeing the instance which was created alv2.
perform free_previous_object.
*CALL METHOD alv2->free
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
*&--fetching the data
*perform fetch_data_alv2 usinr lv_vbeln.
SELECT vbeln "SD Order
posnr "Sales Document Item
matnr "Component
charg "Batch Number
matkl "Material Group
arktx "Short Text for Sales Order Item
kwmeng "cumulative order quantity in sales unit
vrkme "Sales Unit
netpr "Net Price
INTO TABLE it_vbap
FROM vbap
WHERE vbeln = lv_vbeln.
IF sy-subrc <> 0.
MESSAGE e004 WITH text-004.
ENDIF.
*&---populating the second alv
*perform populate_fieldcatalog2.
*&-POPULATING THE FIELD VBELN
wa_fieldcatalog2-col_pos = 1. "position of the column
wa_fieldcatalog2-fieldname = 'VBELN'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
*wa_fieldcatalog2-hotspot = 'X'.
wa_fieldcatalog2-outputlen = 10. "output length of the field.
wa_fieldcatalog2-seltext = 'SD ORDER NUMBER'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD POSNR
wa_fieldcatalog2-col_pos = 2. "position of the column
wa_fieldcatalog2-fieldname = 'POSNR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SD ITEM'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD MATNR
wa_fieldcatalog2-col_pos = 3. "position of the column
wa_fieldcatalog2-fieldname = 'MATNR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'COMPONENT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD CHARG
wa_fieldcatalog2-col_pos = 4. "position of the column
wa_fieldcatalog2-fieldname = 'CHARG'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'BATCH NUMBER'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD MATKL
wa_fieldcatalog2-col_pos = 5. "position of the column
wa_fieldcatalog2-fieldname = 'MATKL'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'MATERIAL GROUP'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD ARKTX
wa_fieldcatalog2-col_pos = 6. "position of the column
wa_fieldcatalog2-fieldname = 'ARKTX'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SHORT TEXT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD KWMENG
wa_fieldcatalog2-col_pos = 7. "position of the column
wa_fieldcatalog2-fieldname = 'KEMENG'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SALES QUANTITY'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD VRKME
wa_fieldcatalog2-col_pos = 8. "position of the column
wa_fieldcatalog2-fieldname = 'VRKME'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SALES UNIT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD NETPR
wa_fieldcatalog2-col_pos = 9. "position of the column
wa_fieldcatalog2-fieldname = 'NETPR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'NET PRICE'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&--display the alv2
*perform display_alv2.
CREATE OBJECT cc2
EXPORTING
PARENT =
container_name = 'CUSTOMCONTROL2'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv2
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = cc2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD 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 =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = it_vbap
it_fieldcatalog = it_fieldcatalog2
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.
ENDMETHOD. "handle_hotspot_click
*&--implement the event handler methods for top of page
method handle_top_of_page.
CALL METHOD e_dyndoc_id->display_document
EXPORTING parent = cc1.
*write:/5 'Desc :' , 'Sales Document Header & Items'.
*write:/5 'Date :' , sy-datum.
*write:/5 'Page no :' , sy-pagno.
endmethod.
ENDCLASS. "lcl_event_reciver IMPLEMENTATION
*&--data for event handler in hot spot click
DATA: event_handler TYPE REF TO lcl_event_reciver,
*&--data for event handler in top of page
o_dd_doc TYPE REF TO cl_dd_document.
*&--main logic
START-OF-SELECTION.
*&--vbak.
SELECT vbeln "SD Order
ernam "Name of the person who created
audat "Document Date
vbtyp "SD Document Category
auart "Type of Order
netwr "Net value in sales current doc currency
waerk "SD Document Currency
vkorg "Sales Organization
vtweg "Distribution Chanel
spart "Division
INTO TABLE it_vbak
FROM vbak
WHERE vbeln IN s_vbeln AND
audat IN s_audat.
IF sy-subrc <> 0.
MESSAGE e003 WITH text-003.
ENDIF.
CLEAR wa_fieldcatalog1 .
REFRESH it_fieldcatalog1 .
*&-POPULATING THE FIELD VBELN
wa_fieldcatalog1-col_pos = 1. "position of the column
wa_fieldcatalog1-fieldname = 'VBELN'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-hotspot = 'X'.
wa_fieldcatalog1-outputlen = 10. "output length of the field.
wa_fieldcatalog1-seltext = 'SD ORDER NUMBER'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD ERNAM
wa_fieldcatalog1-col_pos = 2. "position of the column
wa_fieldcatalog1-fieldname = 'ERNAM'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 12. "output length of the field.
wa_fieldcatalog1-seltext = 'NAME OF THE PERSON WHO CREATED'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD AUDAT
wa_fieldcatalog1-col_pos = 3. "position of the column
wa_fieldcatalog1-fieldname = 'AUDAT'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 8. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT DATE'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VBTYP
wa_fieldcatalog1-col_pos = 4. "position of the column
wa_fieldcatalog1-fieldname = 'VBTYP'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 1. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT CATEGORY'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD AUART
wa_fieldcatalog1-col_pos = 5. "position of the column
wa_fieldcatalog1-fieldname = 'AUART'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 4. "output length of the field.
wa_fieldcatalog1-seltext = 'TYPE OF THE ORDER'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD NETWR
wa_fieldcatalog1-col_pos = 6. "position of the column
wa_fieldcatalog1-fieldname = 'NETWR'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 15. "output length of the field.
wa_fieldcatalog1-seltext = 'NET VALUE'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD WAERK
wa_fieldcatalog1-col_pos = 7. "position of the column
wa_fieldcatalog1-fieldname = 'WAERK'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 5. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT CURRENCY'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VKORG
wa_fieldcatalog1-col_pos = 8. "position of the column
wa_fieldcatalog1-fieldname = 'VKORG'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 4. "output length of the field.
wa_fieldcatalog1-seltext = 'SALES ORG'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VTWEG
wa_fieldcatalog1-col_pos = 9. "position of the column
wa_fieldcatalog1-fieldname = 'VTWEG'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 2. "output length of the field.
wa_fieldcatalog1-seltext = 'DISTRIBUTION CHANEL'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD SPART
wa_fieldcatalog1-col_pos = 10. "position of the column
wa_fieldcatalog1-fieldname = 'SPART'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 2. "output length of the field.
wa_fieldcatalog1-seltext = 'DIVISION'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
CREATE OBJECT cc1
EXPORTING
PARENT =
container_name = 'CUSTOMCONTROL1'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv1
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = cc1
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT event_handler.
*&---set handler for hot spot click
SET HANDLER: event_handler->handle_hotspot_click FOR alv1,
*&---set handler for top of page
event_handler->handle_top_of_page for alv1.
CALL METHOD alv1->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 =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = it_vbak
it_fieldcatalog = it_fieldcatalog1
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.
*&--for hot spot click
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = alv1.
*&--for top of page
CALL METHOD alv1->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
I_DYNDOC_ID = o_dd_doc
IS_SUBTOTTXT_INFO =
IP_SUBTOT_LINE =
I_TABLE_INDEX =
CHANGING
C_SUBTOTTXT =
CALL SCREEN 0101.
*& Module STATUS_0101 OUTPUT
text
MODULE status_0101 OUTPUT.
SET PF-STATUS 'Z9D_MENU1_ALV'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0101 OUTPUT
*& Module USER_COMMAND_0101 INPUT
text
MODULE user_command_0101 INPUT.
CASE ok_code_0101.
WHEN 'BCK1'.
LEAVE PROGRAM.
ENDCASE.*&--data declaration
TYPE-POOLS : slis.
TYPES : BEGIN OF type_vbak,
vbeln LIKE vbak-vbeln, "SD Order
ernam LIKE vbak-ernam, "Name of the person who created
audat LIKE vbak-audat, "Document Date
vbtyp LIKE vbak-vbtyp, "SD Document Category
auart LIKE vbak-auart, "Type of Order
netwr LIKE vbak-netwr,
"Net value in sales current doc currency
waerk LIKE vbak-waerk, "SD Document Currency
vkorg LIKE vbak-vkorg, "Sales Organization
vtweg LIKE vbak-vtweg, "Distribution Chanel
spart LIKE vbak-spart, "Division
END OF type_vbak.
TYPES : BEGIN OF type_vbap,
vbeln LIKE vbap-vbeln, "SD Order
posnr LIKE vbap-posnr, "Sales Document Item
matnr LIKE vbap-matnr, "Component
charg LIKE vbap-charg, "Batch Number
matkl LIKE vbap-matkl, "Material Group
arktx LIKE vbap-arktx, "Short Text for Sales Order Item
kwmeng LIKE vbap-kwmeng,
"cumulative order quantity in sales unit
vrkme LIKE vbap-vrkme, "Sales Unit
netpr LIKE vbap-netpr, "Net Price
END OF type_vbap.
TYPES : type_t_vbak TYPE type_vbak,
type_t_vbap TYPE type_vbap.
DATA : it_vbak TYPE STANDARD TABLE OF type_t_vbak,
it_vbap TYPE STANDARD TABLE OF type_t_vbap.
DATA : wa_vbak TYPE type_t_vbak,
wa_vbap TYPE type_t_vbap.
DATA : d_vbeln LIKE vbak-vbeln,
d_audat LIKE vbak-audat,
lv_vbeln TYPE vbak-vbeln.
*&---Internal table for event catalog
DATA :it_event TYPE slis_t_event,
Internal table for Header printing
i_header TYPE slis_t_listheader,
*&---Work area for event catalog
wa_event TYPE slis_alv_event,
*&---Work area for report layout
wa_layout TYPE slis_layout_alv,
Workarea for Header printing
wa_header TYPE slis_listheader.
*&---cc1 is refering to the global class 'cl_gui_custom_container'
DATA : cc1 TYPE REF TO cl_gui_custom_container.
*&----alv1 is refering to the global class 'cl_gui_alv_grid'
DATA : alv1 TYPE REF TO cl_gui_alv_grid.
*&----work area for field catalog
DATA : wa_fieldcatalog1 TYPE lvc_s_fcat.
*&----internal table for field catalog
DATA : it_fieldcatalog1 TYPE lvc_t_fcat.
*&----data declaration for ok_code
DATA: ok_code_0101 LIKE sy-ucomm.
*&---cc2 is refering to the global class 'cl_gui_custom_container'
DATA : cc2 TYPE REF TO cl_gui_custom_container.
*&----alv2 is refering to the global class 'cl_gui_alv_grid'
DATA : alv2 TYPE REF TO cl_gui_alv_grid.
*&----work area for field catalog
DATA : wa_fieldcatalog2 TYPE lvc_s_fcat.
*&----internal table for field catalog
DATA : it_fieldcatalog2 TYPE lvc_t_fcat.
*&----data declaration for ok_code
DATA: ok_code_0102 LIKE sy-ucomm.
*&--defining the selection screen
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_vbeln FOR d_vbeln OBLIGATORY, "SD Order
s_audat FOR d_audat. "Document Date
SELECTION-SCREEN END OF BLOCK bl1.
AT SELECTION-SCREEN ON s_vbeln.
IF s_vbeln[] IS INITIAL.
SET CURSOR FIELD 'S_VBELN-LOW'.
MESSAGE e001 WITH text-001.
ELSE.
SELECT SINGLE vbeln INTO wa_vbak-vbeln
FROM vbak
WHERE vbeln IN s_vbeln.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VBELN-LOW'.
MESSAGE e002 WITH text-002.
ENDIF.
ENDIF.
DATA : wa_row_id TYPE lvc_s_row,
<b>ls_print type lvc_s_prnt.</b>
CLASS lcl_event_reciver DEFINITION
CLASS lcl_event_reciver DEFINITION.
PUBLIC SECTION.
&--defining the method for each event
METHODS : handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_top_of_page FOR EVENT TOP_OF_PAGE OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS. "lcl_event_reciver DEFINITION
CLASS lcl_event_reciver IMPLEMENTATION
CLASS lcl_event_reciver IMPLEMENTATION.
*&--implement the event handler methods for hot spot click.
METHOD handle_hotspot_click.
CLEAR lv_vbeln.
READ TABLE it_vbak INTO wa_vbak INDEX e_row_id.
lv_vbeln = wa_vbak-vbeln.
**&--for freeing the instance which was created alv2.
perform free_previous_object.
*CALL METHOD alv2->free
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_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.
*&--fetching the data
*perform fetch_data_alv2 usinr lv_vbeln.
SELECT vbeln "SD Order
posnr "Sales Document Item
matnr "Component
charg "Batch Number
matkl "Material Group
arktx "Short Text for Sales Order Item
kwmeng "cumulative order quantity in sales unit
vrkme "Sales Unit
netpr "Net Price
INTO TABLE it_vbap
FROM vbap
WHERE vbeln = lv_vbeln.
IF sy-subrc <> 0.
MESSAGE e004 WITH text-004.
ENDIF.
*&---populating the second alv
*perform populate_fieldcatalog2.
*&-POPULATING THE FIELD VBELN
wa_fieldcatalog2-col_pos = 1. "position of the column
wa_fieldcatalog2-fieldname = 'VBELN'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
*wa_fieldcatalog2-hotspot = 'X'.
wa_fieldcatalog2-outputlen = 10. "output length of the field.
wa_fieldcatalog2-seltext = 'SD ORDER NUMBER'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD POSNR
wa_fieldcatalog2-col_pos = 2. "position of the column
wa_fieldcatalog2-fieldname = 'POSNR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SD ITEM'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD MATNR
wa_fieldcatalog2-col_pos = 3. "position of the column
wa_fieldcatalog2-fieldname = 'MATNR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'COMPONENT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD CHARG
wa_fieldcatalog2-col_pos = 4. "position of the column
wa_fieldcatalog2-fieldname = 'CHARG'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'BATCH NUMBER'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD MATKL
wa_fieldcatalog2-col_pos = 5. "position of the column
wa_fieldcatalog2-fieldname = 'MATKL'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'MATERIAL GROUP'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD ARKTX
wa_fieldcatalog2-col_pos = 6. "position of the column
wa_fieldcatalog2-fieldname = 'ARKTX'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SHORT TEXT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD KWMENG
wa_fieldcatalog2-col_pos = 7. "position of the column
wa_fieldcatalog2-fieldname = 'KEMENG'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SALES QUANTITY'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD VRKME
wa_fieldcatalog2-col_pos = 8. "position of the column
wa_fieldcatalog2-fieldname = 'VRKME'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'SALES UNIT'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&-POPULATING THE FIELD NETPR
wa_fieldcatalog2-col_pos = 9. "position of the column
wa_fieldcatalog2-fieldname = 'NETPR'. "field name
wa_fieldcatalog2-tabname = 'IT_VBAP'. "INTERNAL table name
wa_fieldcatalog2-ref_table = 'VBAP'. "FOR REFERENCE
wa_fieldcatalog2-outputlen = 2. "output length of the field.
wa_fieldcatalog2-seltext = 'NET PRICE'.
"long key word
APPEND wa_fieldcatalog2 TO it_fieldcatalog2.
CLEAR wa_fieldcatalog2.
*&--display the alv2
*perform display_alv2.
CREATE OBJECT cc2
EXPORTING
PARENT =
container_name = 'CUSTOMCONTROL2'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv2
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = cc2
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD 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 =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = it_vbap
it_fieldcatalog = it_fieldcatalog2
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.
ENDMETHOD. "handle_hotspot_click
*&--implement the event handler methods for top of page
method handle_top_of_page.
CALL METHOD e_dyndoc_id->display_document
EXPORTING parent = cc1.
*write:/5 'Desc :' , 'Sales Document Header & Items'.
*write:/5 'Date :' , sy-datum.
*write:/5 'Page no :' , sy-pagno.
endmethod.
ENDCLASS. "lcl_event_reciver IMPLEMENTATION
*&--data for event handler in hot spot click
DATA: event_handler TYPE REF TO lcl_event_reciver,
*&--data for event handler in top of page
o_dd_doc TYPE REF TO cl_dd_document.
*&--main logic
START-OF-SELECTION.
*&--vbak.
SELECT vbeln "SD Order
ernam "Name of the person who created
audat "Document Date
vbtyp "SD Document Category
auart "Type of Order
netwr "Net value in sales current doc currency
waerk "SD Document Currency
vkorg "Sales Organization
vtweg "Distribution Chanel
spart "Division
INTO TABLE it_vbak
FROM vbak
WHERE vbeln IN s_vbeln AND
audat IN s_audat.
IF sy-subrc <> 0.
MESSAGE e003 WITH text-003.
ENDIF.
CLEAR wa_fieldcatalog1 .
REFRESH it_fieldcatalog1 .
*&-POPULATING THE FIELD VBELN
wa_fieldcatalog1-col_pos = 1. "position of the column
wa_fieldcatalog1-fieldname = 'VBELN'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-hotspot = 'X'.
wa_fieldcatalog1-outputlen = 10. "output length of the field.
wa_fieldcatalog1-seltext = 'SD ORDER NUMBER'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD ERNAM
wa_fieldcatalog1-col_pos = 2. "position of the column
wa_fieldcatalog1-fieldname = 'ERNAM'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 12. "output length of the field.
wa_fieldcatalog1-seltext = 'NAME OF THE PERSON WHO CREATED'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD AUDAT
wa_fieldcatalog1-col_pos = 3. "position of the column
wa_fieldcatalog1-fieldname = 'AUDAT'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 8. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT DATE'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VBTYP
wa_fieldcatalog1-col_pos = 4. "position of the column
wa_fieldcatalog1-fieldname = 'VBTYP'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 1. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT CATEGORY'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD AUART
wa_fieldcatalog1-col_pos = 5. "position of the column
wa_fieldcatalog1-fieldname = 'AUART'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 4. "output length of the field.
wa_fieldcatalog1-seltext = 'TYPE OF THE ORDER'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD NETWR
wa_fieldcatalog1-col_pos = 6. "position of the column
wa_fieldcatalog1-fieldname = 'NETWR'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 15. "output length of the field.
wa_fieldcatalog1-seltext = 'NET VALUE'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD WAERK
wa_fieldcatalog1-col_pos = 7. "position of the column
wa_fieldcatalog1-fieldname = 'WAERK'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 5. "output length of the field.
wa_fieldcatalog1-seltext = 'DOCUMENT CURRENCY'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VKORG
wa_fieldcatalog1-col_pos = 8. "position of the column
wa_fieldcatalog1-fieldname = 'VKORG'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 4. "output length of the field.
wa_fieldcatalog1-seltext = 'SALES ORG'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD VTWEG
wa_fieldcatalog1-col_pos = 9. "position of the column
wa_fieldcatalog1-fieldname = 'VTWEG'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 2. "output length of the field.
wa_fieldcatalog1-seltext = 'DISTRIBUTION CHANEL'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
*&-POPULATING THE FIELD SPART
wa_fieldcatalog1-col_pos = 10. "position of the column
wa_fieldcatalog1-fieldname = 'SPART'. "field name
wa_fieldcatalog1-tabname = 'IT_VBAK'. "INTERNAL table name
wa_fieldcatalog1-ref_table = 'VBAK'. "FOR REFERENCE
wa_fieldcatalog1-outputlen = 2. "output length of the field.
wa_fieldcatalog1-seltext = 'DIVISION'.
"long key word
APPEND wa_fieldcatalog1 TO it_fieldcatalog1.
CLEAR wa_fieldcatalog1.
CREATE OBJECT cc1
EXPORTING
PARENT =
container_name = 'CUSTOMCONTROL1'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT alv1
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = cc1
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT event_handler.
*&---set handler for hot spot click
SET HANDLER: event_handler->handle_hotspot_click FOR alv1,
*&---set handler for top of page
event_handler->handle_top_of_page for alv1.
<b>LS_PRINT-RESERVELNS = '3'.</b>
CALL METHOD alv1->set_table_for_first_display
<b> EXPORTING</b>
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT =
<b>IS_PRINT = ls_print</b>
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
it_outtab = it_vbak
it_fieldcatalog = it_fieldcatalog1
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.
*&--for hot spot click
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = alv1.
*&--for top of page
CALL METHOD alv1->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
I_DYNDOC_ID = o_dd_doc
IS_SUBTOTTXT_INFO =
IP_SUBTOT_LINE =
I_TABLE_INDEX =
CHANGING
C_SUBTOTTXT =
CALL SCREEN 0101.
*& Module STATUS_0101 OUTPUT
text
MODULE status_0101 OUTPUT.
SET PF-STATUS 'Z9D_MENU1_ALV'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0101 OUTPUT
*& Module USER_COMMAND_0101 INPUT
text
MODULE user_command_0101 INPUT.
CASE ok_code_0101.
WHEN 'BCK1'.
LEAVE PROGRAM.
ENDCASE.
i have made the changes and bolded the changes in ur program. pls check .
note: u can see the top of page only in print preview. -
Hello ......
i have developed z table, initially there are no entries in it.
i create a z program and create a alv display using method SET_TABLE_FOR_FIRST_DISPLAY
then i have used method set_ready_for_input .
i will now execute the z program..
i will have a std toolbar on screen, there will be three icons insert, delete and append (std tool bar)
as i have told earlier that there are no entries, so when i will press insert button it will be show empty one row in that table, it will be in edit mode due to method set_ready_for_input ..
now my query is suppose there are 3 col and i vl enter value in 3 columns shown in table after pressign insert button, how to get those values in internal table so that later on i can update a z table .
Edited by: medha24 on Apr 15, 2011 11:59 AMthanks friends, let me more clear with u all,
when i will execute the program, i can only see headings of alv display rather table........
to create entries , i m pressing insert button, which comes as in-built as alv std toolbar.....
now when i press insert, it will show me one empty row, i vl enter some values in it.....
how i will get those entries in my internal table......
which method,, wht event........?
Maybe you are looking for
-
Using Swing applet to write data to file on SERVER
Hello, I'm in the process of writing an applet using Swing (SDK v1.4.2). Here's the deal. The JApplet calls a JPanel, which will be used by customers on my site to enter data. I'm adding a <Save> button to the "form" which is supposed to write data t
-
Hi guys, please try this: 1) new image, grayscale 2) fill (say 96,96,96) 3) image->mode->rgb color The pixels will be (95,95,95) and (96,96,96) when they should *all* be the same. It also happens when you paste a black & white image into an RGB docum
-
Does my MacPro have BlueTooth or not?
I have a MacPro 4,1 (2.66 GHz quad-core, 3 GB RAM) that Apple offered as a replacement for my PowerMac G5 after I had problems with the logic board 3 different times over less then 1 year. On the menubar the Bluetooth icon was there so I click on the
-
Setting up e-printing on HO Office jet 7500 series printer
how do i set up e-printing on my HP Office jet 7500 E901a
-
Dear all, I having been using Thunderbird before and recently Apple Mail 3 get my attention. However I find alot of my China staff's email's attachment become MIME attachment. No matter how they attach it. I try different extension like: Rar, zip, do