ALV usage
Hi Experts,
I know report generation in ALV by using Functions modules and By using Objects. So my doubt is What kind of situations will demand to use 'Functions modules' and 'Objects procedure'.
Hi Chinna,
In most cases, ABAP Objects is the better choice.
Once you are used to this OOPs concepts, you are advised to use the Procedural ABAP only when required and when there is no other alternative to use it.
I'm sure you are aware of the Principles of OOPs.
You should be able to judge which one to use!
To be honest, I'm not using ABAP Objects in my project. But, going forward I would certainly make it a habit to use it.
As we are stepping into the ESA world, OOPs is the only WAY!
Regards,
Arun
Similar Messages
-
Hi every body ,
My requirment is : i have a tabstrip and the no.of tabs in the tabstrip is dynamic. So in each tab i am creating table ui element and binding the single context only in each tab .I am using the same node on each tab . Now my requirment is i want use the ALV.
I am using single node in all tabs . I need to use 1 ALV component in all the tabs . So guide me how to change the ALV table in all the view container UI elements based on my tab number . All should be done in the run time dynamically only .
Thank in advance ,
vijayHi,
Is the context dynamic or static.
You can use the sginle ALV instance but you need to use the SET_DATA and give the node name.
When you create the tabstrip and add a tab to it dynamically then store this instance. Based on this tabstrip intances
use the GET_TABS of cl_wd_tabstrip class and use the SET_DATA method based on the tabs you got.
Regards,
Lekha. -
Hi,
What's the difference between REUSE_ALV_GRID_DISPLAY and REUSE_ALV_GRID_DISPLAY_LVC?
Thx.
AndySimilar post...
Link:diffrence -
Change of count on the header on filtering the ALV
Hi Gurus!
I have this ALV report which gives the sales order report, in the output right on the top the report shows the count of all the distinct sales order displayed when the report is run based ona selection criteria. Is it possible to show the total count of teh sales order in the report to change and show teh number of distinct sales doc when we use filter on teh report. Suppose if we run the report based on a particular selection criteria and it gives a count of 30 . In the output if we put filter on a particular column and the report shows fewer lines , which will reduce the number of sales doc, is it possible to show this number which for eg will be say 20 , is it possible to show the number 20 after filetr on ALV instead of that 30 remainiung constant. I am wanting the report to show the change in count of distinct sales doc when I put filter on any columnh.
report zsales_orders message-id zsd no standard page heading.
* For ALV usage
type-pools: slis.
data: gs_layout type slis_layout_alv,
ta_events type slis_t_event_exit,
tp_event type slis_event_exit,
tp_print type slis_print_alv,
gt_sort type slis_t_sortinfo_alv,
gt_events type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv with header line,
repid type syrepid, " ABAP Program.
gt_list_top_of_page type slis_t_listheader, " Top of page text.
gs_list_top_of_page type slis_listheader,
alv_variant type disvariant. " Customize Disp. Variant
data: w_field type slis_fieldcat_alv.
data: count type i.
data: count1 type i.
tables: vbak, vbap, vbpa, knvv.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
selection-screen begin of block one with frame title text-001.
parameters: p_vkorg type vkorg obligatory memory id vko,"DEVK906677
p_vtweg type vtweg obligatory default '01',
p_spart type spart obligatory default '01'.
select-options: s_vkbur for vbak-vkbur, " Sales Office "DEVK906677
s_kunnr for vbak-kunnr. " Sold-to customer number.
select-options: s_shipto for vbap-oid_ship, " Ship-to customer number.
s_billto for vbpa-kunnr, " bill-to from S.O. header.
s_load for vbpa-kunnr, " Load confirmation contact.
s_truck for vbap-oid_extbol. " Trucking ticket number.
select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
select-options: s_lgort for vbap-lgort. " Storage location.
select-options: s_matnr for vbap-matnr. " Material number.
select-options: s_konda for knvv-konda. " price group
selection-screen skip 1.
select-options: s_vdatu for vbak-vdatu default sy-datum.
selection-screen end of block one.
* ALV display layout
selection-screen begin of block layout with frame title text-003.
parameters: pa_vari type slis_vari default ' '. " Display variant.
selection-screen end of block layout.
selection-screen begin of block two with frame title text-028.
selection-screen comment: /1(79) text-029.
selection-screen comment: /1(79) text-030.
selection-screen comment: /1(79) text-031.
selection-screen comment: /1(79) text-032.
selection-screen comment: /1(79) text-033.
selection-screen comment: /1(79) text-034.
selection-screen comment: /1(79) text-035.
selection-screen comment: /1(79) text-036.
selection-screen end of block two.
* Data Definitions *
* Storing Extracted Info.
types: begin of t_extract,
vbeln type vbeln_va, " Sales order number.
augru type augru, " order reason
vdatu type edatu_vbak, " Requested delivery date.
kunnr type kunag, " Sold-to customer number.
soldto_name type name1_gp, " Sold-to name.
posnr type posnr_va, " Item number.
matnr type matnr, " Material number.
vrkme type vrkme, " Sales UoM.
mseh3 type mseh3, " UoM text.
netwr type netwr_ap, " Net value of the order item.
kwmeng type p length 13 decimals 1, " Quantity.
werks type werks_d, " Plant.
lgort type lgort_d, " Storage location.
oid_extbol type oid_extbol, " External BOL or truck ticker header.
maktx type maktx, " Material description.
oid_ship type kunwe, " Ship-to customer number.
shipto_name type name1_gp, " Ship-to name.
billto type kunre, " Bill-to customer number.
billto_name type name1_gp, " Bill-to name.
load_contact type kunnr, " Load confirmation contact.
load_name type name1_gp, " Load confirmation contact name.
truck type kunnr, " Truck company number.
truck_name type name1_gp, " Truck company name.
bstkd type bstkd, " PO number.
ihrez type ihrez, " AFE number per the contract/sales order.
delivery type vbeln_vl, " Delivery number.
posnr_vl type posnr_vl, " Delivery item number.
bill_vbeln type vbeln_vf, " Invoice number.
bill_posnr type posnr_vf, " Invoice item number.
bill_netwr type netwr_fp, " Invoice net value.
statu type stats, " Document status.
auart type auart, " order type
vkorg type vkorg, " sales org.
vtweg type vtweg, " distrbtn channel
spart type spart, " division
vkbur like vbak-vkbur, " Sales Office DEVK906677
konda type konda, " price group
tdline type tdline, " text for customer account reference
count type i,
end of t_extract.
data : it_extract type table of t_extract with header line,
it_extract2 type table of t_extract with header line.
data: it_text type table of tline with header line.
data: w_index type sy-index,
w_tdname type tdobname.
constants: c_minus1 type netwr_ap value '1.00-'.
*RANGES: r_auart FOR vbak-auart.
data: r_auart type range of t_extract-auart,
r_auart_line like line of r_auart.
* initialization
initialization.
tp_event-ucomm = '&ILT'. " Filter event.
tp_event-after = 'X'.
append tp_event to ta_events.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
perform set_fieldcat.
perform alv_eventtab_build using:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* changed to exclude following order types
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZEQ'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* credit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* debit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRD'.
clear r_auart_line-high.
append r_auart_line to r_auart.
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZDR'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Industry sales order correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZSOC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield FF correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCF'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield WP correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCW'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Dropdown list for all created ALV layouts, global or user-specific
at selection-screen on value-request for pa_vari.
perform alv_variant_f4 changing pa_vari.
* Main BODY of processing logic
start-of-selection.
perform extract_data.
end-of-selection.
if not it_extract[] is initial.
* Build headings for report.
perform build_top_of_page using gt_list_top_of_page[].
perform call_alv.
endif.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
form extract_data.
clear: it_extract. refresh: it_extract.
* orders
select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
into corresponding fields of table it_extract
from vbak inner join vbap
on vbak~mandt = vbap~mandt
and vbak~vbeln = vbap~vbeln where
vbak~auart not in r_auart and
vbak~vkorg eq p_vkorg and
vbak~vtweg eq p_vtweg and
vbak~spart eq p_spart and
vbak~vkbur in s_vkbur and "DEVK906677
vbak~vdatu in s_vdatu and
vbak~kunnr in s_kunnr and
vbap~matnr in s_matnr and
vbap~werks in s_werks and
vbap~lgort in s_lgort and
vbap~oid_extbol in s_truck and
vbap~oid_ship in s_shipto.
if sy-subrc <> 0.
message i000 with text-002 ' ' ' ' ' '.
endif.
sort it_extract by vbeln.
check sy-subrc = 0.
loop at it_extract.
* Retrieve and select by load confirmation contacts from header
select single kunnr from vbpa into it_extract-load_contact
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'ZB'.
if it_extract-load_contact in s_load.
it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
else.
delete it_extract.
continue.
endif.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
select single kunnr from vbpa into it_extract-billto
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'RE'.
if sy-subrc = 0.
if s_billto is initial.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
if it_extract-billto in s_billto.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
delete it_extract.
continue.
endif.
endif.
else.
* Newalta - always has bill-to, following will not occur but included
* as good programming practice.
it_extract-billto_name = it_extract-billto.
endif.
* Retrieve and select by price group of sold-to
select single konda from knvv into it_extract-konda
where kunnr = it_extract-kunnr
and vkorg = it_extract-vkorg
and vtweg = it_extract-vtweg
and spart = it_extract-spart.
if sy-subrc = 0.
if not ( it_extract-konda in s_konda ).
delete it_extract.
continue.
endif.
endif.
* Retrieve trucking company customer
select single kunnr from vbpa into it_extract-truck where
vbeln = it_extract-vbeln and
posnr = '000000' and
parvw = 'ZT'.
if sy-subrc = 0.
it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
endif.
* Retrieve sold-to name
it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
* Retrieve ship-to name
it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
* lookup P.O.
select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
where vbeln = it_extract-vbeln
and posnr = '000000'.
* Retreive the material description.
it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
* cosmetic change of material number, donot display leading zeros.
shift it_extract-matnr left deleting leading '0'.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
w_tdname = it_extract-vbeln.
* read customer account reference which is under 'text'
call function 'READ_TEXT'
exporting
client = sy-mandt
id = 'Z010'
language = sy-langu
name = w_tdname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = it_text
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc = 0.
read table it_text index 1.
if sy-subrc = 0.
it_extract-tdline = it_text-tdline.
else.
clear it_extract-tdline.
endif.
else.
clear it_extract-tdline.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* Get the delivery item.
call method zcl_vbap=>get_delivery
exporting
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
importing
etp_vbeln = it_extract-delivery
etp_posnr = it_extract-posnr_vl.
if it_extract-delivery is not initial.
perform process_deliveries.
else.
perform invoice_process.
endif.
it_extract-count = 1 .
move-corresponding it_extract to it_extract2.
append it_extract2.
at new vbeln.
count1 = count1 + 1.
endat.
endloop.
endform. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
form set_fieldcat .
clear w_field.
clear t_fieldcat. refresh t_fieldcat.
w_field-col_pos = 1 .
w_field-fieldname = 'VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Document.Nbr'.
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 2 .
w_field-fieldname = 'POSNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Item'(023).
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 3 .
w_field-fieldname = 'VDATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Req. Del. Date'(005).
append w_field to t_fieldcat.
w_field-col_pos = 4. "DEVK909658
w_field-fieldname = 'KUNNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to.'(038).
append w_field to t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'SOLDTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to'(006).
append w_field to t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'MATNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Material'(007).
append w_field to t_fieldcat.
w_field-col_pos = 7 .
w_field-fieldname = 'KWMENG'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Quantity'(008).
append w_field to t_fieldcat.
w_field-col_pos = 8.
w_field-fieldname = 'MSEH3'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'UOM'(009).
append w_field to t_fieldcat.
w_field-col_pos = 9 .
w_field-fieldname = 'BILL_VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Invoice #'(010).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 10 .
w_field-fieldname = 'BILL_NETWR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Values'(011).
append w_field to t_fieldcat.
w_field-col_pos = 11.
w_field-fieldname = 'WERKS'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Plant'(012).
append w_field to t_fieldcat.
w_field-col_pos = 12.
w_field-fieldname = 'LGORT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Storage Loc'(013).
append w_field to t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'MAKTX'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Description'(014).
append w_field to t_fieldcat.
w_field-col_pos = 14. "DEVK909658
w_field-fieldname = 'OID_SHIP'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to.'(039).
append w_field to t_fieldcat.
w_field-col_pos = 15 .
w_field-fieldname = 'SHIPTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to'(015).
append w_field to t_fieldcat.
w_field-col_pos = 16. "DEVK909658
w_field-fieldname = 'BILLTO'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to .'(040).
append w_field to t_fieldcat.
w_field-col_pos = 17 .
w_field-fieldname = 'BILLTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to'(016).
append w_field to t_fieldcat.
w_field-col_pos = 18 .
w_field-fieldname = 'LOAD_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Load Contact'(017).
append w_field to t_fieldcat.
w_field-col_pos = 19 .
w_field-fieldname = 'TRUCK_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Comp.'(018).
append w_field to t_fieldcat.
w_field-col_pos = 20 .
w_field-fieldname = 'BSTKD'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'P.O.'(019).
append w_field to t_fieldcat.
w_field-col_pos = 21 .
w_field-fieldname = 'IHREZ'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'AFE Nbr'(020).
append w_field to t_fieldcat.
w_field-col_pos = 22 .
w_field-fieldname = 'OID_EXTBOL'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Ticket'(021).
append w_field to t_fieldcat.
w_field-col_pos = 23.
w_field-fieldname = 'STATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Status'(022).
append w_field to t_fieldcat.
w_field-col_pos = 24.
w_field-fieldname = 'AUGRU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ord.Reason'(024).
append w_field to t_fieldcat.
w_field-col_pos = 25.
w_field-fieldname = 'TDLINE'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'cstmr.acct.ref.'(027).
append w_field to t_fieldcat.
w_field-col_pos = 26 . "DEVK906678
w_field-fieldname = 'VKBUR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sales Office'(037).
append w_field to t_fieldcat.
w_field-col_pos = 27. "DEVK909658
w_field-fieldname = 'COUNT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Count'(041).
w_field-do_sum = 'X'.
append w_field to t_fieldcat.
endform. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
form call_alv .
sort it_extract by lgort vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
it_event_exit = ta_events[]
is_print = tp_print
tables
t_outtab = it_extract2
exceptions
program_error = 1
others = 2.
if sy-subrc ne 0.
message w000 with text-004 ' ' ' ' ' '.
endif.
endform. " CALL_ALV
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
form build_top_of_page using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
data: w_selections(40) type c,
w_date_from(10) type c,
w_date_to(10) type c.
write: s_vdatu-low to w_date_from dd/mm/yyyy.
if s_vdatu-high is not initial.
write: s_vdatu-high to w_date_to dd/mm/yyyy.
clear w_selections.
concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total Number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
else.
clear w_date_to.
concatenate 'Del.Req.Date: ' w_date_from
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
endif.
endform. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
form alv_eventtab_build using u_name type slis_alv_event-name
u_form type slis_alv_event-form
alv_lt_events type slis_t_event.
data: ls_event type slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
append ls_event to alv_lt_events.
endform. " alv_eventtab_build
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
endform. " TOP_OF_PAGE
*& Form process_deliveries
* Process the delivery related records.
form process_deliveries .
data:
ltp_date type wadat_ist, " Goods movement date.
ltp_vbtyp type vbtyp_n,
ltp_mtart type mtart, " Material type.
w_lfimg type lfimg, " Actual quantity delivered (in sales units).
w_vrkme type vrkme. " Sales unit of measure.
* Read delivery quantity and uom.
select single lfimg vrkme into (w_lfimg, w_vrkme)
from lips where
vbeln = it_extract-delivery and
posnr = it_extract-posnr_vl.
* these fields have values from vbap. override with lips values
if sy-subrc = 0.
it_extract-kwmeng = w_lfimg.
it_extract-vrkme = w_vrkme.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
endif.
* Determine STATUS by reading 'service confirmation', R (goods movemt)
* it is possible to have multiple 'service confirmation' records for
* one item. ie. delivery 80010390 in PRD.
* As long as there is at least one 'service confirmation' record,
* status is considered 'complete'.
* Validate the created on date of the goods movement or service confirmation.
ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
* ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
* itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
call method zcl_lips=>get_goods_mvt_info
exporting
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
itp_mtart = ltp_mtart
importing
rtp_date = ltp_date
rtp_vbtyp = ltp_vbtyp.
* 'h' is cancel goods issue
if ltp_vbtyp = 'h'.
it_extract-statu = 'Incomplete'(025).
else.
if ltp_date is not initial.
it_extract-statu = 'COMPLETE'(026).
endif.
endif.
* Retrieve the invoice/billing document item.
call method zcl_lips=>get_invoice
exporting
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
importing
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
endif.
endform. " process_deliveries
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ltp_vbeln type vbeln. " Sales document number.
case r_ucomm.
when '&IC1'.
if ( rs_selfield-fieldname = 'VBELN'
or rs_selfield-fieldname = 'BILL_VBELN' )
and rs_selfield-value is not initial. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
endif.
when '&ILT'.
data:
lta_filt type slis_t_filtered_entries.
break rdrury.
call function 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
importing
* es_layout = gs_layout
* et_fieldcat = t_fieldcat[]
* et_sort = gt_sort[]
* ES_LAYOUT =
* ET_FIELDCAT =
* ET_SORT =
* ET_FILTER =
* ES_LIST_SCROLL =
* ES_VARIANT =
* E_WIDTH =
* ET_MARKED_COLUMNS =
et_filtered_entries = lta_filt
* ET_FILTERED_ENTRIES_HEADER =
* ET_FILTERED_ENTRIES_ITEM = lta_filt
* TABLES
* et_outtab =
* ET_OUTTAB_HEADER =
* et_outtab_item =
* ET_COLLECT00 =
* ET_COLLECT01 =
* ET_COLLECT02 =
* ET_COLLECT03 =
* ET_COLLECT04 =
* ET_COLLECT05 =
* ET_COLLECT06 =
* ET_COLLECT07 =
* ET_COLLECT08 =
* ET_COLLECT09 =
exceptions
no_infos = 1
program_error = 2
endcase.
endform. "user_command
*& Form invoice_process
* Process for orders without deliveries. *
form invoice_process .
* Translate unit of measure.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
* Retrieve the invoice/billing document item.
call method zcl_vbap=>get_invoice
exporting
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
importing
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else. " If no Invoice, then status becomes 'incomplete'.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
it_extract-statu = 'Incomplete'(025).
endif.
endform. " invoice_process
*& Form alv_variant_f4
* Get the display variant.
* <--CTP_VARI Variant name
form alv_variant_f4 changing ctp_vari type slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = alv_variant
i_save = 'A'
importing
es_variant = alv_variant
exceptions
others = 1.
if sy-subrc = 0.
ctp_vari = alv_variant-variant.
endif.
endform. " alv_variant_f4I have used all the FM modules mentioned but I am not able to get the total of the sales doc on the top of the page to chnage when filtering of data is done . I just want to see this count of sales document (distict ) and to see it change as filtering is done , be it at any place in teh ALV , its not necessary that it has to be on the top of the ALV output. Could I get some inputs please. As you can see I used the below mentioned FM but on debugging I find the gt_stack is empty still.
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
FORM build_top_of_page USING e04_lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
DATA: w_selections(40) TYPE c,
w_date_from(10) TYPE c,
w_date_to(10) TYPE c.
WRITE: s_vdatu-low TO w_date_from DD/MM/YYYY.
IF s_vdatu-high IS NOT INITIAL.
WRITE: s_vdatu-high TO w_date_to DD/MM/YYYY.
CLEAR w_selections.
CONCATENATE 'Del.Req.Date: ' w_date_from 'To' w_date_to
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total Number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
ELSE.
CLEAR w_date_to.
CONCATENATE 'Del.Req.Date: ' w_date_from
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
ENDIF.
ENDFORM. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
FORM alv_eventtab_build USING u_name TYPE slis_alv_event-name
u_form TYPE slis_alv_event-form
alv_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
APPEND ls_event TO alv_lt_events.
ENDFORM. " alv_eventtab_build
* FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
Data:lt_FILTERED_ENTRIES type SLIS_T_FILTERED_ENTRIES,
wa_filter like line of lt_FILTERED_ENTRIES.
data: count2 type i.
data: it_fieldcat type slis_t_fieldcat_alv with header line.
CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
IMPORTING
ET_FILTERED_ENTRIES = lt_FILTERED_ENTRIES
EXCEPTIONS
NO_INFOS = 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.
MESSAGE i000 WITH count1 .
ENDIF.
loop at lt_FILTERED_ENTRIES into wa_filter.
* if sy-tabix <> 0.
if sy-subrc = 0 .
count2 = count2 + 1.
*count3 = count1 - count2 .
* write:/ 'Total number of Sales Documents =', count3 .
endif.
endloop.
ENDFORM. " TOP_OF_PAGE
I tried using it at user-command level too but it dosent help.
Thanks -
In webdynpro for ABAP alv table issue
hello gurus,
i am new for webdynpro for ABAP.i strucked at one point at designing time.anybody could you suggest me on this.
thanks in advance.
let me explain my scenario first.
in my webdynpro for ABAP developement i have one alv table having ten fields.i am featching the data for eight fields from one Ztabale and updating , for rest of two fields we need to fill after displaying output using the respective F4 help. Right now these two fields are in input editable mode.now i am getting the values successfully from F4 help and at the same time it is allowing MANUAL ENTRIES also but as per my requirement it should not allow any manual entries . for this i have made these two fields are in readonly mode as like as rest of fields to avoid the MANUAL ENTRIES but at this time i didnot get any F4 helpfor those two fields.
so how can i achive my goal in this thing could any one suggest me.
my final conclusion is we need to get only F4 help values into those two fields . it should not allow any manual values at any point of time.
best regards,
babuya hi harshit,
my self also used same code in my action part . here i have one table with four fields carrid , connid , fldate , price.
for carrid i have created freely programmed search help.but if it is in display mode there is no F4 help in enable mode.
in context for attribute carrid
DATA lo_nd_flight TYPE REF TO if_wd_context_node.
DATA lo_el_flight TYPE REF TO if_wd_context_element.
DATA ls_flight TYPE wd_this->element_flight.
DATA lt_flight TYPE wd_this->elements_flight.
navigate from <CONTEXT> to <FLIGHT> via lead selection
lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).
select connid fldate price from sflight into CORRESPONDING FIELDS OF TABLE
lt_flight UP TO 20 ROWS.
@TODO handle non existant child
IF lo_nd_flight IS INITIAL.
ENDIF.
get element via lead selection
lo_el_flight = lo_nd_flight->get_element( ).
alternative access via index
lo_el_flight = lo_nd_flight->get_element( index = 1 ).
@TODO handle not set lead selection
IF lo_el_flight IS INITIAL.
ENDIF.
get all declared attributes
lo_el_flight->get_static_attributes(
IMPORTING
static_attributes = ls_flight ).
CALL METHOD lo_nd_flight->bind_table
EXPORTING
new_items = lt_flight
set_initial_elements = ABAP_TRUE
index =
DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage.
DATA: lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.
instantiate ALV component usage if necessary
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
pass reference to data node to instance of ALV usage
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_interfacecontroller->set_data( r_node_data = lo_nd_flight ).
Configure ALV
DATA lr_config TYPE REF TO cl_salv_wd_config_table.
lr_config = lo_interfacecontroller->get_model( ).
**declerations
DATA: lt_columns TYPE salv_wd_t_column_ref,
ls_columns TYPE salv_wd_s_column_ref,
lr_input TYPE REF TO cl_salv_wd_uie_input_field,
name TYPE string,
lt_node_info TYPE wdr_context_attr_info_map,
ls_node_info TYPE wdr_context_attribute_info,
lv_tabix TYPE sy-tabix,
lr_info TYPE REF TO if_wd_context_node_info.
TYPES: BEGIN OF ty_name,
name TYPE string,
END OF ty_name.
DATA: lt_name TYPE TABLE OF ty_name,
ls_name TYPE ty_name.
**for getting node info
*Get the context node information
lr_info = lo_nd_flight->get_node_info( ).
lt_node_info = lr_info->get_attributes( ).
LOOP AT lt_node_info INTO ls_node_info.
CASE ls_node_info-name.
WHEN 'CARRID'.
ls_name-name = ls_node_info-name.
APPEND ls_name TO lt_name.
WHEN 'REGIONALOFFICER'.
ls_name-name = ls_node_info-name.
APPEND ls_name TO lt_name.
WHEN 'INSPECTORNAME'.
ls_name-name = ls_node_info-name.
APPEND ls_name TO lt_name.
ENDCASE.
ENDLOOP.
*Logic for Table Horizontal Scrolling
lr_config->if_salv_wd_table_settings~set_visible_row_count( 13 ).
" lr_config->if_salv_wd_table_settings~set_width( '1085' ).
lr_config->if_salv_wd_table_settings~set_width( '100%' ).
lr_config->if_salv_wd_table_settings~set_scrollable_col_count( 8 ).
" lr_config->if_salv_wd_table_settings~set_fixed_table_layout( abap_true ).
lr_config->if_salv_wd_table_settings~set_first_visible_scroll_col( 'CARRID' ).
lr_config->if_salv_wd_table_settings~set_cell_action_event_enabled( abap_true ).
Set the table editable .
DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= lr_config.
lr_table_settings->set_read_only( abap_false ).
lr_table_settings->set_read_only( abap_true ).
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column.
DATA: lt_string TYPE STANDARD TABLE OF string,
ld_string TYPE string,
ld_int TYPE i,
lv_index TYPE i.
Make few columns editable and attach inputfield, if permitted.
DATA lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CLEAR lt_string.
APPEND 'CARRID' TO lt_string.
LOOP AT lt_string INTO ld_string.
lr_column_settings ?= lr_config.
lr_column = lr_column_settings->get_column( ld_string ).
CREATE OBJECT lr_input_field
EXPORTING
value_fieldname = ld_string.
lr_input_field->set_read_only( abap_true ).
lr_column->set_cell_editor( lr_input_field ).
ENDLOOP.
CLEAR lt_string. -
Hi Friend ,
I ve a problem with the ALV output. Actually i am getting all the value in the internal table and then i am binding the table with the node . But i wonder why the output is not coming in the ALV table only the blank table is coming .
Regards,
SatyaHi
first u instantiate the alv component with the use of wizard.
then u call the method "GET_MODEL".
Then u call the method "SET_DATA" and set the alv table with the node in which u have ur data.
check this code.....
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
*declaration of alv usage
*declare config model
DATA lo_config_model_value TYPE REF TO cl_salv_wd_config_table.
lo_cmp_usage = wd_this->wd_cpuse_alv_requi_list( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
lo_interfacecontroller = wd_this->wd_cpifc_alv_requi_list( ).
lo_config_model_value = lo_interfacecontroller->get_model( ).
lo_interfacecontroller->set_data(
r_node_data = lo_nd_req_list
here lo_nd_req_list is the name of my node.
Regards
chythanya -
Rename alv header text in webdynpro abap
Hi ,
I have created two attribute PART_NUMBER and TERM_CODE in context level with type CHAR10.
AND in ALV header PART_NUMBER and TERM_CODE is displaying, which is coming from context level.
i want to rename the header of ALV to PARTNUMBER and TERMCODE.
could any one send me the sampls code or any solution?
Thanks
RaksharFirst get access to the ALV Model object for your ALV usage:
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
Then access the column you want to change the header on. In addition to setting the text of the header of the column, you must also force off the data dictionary binding for the field property text.
data l_column type ref to cl_salv_wd_column.
l_column = l_table->if_salv_wd_column_settings~get_column( 'POSTING_DATE' ).
data l_header type ref to cl_salv_wd_column_header.
l_header = l_column->get_header( ).
l_header->set_prop_ddic_binding_field(
property = if_salv_wd_c_ddic_binding=>bind_prop_text
value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).
l_header->set_text( `Posting Date` ). -
Re: creating check boxes in ALV grid using web dynpro
Hi Techies,
I need to have a check box column in alv grid, and it should allow me to select the check box and the selected row has to be updated in the database.
Kindly assist me with the steps to handle the above mentioned scenario
Thanks in advance.Now to first make the last column of my ALV as a checkbox:
method BUILD_ALV .
data: l_ref_cmp_usage type ref to if_wd_component_usage.
" Instantiate the ALV usage
l_ref_cmp_usage = wd_This->wd_CpUse_My_Alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
" Get reference to the model
DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_My_Alv( ).
data: lr_config type ref to Cl_Salv_Wd_Config_Table.
lr_config = l_ref_INTERFACECONTROLLER->Get_Model( ).
|" Set read only mode to false (and display edit toolbar)
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= lr_config.
lr_table_settings->set_read_only( abap_false ).
data: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
lr_checkbox1 TYPE REF TO cl_salv_wd_uie_checkbox,
lr_checkbox2 TYPE REF TO cl_salv_wd_uie_checkbox.
FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.
" Embed the UI elements within the ALV
lr_column_settings ?= lr_config.
lt_columns = lr_column_settings->get_columns( ).
" Embed an checkbox within the column APPROVE
LOOP AT lt_columns ASSIGNING <fs_column>.
CASE <fs_column>-id.
WHEN 'APPROVE'.
CREATE OBJECT lr_checkbox1
EXPORTING
checked_fieldname = <fs_column>-id.
<fs_column>-r_column->set_cell_editor( lr_checkbox1 ).
FREE lr_checkbox1.
ENDCASE.
ENDLOOP.
ENDMETHOD. "BUILD_ALV -
hi all,
have a requirement where I have to create a webdynpro for ABAP table for new row/rows entry, delete row/rows and update row/rows data. This is something like table control in normal ABAP.
how can I achieve this? Is there any such feature in ALV component?
Any code sample will be really helpfull.
Please help!
Thanks
RaviHi Ravi Raju
In alv you can edit, add and append rows. First you have to initialize the ALV usage in WDDOINIT method of the view in which SALV_WD_TABLE is added as component usage. Then you have to disable the read only attribute of the ALV. If you set the property to abap_false, then append, insert, delete buttons will be added automaticaly. Then you can set the appropriate cell editor for each column.
initialize ALV Component
l_ref_cmp_usage = wd_This->wd_CpUse_Alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
Get model data
DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_Alv( ).
data:
l_VALUE type ref to Cl_Salv_Wd_Config_Table.
l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model( ).
set read only mode to false (and display edit toolbar)
data: lr_table_settings type ref to
if_salv_wd_table_settings.
lr_table_settings ?= l_value.
lr_table_settings->set_read_only( abap_false ).
set cell editor for input fields (~make colum editable)
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column_settings ?= l_value.
lr_column = lr_column_settings->get_column( 'SAMPLE' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname =
'SAMPLE'.
lr_column->set_cell_editor( lr_input_field ).
Hope it helps ;>)
Regards
Rakesh. -
Hi!
I would like to get the count of rows in my ALV report . How to get the count of the rows ? Can anyone guide me in getting it dome please.
ThanksHi Gaddemmedi!
I am attaching the report as you had asked for. I have added the things you asked me to do and now I am getting the count on the top of the page. The problem is that though it shows me the count of the lines from the LAV report on top but when I try to filter the records in the report that count first of all dosent change and remain the same as the initial number of record though after filtering records reduce and over that the count lines keep on increasing I mean the count is shown in repeated lines afet lines. Kindly help please.
Thanks
*& Report ZSD_BILLING_HDR_TEXT_sum *
*& billing doc. and associated header text report *
*& CHANGE LOG *
*& jpoon 2007.08.03 Change request: DEVK905095 *
*& Move request: SD_1451_01 Requestor: Mona Fox *
*& FP14134 - original code. *
REPORT zsd_billing_hdr_text_sum MESSAGE-ID zsd NO STANDARD PAGE HEADING.
* For ALV usage
TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
tp_print TYPE slis_print_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_events TYPE slis_t_event,
t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
repid TYPE syrepid, " ABAP Program.
gt_list_top_of_page TYPE slis_t_listheader, " Top of page text.
alv_variant TYPE disvariant," Customize Disp. Variant
w_event type slis_alv_event.
DATA: w_field TYPE slis_fieldcat_alv.
TABLES: vbrk, vbrp, vbpa.
DATA SLIS_EV_AFTER_OUTPUT.
data: gs_list_top_of_page type slis_listheader.
*data: gt_list_top_of_page type slis_t_listheader.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbrk-vbeln, " billing doc.
s_kunnr FOR vbpa-kunnr, " bill-to customer number.
s_werks FOR vbrp-werks, " line item plant.
s_fkdat FOR vbrk-fkdat, " billing date.
s_fkart FOR vbrk-fkart, " billing type.
s_vkorg FOR vbrk-vkorg. " sales org.
PARAMETERS: p_hold AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK one.
* ALV display layout
SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME TITLE text-003.
PARAMETERS: pa_vari TYPE slis_vari DEFAULT ' '. " Display variant.
SELECTION-SCREEN END OF BLOCK layout.
* Data Definitions *
* Storing Extracted Info.
TYPES: BEGIN OF t_extract,
vbeln TYPE vbeln_vf, " Sales order number.
posnr TYPE posnr, " line item
fkart TYPE fkart, " billing type.
vtext TYPE BEZEI20, " billing type description.
fkdat TYPE fkdat, " billing date.
werks TYPE werks_d, " line item plant.
werks_name1 TYPE name1, " plant description.
kunnr TYPE kunnr, " bill-to customer.
kunnr_name1 TYPE name1_gp, " bill-to description.
netwr TYPE netwr, " net value,invoice total $
zzflag TYPE boolean, " hold indicator
zzreason TYPE char30, " header text2 (reason)
zzuser TYPE ernam, " last changed by
zz_changed_date TYPE dats, " last changed date
zz_changed_time TYPE tims, " last changed time
END OF t_extract.
DATA: it_extract TYPE TABLE OF t_extract WITH HEADER LINE,
it_extract2 TYPE TABLE OF t_extract WITH HEADER LINE.
DATA: it_text TYPE TABLE OF tline WITH HEADER LINE.
DATA: wa_thead type thead.
DATA: w_tdname type TDOBNAME.
DATA: L_COUNT TYPE I.
* initialization
INITIALIZATION.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
PERFORM set_fieldcat.
PERFORM alv_eventtab_build USING:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* Dropdown list for all created ALV layouts, global or user-specific
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
PERFORM alv_variant_f4 CHANGING pa_vari.
* Main BODY of processing logic
START-OF-SELECTION.
IF s_vbeln IS INITIAL
AND s_kunnr IS INITIAL
AND s_werks IS INITIAL
AND s_fkdat IS INITIAL
AND s_fkart IS INITIAL
AND s_vkorg IS INITIAL.
MESSAGE i000 WITH text-037 ' ' ' ' ' '.
ELSE.
PERFORM extract_data.
ENDIF.
END-OF-SELECTION.
IF it_extract2[] IS INITIAL.
MESSAGE i000 WITH text-002 ' ' ' ' ' '.
ELSE.
* Build headings for report.
* PERFORM build_top_of_page USING gt_list_top_of_page[].
* describe table it_extract2 lines l_count.
*write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
PERFORM call_alv.
*write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
ENDIF.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
FORM extract_data.
CLEAR: it_extract. REFRESH: it_extract.
* read and select billing documents
IF p_hold IS INITIAL.
SELECT vbrk~vbeln vbrk~fkart vbrk~fkdat vbrk~netwr
vbrk~zzflag vbrk~zzreason vbrk~zzuser
vbrk~zz_changed_date vbrk~zz_changed_time
vbrp~posnr vbrp~werks
INTO CORRESPONDING FIELDS OF TABLE it_extract
FROM vbrk INNER JOIN vbrp ON
vbrk~vbeln = vbrp~vbeln
WHERE vbrk~vbeln IN s_vbeln
AND vbrk~fkart IN s_fkart
AND vbrk~fkdat IN s_fkdat
AND vbrk~vkorg IN s_vkorg
AND vbrk~fksto NE 'X'
AND vbrp~werks IN s_werks.
ELSE.
* read 'held' documents only as per selection
SELECT vbrk~vbeln vbrk~fkart vbrk~fkdat vbrk~netwr
vbrk~zzflag vbrk~zzreason vbrk~zzuser
vbrk~zz_changed_date vbrk~zz_changed_time
vbrp~posnr vbrp~werks
INTO CORRESPONDING FIELDS OF TABLE it_extract
FROM vbrk INNER JOIN vbrp ON
vbrk~vbeln = vbrp~vbeln
WHERE vbrk~vbeln IN s_vbeln
AND vbrk~fkart IN s_fkart
AND vbrk~fkdat IN s_fkdat
AND vbrk~vkorg IN s_vkorg
AND vbrk~fksto NE 'X'
AND vbrk~zzflag = 'X'
AND vbrp~werks IN s_werks.
ENDIF.
IF sy-subrc <> 0.
MESSAGE i000 WITH text-002 ' ' ' ' ' '.
ENDIF.
CHECK sy-subrc = 0.
* only need first line item for this report.
SORT it_extract BY vbeln posnr.
DELETE ADJACENT DUPLICATES FROM it_extract COMPARING vbeln.
LOOP AT it_extract.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
SELECT SINGLE kunnr FROM vbpa INTO it_extract-kunnr
WHERE vbeln = it_extract-vbeln
AND posnr = '000000'
AND parvw = 'RE'.
IF it_extract-kunnr IN s_kunnr.
it_extract-kunnr_name1 = zcl_kna1=>get_name1( it_extract-kunnr ).
ELSE.
DELETE it_extract.
CONTINUE.
ENDIF.
* lookup billing type description
SELECT SINGLE vtext FROM tvfkt
INTO it_extract-vtext
WHERE spras = sy-langu
AND fkart = it_extract-fkart.
IF sy-subrc <> 0.
clear it_extract-vtext.
ENDIF.
* lookup plant description
SELECT SINGLE name1 FROM t001w
INTO it_extract-werks_name1
WHERE werks = it_extract-werks.
IF sy-subrc <> 0.
clear it_extract-werks_name1.
ENDIF.
MOVE-CORRESPONDING it_extract TO it_extract2.
APPEND it_extract2.
ENDLOOP.
describe table it_extract2 lines l_count.
ENDFORM. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
FORM set_fieldcat .
*CLEAR W_EVENT.
*W_EVENT-FORM = SLIS_EV_AFTER_OUTPUT.
*W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.
*APPEND W_EVENT TO GT_EVENTS.
CLEAR w_field.
CLEAR t_fieldcat. REFRESH t_fieldcat.
w_field-col_pos = 1.
w_field-fieldname = 'ZZFLAG'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Hold Printing'(005).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 2.
w_field-fieldname = 'ZZREASON'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Reason'(036).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 3 .
w_field-fieldname = 'VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Billing Doc'(028).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
APPEND w_field TO t_fieldcat.
CLEAR w_field.
w_field-col_pos = 4 .
w_field-fieldname = 'VTEXT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Type Description'(030).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'FKDAT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Billing Date'(031).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'WERKS'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Plant'(012).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 7 .
w_field-fieldname = 'WERKS_NAME1'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Plant Description'(032).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 8.
w_field-fieldname = 'KUNNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to Customer'(033).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 9 .
w_field-fieldname = 'KUNNR_NAME1'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to Description'(034).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
APPEND w_field TO t_fieldcat.
CLEAR w_field.
w_field-col_pos = 10 .
w_field-fieldname = 'NETWR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Invoice Amount'(035).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 11 .
w_field-fieldname = 'ZZUSER'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Changed By'.
APPEND w_field TO t_fieldcat.
w_field-col_pos = 12 .
w_field-fieldname = 'ZZ_CHANGED_DATE'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Last Changed Date'(006).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'ZZ_CHANGED_TIME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Last Changed Time'(007).
APPEND w_field TO t_fieldcat.
* W_event-NAME = slis_ev_end_of_list.
* W_event-FORM = 'END_OF_LIST'.
* APPEND W_event TO GT_EVENTS.
* CLEAR W_event .
* w_field-col_pos = 14 .
* w_field-fieldname = 'COUNT'.
* w_field-tabname = 'IT_EXTRACT2'.
* w_field-seltext_l = 'COUNT'.
* APPEND w_field TO t_fieldcat.
ENDFORM. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
FORM call_alv .
SORT it_extract BY vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
is_print = tp_print
TABLES
t_outtab = it_extract2
EXCEPTIONS
program_error = 1
OTHERS = 2.
write :/ 'TOTAL NO OF ENTRIES', SY-VLINE, 32 L_COUNT.
IF sy-subrc NE 0.
MESSAGE w000 WITH text-004 ' ' ' ' ' '.
ENDIF.
ENDFORM. " CALL_ALV
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
FORM alv_eventtab_build USING u_name TYPE slis_alv_event-name
u_form TYPE slis_alv_event-form
alv_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
APPEND ls_event TO alv_lt_events.
ENDFORM. " alv_eventtab_build
* FORM TOP_OF_PAGE *
FORM top_of_page.
*gs_list_top_of_page-type = 'H'.
GS_LIST_TOP_OF_PAGE-INFO = L_COUNT.
APPEND GS_LIST_TOP_OF_PAGE TO GT_LIST_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
ENDFORM. " TOP_OF_PAGE
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: ltp_vbeln TYPE vbeln. " Sales document number.
CASE r_ucomm.
WHEN '&IC1'.
IF ( rs_selfield-fieldname = 'VBELN'
OR rs_selfield-fieldname = 'BILL_VBELN' )
AND rs_selfield-value IS NOT INITIAL. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
ENDIF.
ENDCASE.
ENDFORM. "user_command
*& Form alv_v-ariant_f4
* Get the display variant.
* <--CTP_VARI Variant name
FORM alv_variant_f4 CHANGING ctp_vari TYPE slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = alv_variant
i_save = 'A'
IMPORTING
es_variant = alv_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
ctp_vari = alv_variant-variant.
ENDIF.
ENDFORM. " alv_variant_f4 -
Unable to make use of ALV table in a standard component.
Hi All,
I am enhancing a standard wd component. I want to make use of ALV table in my enhancement. I am able to add SALV_WD_TABLE in "Used components". But the same is not getting reflected in "Component Usages".
Can anybody guide regarding this?
Regards,
Yugesh AdalamHi yugesh,
Sorry, for me also it is not coming in Enh mode.
Refer this thread:
Regarding enhancement for ALV usage Need Help!
Ans by Thomas:
Re: Component Usage in Enhancement
For the ALV, you can always do the data mapping dynamically in code using the SET_DATA method of the ALV Component Interface -
Action (navigation) when click on Hyperlink field in ALV web dynpro
Hi - I had a question about Hyperlink in ALV web dynpro and it was answered in Link: [web dynpro abap ALV link to (hyperlink);
Now I need to click the Hyperlink field and navigate to another screen.
i.e. I have a Object ID (PR Number) when I click the PR number I need to open the PR Document also another case is at the item level if the PR has more than one item I'm showing the word "MULTIPLE" so if the user click on Multiple I need to show all the items (material) in another ALV table that I already create.
Thanks for your help!
Jason P-VHi,
As per my understanding, there are PR number and Material and other columns in the SAME ALV table right.
There is a ONCLICK event for ALV not for the VIEWCONTAINTERELEMENT.
In the View where you have the ALV as component usage under view's properties, you have ALV usage right.
Now, under the METHODS tab of the ALV, implement an event
Onclick EventHandler ONCLICK(press F4) of that ALV.
Now the Click event is implemented for that ALV. When ever you click on any column(Hyperlink) this gets called.
Here there are parameters that you need to use it. R_PARAM has both the index and the element.
Based on the COLUMN you can call the respective event.
The index that you have clicked i shown from r_param->index and you can also know ATTRIBUTE name(column name).
If attribute eq 'PRNUMBER'
*call the Purchase requistion transaction
elseif attribute eq 'MATNR'.
*call the popup for other ALV as component usage to display item details.
endif.
Refer this Article -
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8&overridelayout=true
Hope this is clear.
Regards,
Lekha.
Edited by: Lekha on Sep 26, 2009 12:57 PM -
Hello ,
I have a problem in the ALV usage in abap webdrn pro.
I have implemented the ALV by reusing the component SALV_WD_TABLE.
In the interface controller usage, i mapped the DATA node to
component context node, say, node1.
Node1 is has a reference to a structure from data ditionary, say Struc1.
and Stuc1 has some 20 elements.
But in the Node1 i mapped only 10 elements of the structure Struc1 as its attributes.
Now, when i map 'data' node to the Node1 from controller,
My ALV shows all teh 20 columns.
But i want only 10 of these columns to be displayed in the ALV.
Please let me know if.
I already know of referring to the ALV programmatically and hiding the columns.
But my question is taht when the Node1 has only few elements, shouldnt the alv also display the same number of coloumns..
Please let know if there is a way out here.
regards,
KiranHi,
if you want to hide a column named OBJID and OBJTYP then implement following coding
DATA:
lr_comp_alv TYPE REF TO if_wd_component_usage,
lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,
lr_config TYPE REF TO cl_salv_wd_config_table,
lr_column TYPE REF TO cl_salv_wd_column,
ls_column TYPE salv_wd_s_column_ref,
lt_columns TYPE salv_wd_t_column_ref.
data: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
*... ALV Component Usage
lr_comp_alv = wd_this->wd_cpuse_alv( ).
IF lr_comp_alv->has_active_component( ) IS INITIAL.
lr_comp_alv->create_component( ).
ENDIF.
lr_comp_if_alv = wd_this->wd_cpifc_alv( ).
*... Configure ALV
lr_config = lr_comp_if_alv->get_model( ).
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
lr_config->if_salv_wd_std_functions~set_edit_insert_row_allowed( ).
lr_config->if_salv_wd_std_functions~set_view_list_allowed( abap_false ).
lr_config->if_salv_wd_std_functions~set_export_allowed( abap_true ).
lt_columns = lr_config->if_salv_wd_column_settings~get_columns( ).
lr_column = lr_config->if_salv_wd_column_settings~get_column('OBJID' ).
*To hide particular coulmn
LOOP AT lt_columns INTO ls_column.
CASE ls_column-id.
when 'OBJID'.
ls_column-r_column->set_visible( value = '99' ).
when 'OBJTP'.
ls_column-r_column->set_visible( value = '99' ).
ENDCASE.
ENDLOOP. -
Enhancing standard component with new component usage
Hi!
I try to enhance standard component /SAPSRM/WDC_AOFC_BEV with new component usage (say, SALV_WD_TABLE). It allows me to add new usage, but the usage does not appear in the "Component Usages" tree node.
Is it a bug? Is it possible to enhance a standard component with new component usage?Hi Thomas!
We've been communicating with SAP on this issue for a while and last response we obtained is next:
Dear customer,
the possibility to create external controller usages (as required for
the ALV-usage) is not supported by the Web Dynpro ABAP development
tools. However, you could try a programmatic apporach by adding the
ALV-usage dynamically (e.g. in methods or method exits created within
your enhancement implementation).
See test component WDR_TEST_DYN_ALV_USAGE for details.
What's your opinion on this? Is it really not a bug? -
ALV selection not displayed/shown
Hello,
I have a question concerning the ALV:
In NW 7.0 everything was fine and working, as of EhP1 the selection for one ALV is not displayed.
...the selection is done alright and also corresponding events are raised. Nevertheless there is no visual representation for a selection - meaning the yellow/orange highlighting of a selected line. It is neither done for the lead selection nor for "normal" selections.
Other ALV in the same application (though different component) work fine and as far as I can tell all are initilized similarly.
Does anyone know this effect and - most important - how to correct it?
Regards,
RobertHello all,
We were able to solve the issue of selections not being visible - although they are correctly set in ALV/context.
-> The default view of the window has to be set to the ALV usage!
Don't ask me why, but in case the default setting is on the empty view, no selections will be visible on the UI. As soon as you set the ALV usage as default, the selections will be visible again.
Kind Regards,
Robert
Maybe you are looking for
-
Material Cost estimate modification
Hi Experts I want to modified this report and add cost estimate value from MBEW (field is STPRS) for each material to this report. I have used the table MBEW but unable to locate where to start. Can anyone have a look and comment on this report REPO
-
I have got a windows 7 64bit laptop, and i have been experiancing problems with my iTunes. It worked last saturday (28th April) and ever since then i can't open it back up. it asked me to re-install it as it wasnt installed properly. The error that i
-
I can't get Motion 4 to run. It crashes each time on startup. The crash log is below. The project it opened on had music imported into it. Not sure if that's related. Dave Process: Motion [181] Path: /Applications/Motion.app/Contents/MacOS/Motion Ide
-
Why is Lightroom 5 Crop tool so slow?
Having this problem all the time. Sluggish crop tool making it impossible to make fine adjustments. Sole solution is to NOT use the 2nd monitor view. It seems this is causing the problem. Except I WANT to use the 2nd monitor-option as a part of my wo
-
Corrupt database, need to start over
This is a test bed env. I've hosed the .dbf and control files, there's no backup and I don't want to recover. V$DATABASE and V$INSTANCE show the db as intact when I 'startup nomount', but in fact there's no database out there anymore. What I want to