How to cancel invoices shown by alv grid using bapi?
hi,
i have a alv grid showing all the invoices .now i want to cancel the selected invoices using bapi......how?
Moderator message - Welcome to SCN.
But please ask a specific question. Do not just post your requirements and ask for help - thread locked.
Also, Please read Please read "The Forum Rules of Engagement" before posting! HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
Rob
Similar Messages
-
How to enable excel downloading in ALV grid report.
Hi all,
How to enable excal downing in ALV grid report?
Thanks in Advance.
Siva Sankar.hi
check the following code
Example of a Simple ALV Grid Report
REPORT ZTUFI091 .
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
*REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data 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,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
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-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_events
is_print = gd_prntparams
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
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
hope it will help you
regards
sreelatha gullapalli -
How to get f4 help in alv grid in container-urgent
hi,
how to get f4 help in alv grid in container using abap objects
ganeshHi Ganesh,
Did you have a look at sample report BCALV_TEST_GRID_F4_HELP ?
Here is part of the header documentation:
*& Report BCALV_GRID_F4_HELP *
Purpose:
~~~~~~~~
This report illustrates the use of f4-Help in an alv grid control.
Background:
~~~~~~~~~~~
There a two possibilities to implement an f4-Help in the alv grid
control: one can either use standard f4-help or write one by Hand.
For the former there is nothing to do at all. This report shows how
to implement user-defined f4-help.
I am sure you will find within this report the solution you are looking for.
Reward points if this Helps.
Manish -
How to trigger left_click_run event on ALV GRID
Hiiiiiiii........
Can any of u please tell me how to trigger left_click_run event on ALV GRID.
There is an event LEFT_CLICK_RUN and its a public accessed event. But the problem is , the corresponding attribute of this event "EVENT_LEFT_CLICK_RUN" which is needed to registered that event (We need to register our events through a method set_register_events using table of type cntl_simple_events...) is protect accessed. So I am unable to use that attribute...Could u please tell me is there any alternative way to register that event.......ANY POSSIBLE WAY?
Thanks in advance,
RamsI think you should use event selection_changed. Note that you shouldn't allow multiple selection for the tree at the same time, i.e. use: create object g_tree exporting \[...\] node_selection_mode = cl_gui_column_tree=>node_sel_mode_single.
For more information, see this thread: Urgently required : cl_gui_alv_tree single_click event... -
How to cancell Invoice by VF11
Salute Masters !!
I have created one new Sales Order Type PW00 Warranty Order for Plant P&YE (Port & Yard Equipment), Copied from Existing Sales Order Type EW00 Warranty Order Type for Plant BMHE (Bulk Material Handling Equipment) in which I have given separate No. Range From 3330000000 To 3339999999.
In PW00, I have given Delivery Document Type PY00 by No. Range from 3270000000 To 3279999999; Delivery Related Billing Type PY01 by No. Range 3290000000 To 3299999999 and have assigned to respected document.
Now, Sales Order has been created by 3330000000, subsequent Delivery has been done by 3270000001 and Invoice has been done by 3290000003, Released to Accounting and Excise Invoice done by 3290000003.
Now user wanted to get the same No. by which Accounting document generated internally which was created by FI side through FBN1, No. Range 3601000001 To 3791099999, for their Financial Accounting Document Type (OBA7), as it was given in my Billing Document type PY01, that is PB (Standard was EB), instead of 3290000003,
as his other plants Nos. are same as well as Invoice No. & Accounting Document No.
I have changed No. Range from 3290000000-32999999999 To 3601000001-3601999999 in VN01.
After wards user cancelled the excise invoice and tried to cancel Commercial Invoice by VF11, now system is giving error,
No Billing Document were generated
When check error log, its saying, Data inconsistency during processing of Document 3290000000
The Billing Document 3290000000 is already cleared
I have changed again the No. Range from 3601000001-3601999999 To 3290000000-32999999999
Still system is giving error,
No Billing Document were generated
When check error log, its saying, Data inconsistency during processing of Document 3290000000
The Billing Document 3290000000 is already cleared
Please suggest how to cancel invoice & give the same No. Range as per user requirement and we can do Excise Invoice.
Thanks & Regards
Srivastav
+91-9973504950As I already mentioned, you need to remove Copying requirements in Cancellation section of Billing Doc type-PY01 (tcode VOFA).
As the routine is for cancelling an invoice that has been cleared in accounting. So, this copying requirements are FORM routines that check certain requirements as a precondition for the copying process. This requirement checks if a billing document has been paid in AR prior to permitting cancellation. For example, If an error has been made in invoicing, it is possible to create a cancellation invoice and then re-bill the customer for the correct amount. This process, however, should not be allowed if the invoice has already been forwarded to the customer and payment has been received and applied. This requirement can be assigned to the billing document to insure that no paid invoices are allowed to be canceled.
So, remove that and try.
And check you doc number 3290000003 with tcode FB03
Also, Doc type PB in tcode OBA7, check
- number range for doc type.
- Reversal Doc type and number range for reversal doc type.
Hope this can assist you.
Thanks & Regards
JP -
ALV grid using methods: how to get modified cells
Hi all,
IAM USING alv grid using methods,
i have few fields as editable
if the user edits any of those fields how can i know which cell is modified and what is the new value.
i tried to use method get_modified_cells
but iam getting a msg saying protected method and u can not use.
please advise.
thanks
JAfarJafar,
You need to Take the Help of DATA_CHANGED event, when ever there is a change in the Grid, it will trigger, here you can capture the Cells which are modified.
in your PAI call the method check changed data
CL_GUI_ALV_GRID-->CHECK_CHANGED_DATA
You need to set the handler for datachanged.
set the handler for this, and register the event modified or enter.
**Handler to Check the Data Change
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,
**Handle Data Change
METHOD HANDLE_DATA_CHANGED.
DATA: X_CHANGE TYPE LVC_S_MODI. "modified cells
LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
ENDLOOP.
ENDMETHOD. "HANDLE_DATA_CHANGED
Regards
Vijay -
How can I call functionality of ALV Grid by event of button outside grid?
Hello,
How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
Best regards,
Josef Motlhi Motl,
these are steps to create a button in ALV and trigger an event from it..
1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'NEWALVSTATUS'.
endform.
You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
2.You have to do the following to process the new button click.
i_callback_user_command = 'USER_COMMAND'
form user_command using i_ucomm like sy-ucomm
is_selfield type slis_selfield.
case i_ucomm.
3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status. Then look for the standard pf status. Copy this to Z range and then add your new button.
reward points if helpful
regards
satesh -
How to make a field manadatory within ALV Grid using methods and classes
Hi,
I am using ALV Grid using set_table_for_first_display
inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
Is there any other way, i can accomplish this within the ALV grid?from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
i dont know anthing in fieldcat, but u can try the following logic.
FORM DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL .
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
if sy-subrc = 0.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
ENDIF. -
Display error message in ALV grid using OOPS
Hi,
I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell and click on the Toolbar button, sales order item should be assigned to contract.
When the user select the row and click on toolbar button, a salesorder item should be assigned to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row should change its color .
Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
To display POP Up, I am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row.
Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because, error log is not refreshing.
Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
Thanks in AdvanceHi
Please suggest me how to clear error log which was created by using the above FM's....
U can use BAL_LOG_REFRESH
....and change the color of the failed row
You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
IS_LAYOUT-INFO_FNAME = <field name for colour>
The field has to be a CHAR 3 and its value can be -
> Cxy
C is a constant
x is the colour number (from 1 to 9)
y is intensified (0 = off, 1 = on)
After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
Max -
Header in alv grid using class
Hello All,
I developed alv grid using class method.
First I created CREATE OBJECT GR_CCONTAINER
then CREATE OBJECT GR_ALVGRID
then PERFORM FIELD_CATALOG TABLES GT_FIELDCAT----
for field catalog
PERFORM LAYOUT CHANGING GS_LAYOUT.----
for header
p_gs_layout-grid_title = 'class method'.
p_gs_layout-sel_mode = 'D'.
APPEND P_GS_LAYOUT TO IT_LAYOUT.
and finally CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
the report is cooming fine but in header it comes only "class method".
but i need also
1. reporting date
2. reporting time.
can any body tell me how i can i put 2 more heading line
Thanks,
RakeshHi Dude,
Please refer the below link how to handle the header in alv using abap oo
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer
Hope it clears,..............
Thanks & Regards
Ramakrishna Pathi -
F4 help in ALV grid using existing search help
Hi All,
It would be appreciable , if some help on problem. Thanks in advance.
How to provide user defined F4 help in ALV grid using existing search help?
ALV grid has developed using OOPS concept.
Thanks,
Sudhakar.Hi,
if you already developed using OO concept, it should be possible to:
create a handler for event ONF4
The interface will tell you actual field name and value where F4 is pressed. This will enable you to call your own routine (see FM F4-IF....).
Please check how the standard handles F4 - if you have standard and customer-F4 mixed you shouldtake care that the standard handling is triggered.
Regards,
Clemens -
Display ALV GRID Using Dynamic Internal Table
Hi all,
I try to display ALV Grid using Dynamic Internal Table, but when i activate my program, i get an error message "DYN_TABLE" is not type-compatible with formal parameter "IT_OUTTAB". ( DYN_TABLE is my Dynamic Itab).
Anybody can help me how to passing Dynamic Itab into ALV Grid ?? Of ALV Grid only accept static Itab ??
Thanks,Hi Vijay,
It's doesn't work, and make new error "Formal parameter "IT_OUTTAB[]" does not exist. However, the parameter "IT_OUTTAB" has a similar name."
Because the method is:
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE = <any type (ANY)>
I_STRUCTURE_NAME = <string of type DD02L-TABNAME>
IS_VARIANT = <structure of type DISVARIANT>
I_SAVE = <var. of type CHAR01>
I_DEFAULT = <var. of type CHAR01>
IS_LAYOUT = <structure of type LVC_S_LAYO>
IS_PRINT = <structure of type LVC_S_PRNT>
IT_SPECIAL_GROUPS = <internal table of type LVC_T_SGRP>
IT_TOOLBAR_EXCLUDING = <internal table of type UI_FUNCTIONS>
IT_HYPERLINK = <internal table of type LVC_T_HYPE>
IT_ALV_GRAPHICS = <internal table of type DTC_T_TC>
CHANGING
IT_OUTTAB = <internal table>
IT_FIELDCATALOG = <internal table of type LVC_T_FCAT>
IT_SORT = <internal table of type LVC_T_SORT>
IT_FILTER = <internal table of type LVC_T_FILT>
Thanks, -
Alv grid using dynamic internal table
hi i have an internal table
begin of itab
equipno like equi-equnr,
reading like imrg-readg
uom like imrg-uom
date like imrg-date
end of itab.
and many more fields in this table the reading, date, uom are dynamic its not fixed there can be five readings and 6 reading etc
if i get all the data populated into final table itab. how to display it throgh the alv grid
i can use fieldsymbols i have seen some documents i want to know how to populate the fieldname s of the dynamic internal table to the field catalog and the values of the dynamic internal table .its a alv grid display pls guideHi,
Before displaying the records in ALV, you integrate all the fields (Fixed fields as well as variable fields) into one table. To do so you need create one dynamic table. If you already created this dynamic table then in the same way (same sequence) you need to populate the field catalog and use normal FM REUSE_ALV_GRID_DISPLAY to display it.
If you not aware of how to create this dynamic internal table, please check the below way.
1. Populate the fixed field into one field catalog(NB. this to create dyn table not ALV).
*--- Cons Unit
wa_lvc_cat-fieldname = c_cons.
wa_lvc_cat-ref_field = c_rbunit.
wa_lvc_cat-ref_table = c_ecmca.
append wa_lvc_cat to it_lvc_cat.
*--- account description
wa_lvc_cat-fieldname = c_acctd.
wa_lvc_cat-ref_field = c_txtmi.
wa_lvc_cat-ref_table = c_tf101.
append wa_lvc_cat to it_lvc_cat.
2. For variable fields you have your own logic based on which you need to display the output. (like loop at one table and make each field as one column). Here one thing need to make sure every time field name should be different. You know in one structure there are 2 fields with same name is not allowed.
3. next use the below method to create the internal table
Create a new Table
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_lvc_cat
importing
ep_table = it_new_table.
Create a new Line with the same structure of the table.
assign it_new_table->* to <l_table>. " internal table
create data wa_new_line like line of <l_table>.
assign wa_new_line->* to <l_line>. " Work area
4. To populate the field catalog for ALV use the same sequence. Better while you populated it_lvc_cat for dynamic table also create one lookup table with three fields. (fieldname, Text, col_pos). Here loop into this look up table and populate the ALV field catalog.
5. Display it using REUSE_ALV_GRID_DISPLAY
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = c_rep_name
i_callback_user_command = 'F_USER_DOUBLE_CLICK' "SD0K963313
is_layout = l_wa_layout
it_fieldcat = it_fieldcat
it_sort = it_sort
i_save = l_save
is_variant = wa_variant1
it_events = it_events
tables
t_outtab = <l_table>
exceptions
program_error = 1
others = 2.
Thanks
Subhankar -
HI all,
Is it necessary to use container for ALV grid using classes.If not then please help me with a sample code.REPORT z_alv_using_oops_conepts MESSAGE-ID z_OOPS.
TABLES: ekko, ekpo.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: ok_code TYPE sy-ucomm,
gx_fcat1 TYPE lvc_s_fcat,
gt_fcat1 TYPE STANDARD TABLE OF lvc_s_fcat,
gx_fcat2 TYPE lvc_s_fcat,
gt_fcat2 TYPE STANDARD TABLE OF lvc_s_fcat,
gx_layout1 TYPE lvc_s_layo,
gx_layout2 TYPE lvc_s_layo,
gx_variant TYPE disvariant,
g_custom_container1 TYPE REF TO cl_gui_custom_container,
g_custom_container2 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
g_container1 TYPE scrfname VALUE 'MAIN_REPORT_LIST',
g_container2 TYPE scrfname VALUE 'SECOND_REPORT_LIST',
gv_event_rec1 TYPE REF TO lcl_event_receiver,
gv_event_rec2 TYPE REF TO lcl_event_receiver,
gv_repid TYPE sy-repid,
gt_final1 TYPE STANDARD TABLE OF ekko,
gt_final2 TYPE STANDARD TABLE OF ekpo,
gt_final3 TYPE STANDARD TABLE OF ekpo,
gx_final TYPE ekko,
gx_final1 TYPE ekpo.
INITIALIZATION.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME .
SELECT-OPTIONS:
s_ebeln FOR ekko-ebeln obligatory,
s_ebelp FOR ekpo-ebelp,
s_bukrs FOR ekko-bukrs,
s_bsart FOR ekko-bsart.
SELECTION-SCREEN END OF BLOCK blk3.
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
hotspot_click1
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id,
hotspot_click2
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD hotspot_click1.
DATA: lv_tabix TYPE sy-tabix,
lx_final TYPE ekko.
READ TABLE gt_final1 INTO gx_final INDEX e_row_id.
IF sy-subrc = 0.
gt_final3 = gt_final2.
DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
IF NOT g_custom_container2 IS INITIAL.
CALL METHOD grid2->refresh_table_display.
CALL METHOD grid1->refresh_table_display.
ENDIF.
ELSE.
MESSAGE s000 WITH text-003.
LEAVE LIST-PROCESSING.
ENDIF.
ENDMETHOD. "hotspot_click1
METHOD hotspot_click2.
READ TABLE gt_final3 INTO gx_final1 INDEX e_row_id.
IF sy-subrc = 0.
SET PARAMETER ID 'BES' FIELD gx_final-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "button_click1
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
START-OF-SELECTION *
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE gt_final1 WHERE ebeln IN s_ebeln
AND bukrs IN s_bukrs
AND bsart IN s_bsart.
IF sy-subrc = 0.
SELECT * FROM ekpo INTO TABLE gt_final2 FOR ALL ENTRIES IN gt_final1
WHERE ebeln = gt_final1-ebeln
AND ebelp IN s_ebelp.
IF sy-subrc = 0.
gt_final3 = gt_final2.
ENDIF.
ENDIF.
PERFORM sub_get_fieldcat CHANGING gt_fcat1.
PERFORM sub_get_fieldcat CHANGING gt_fcat2.
END-OF-SELECTION *
END-OF-SELECTION.
PERFORM display_process.
CALL SCREEN 9000.
MODULE pbo OUTPUT
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
gx_layout1-grid_title = 'Purchase Order Header'.
gx_layout1-zebra = 'X'.
gx_layout1-info_fname = 'COLOR_LINE'.
gx_layout1-sel_mode = 'X'.
gx_layout2-grid_title = 'Purchase Order Items'.
gx_layout2-zebra = 'X'.
gx_layout1-stylefname = 'CB'.
gs_layout1-excp_led = gc_check.
gs_layout1-excp_group = gc_check.
gv_repid = sy-repid.
gx_variant-report = gv_repid.
READ TABLE gt_final1 INTO gx_final INDEX 1.
IF sy-subrc = 0.
DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
ENDIF.
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING
container_name = g_container1.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container1.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = gx_layout1
is_variant = gx_variant
i_save = 'U'
i_default = 'X'
i_structure_name = 'EKKO'
CHANGING
it_outtab = gt_final1
it_fieldcatalog = gt_fcat1.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDIF.
IF g_custom_container2 IS INITIAL.
CREATE OBJECT g_custom_container2
EXPORTING
container_name = g_container2.
CREATE OBJECT grid2
EXPORTING
i_parent = g_custom_container2.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
is_layout = gx_layout2
is_variant = gx_variant
i_save = 'U'
i_default = 'X'
i_structure_name = 'EKPO'
CHANGING
it_outtab = gt_final3
it_fieldcatalog = gt_fcat2.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid2.
ENDIF.
CREATE OBJECT gv_event_rec1.
SET HANDLER gv_event_rec1->hotspot_click1 FOR grid1.
CREATE OBJECT gv_event_rec2.
SET HANDLER gv_event_rec1->hotspot_click2 FOR grid2.
IF gt_final2 IS INITIAL.
MESSAGE i000 WITH 'No Items exist for the Purchase Order'.
ENDIF.
ENDMODULE. "PBO OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
To react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD grid1->free.
CALL METHOD grid2->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = gv_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(009).
ENDIF.
ENDFORM. "EXIT_PROGRAM
*& Form display_process
text
--> p1 text
<-- p2 text
FORM display_process .
DATA: a LIKE sy-ucomm.
DO 100 TIMES.
DO 300 TIMES.
GET TIME.
ENDDO.
a(3) = sy-index.a+3 = '%'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = sy-index
text = a.
ENDDO.
ENDFORM. " display_process
*& Form sub_get_fieldcat
text
<--P_GT_FCAT1 text
FORM sub_get_fieldcat CHANGING lt_fcat TYPE lvc_t_fcat.
gx_fcat1-fieldname = 'EBELN'.
gx_fcat1-tabname = 'gt_final1'.
gx_fcat1-hotspot = 'X'.
APPEND gx_fcat1 TO lt_fcat.
ENDFORM. " sub_get_fieldcat -
Coulmn validation on ALV Grid (using Classes)
Hi All,
I'm creating a ALV Grid using calsses. I want to check the column value of Grid and raise some errror message. How to do this.
Regards
Jaker.have a look at sample report BCALV_EDIT_03
Maybe you are looking for
-
My ipod is not getting charged, and its not being recognized by windows
The day before, i left my ipod in the bathroom for the whole day without doing anything to it. Yes, the battery was already drained i just didn't charge it. Today, I connected my ipod to my computer to charge but nothign is happening. Usually it'll s
-
When going back and Click many slide Unanswered questions on Quiz are not counted correctly
Hi, I'm using Captivate 8, and made a simple multiple choice quiz, with an option "submit all button". It works correct, except for when using the back button,and when i clicking many slides in right side navigation. When trying to submit, I get the
-
Workflow step by step configuration for scheduling level agreement release
Hi All, I tried alot to configure step by step scheduling level agreement release using workflow. But, The release code I couln't pass using workflow. Plz guide me, or let me know some useful links for the same.
-
How will I know the carrier of my iPhone 5?
I bought my iPhone 5 in Thailand through online apple.com , but I want to know the carrier of it. thank you.
-
Online printing services and that built into Aperture
Hi, I regularly have pictures printed by a well known high street photo store here in the UK but just recently I've been disappointed with some of the results. They're coming back too dark and with a yellow cast even though the original files look fi