02-14-2011 10:33 AM
Guys, I have the following code :
if x_header-viewname = 'ZRC_C003'.
loop at total assigning <fs_str>.
"assign: component 'ACTION' of structure <fs_str> to <fs_action>.
"check <fs_action> ca 'NU'.
assign component 'BUKRS' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_bukrs = <fs_fld>.
endif.
assign component 'SAKNR' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_bukrs = <fs_fld>.
endif.
assign component 'ZRC_PERIO_I' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_zrc_perio_i = <fs_fld>.
endif.
assign component 'ZRC_PERIO_F' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_zrc_perio_f = <fs_fld>.
endif.
assign component 'ZRC_TP_CONTA' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_zrc_tp_conta = <fs_fld>.
endif.
assign component 'ZRC_REL3' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_zrc_rel3 = <fs_fld>.
endif.
assign component 'ZRC_CEF' of structure <fs_str> to <fs_fld>.
if <fs_fld> is assigned.
lv_zrc_cef = <fs_fld>.
endif.
endloop.
endif.to be honest i have copied this from other program , my problem is that i dont know what you have to do to declare TOTAL in a proper way, because when i debugg the original program i see that total has all the fields of the table , however my total ( in my table ) only has a field called LINE.
Edited by: José M. Sánchez on Feb 14, 2011 6:23 AM
02-14-2011 12:09 PM
DATA: BEGIN OF wa_total.
INCLUDE STRUCTURE zmmmt_catlg_link.
INCLUDE STRUCTURE vimflagtab.
DATA: END OF wa_total.
loop at total into wa_total.
endloop.
02-14-2011 12:09 PM
DATA: BEGIN OF wa_total.
INCLUDE STRUCTURE zmmmt_catlg_link.
INCLUDE STRUCTURE vimflagtab.
DATA: END OF wa_total.
loop at total into wa_total.
endloop.
02-14-2011 2:19 PM
thank you Keshav , But just one question what is zmmmt_catlg_link.
?
02-14-2011 4:00 PM
02-14-2011 4:50 PM
Ok , but my problem is that several tables will call the same include , is there any way of do the name dinamically , something like:
for example
include structure <fs>
thank you one more time.
02-14-2011 5:15 PM
but my problem is that several tables will call the same include
It seems like you are doing a big process. Please explain what you are trying to do. Generally the events are called dynamically in a standard include generated by the table maintenance.
How are you saying several tables will call the same include ??
Keshav
02-14-2011 6:05 PM
Well , Whati want to is use the same function module for several tables , four to be exact , what i want to do is to validate x_header-viewname = 'ZRC_C003' 0r x_header-viewname = 'ZRC_C004' and update some fields for one table and some other for the others.
Im using the event 01 so maybe my user want to update several lines before SAVE I really need that loop on TOTAL. i did something like this , but it doesnt work
field-symbols:
<fs_action>,
<fs_str>,
<fs_fld>.
data:
lv_bukrs type zrc_c005-bukrs.
if "x_header-viewname = 'ZRC_C003' or
"x_header-viewname = 'ZRC_C004' or
x_header-viewname = 'ZRC_C005' .
"assign x_header-viewname to <fs_str> .
data: begin of wa_total.
include structure ZRC_C005. <-- " want to use different tables here
include structure vimflagtab.
data: end of wa_total.
loop at extract into wa_total .
assign component 'AEDAT' of structure wa_total to <fs_fld>.
if <fs_fld> is assigned.
<fs_fld> = sy-datum.
endif.
assign component 'AEZET' of structure wa_total to <fs_fld>.
if <fs_fld> is assigned.
<fs_fld> = sy-uzeit.
endif.
assign component 'AENAM' of structure wa_total to <fs_fld>.
if <fs_fld> is assigned.
<fs_fld> = sy-uname.
endif.
endloop..
02-14-2011 7:04 PM
José,
The following is some code I used. You would need to change this to allow for the four different tables.
if "x_header-viewname = 'ZRC_C003' .
>> code for this table <<
elseif "x_header-viewname = 'ZRC_C004' .
>> code for this table <<
elseif "x_header-viewname = 'ZRC_C005' .
>> code for this table <<
endif.
loop at total into w_string. " all records on screen
*
if w_string+693(1) = `U`. " change record
*
*>> Change entry validation, if date_to_chspk has value, error
*
select single *
from zes_check_info
into w_zes_check_info
where chect = w_string+3(13)
and vblnr = w_string+16(10)
and gjahr = w_string+26(4)
and zbukr = w_string+30(4)
and hbkid = w_string+34(5)
and hktid = w_string+39(5)
and ubhkt = w_string+44(10)
and date_to_chspk > 0.
*
if sy-subrc = 0.
* record has value in date_to_chspk
* compare all changeable fields
if
* w_zes_check_info-check_reportable = w_string+068(01) and
w_zes_check_info-multiple_payees = w_string+069(01) and
w_zes_check_info-chspk_last_name = w_string+293(35) and
w_zes_check_info-chspk_1st_name = w_string+328(35) and
w_zes_check_info-chspk_mid_name = w_string+363(35) and
w_zes_check_info-chspk_suffix = w_string+398(04) and
w_zes_check_info-chspk_comp_name = w_string+402(35) and
w_zes_check_info-chspk_adr_line1 = w_string+437(35) and
w_zes_check_info-chspk_state = w_string+472(2) and
w_zes_check_info-chspk_country = w_string+474(4) and
w_zes_check_info-department = w_string+527(30) and
w_zes_check_info-property_type = w_string+557(4) and
w_zes_check_info-holder_id = w_string+561(4) and
* w_zes_check_info-srch_ltr_recdate = w_string+622(8) and
* w_zes_check_info-srch_ltr_rectime = w_string+630(6) and
w_zes_check_info-final_rpt_date = w_string+627(8) and
w_zes_check_info-override_rj = w_string+691(2).
*
* OK, table & screen fields all equal, no change
else.
* error, data already sent to Chesapeake, change attempted
*
message i000(zf) with `Already sent to Chesapeake.`
`Record can't be changed.` .
*
errors = 'X'.
*
endif. " compare all changeable fields
*
endif. " sy-subrc = 0. ZES_CHECK_INFO
*
endif. " w_string+693(1) = `U`. " change record
*
endloop. "AT total INTO w_string Bruce