‎2007 May 14 7:19 AM
I have a variable 'z' where a value is coming dynamically in the program. This value is the name of one of the date type field of my infotype 0041.
eg. z = dar** (any 1 of the 12 fields).
My requirement is that i hv to select the value of another field (dat*) which corresponds to value of this field (dar*) and store it in a variable "datedem"
Please help me to write the select query for the same.
‎2007 May 14 7:51 AM
You are working with date repetitive structure.
Use do varying option.
declare like
data:begin of str,
dar type p0041-dar01,
dat type p0041-dat01,
end of str.
do 12 times varying str from p0041-dar01 next p0041-dar01.
v_date = str-dat01.
enddo.
‎2007 May 14 7:46 AM
Hi,
You can take the help from this code :
If zdar is not initial.
if datedem is initial.
select dat01 from pa0041 into datedem
where dar01 eq zdar.
endif.
if datedem is initial.
select dat02 from pa0041 into datedem
where dar02 eq zdar.
endif.
if datedem is initial.
select dat03 from pa0041 into datedem
where dar03 eq zdar.
endif.
if datedem is initial.
select dat04 from pa0041 into datedem
where dar04 eq zdar.
endif.
if datedem is initial.
select dat05 from pa0041 into datedem
where dar05 eq zdar.
endif.
if datedem is initial.
select dat06 from pa0041 into datedem
where dar06 eq zdar.
endif.
if datedem is initial.
select dat07 from pa0041 into datedem
where dar07 eq zdar.
endif.
if datedem is initial.
select dat08 from pa0041 into datedem
where dar08 eq zdar.
endif.
if datedem is initial.
select dat09 from pa0041 into datedem
where dar09 eq zdar.
endif.
if datedem is initial.
select dat10 from pa0041 into datedem
where dar10 eq zdar.
endif.
if datedem is initial.
select dat11 from pa0041 into datedem
where dar11 eq zdar.
endif.
if datedem is initial.
select dat12 from pa0041 into datedem
where dar12 eq zdar.
endif.
endif.
Reward if helpful.
Regards,
Sandeep Kaushik
‎2007 May 14 7:51 AM
You are working with date repetitive structure.
Use do varying option.
declare like
data:begin of str,
dar type p0041-dar01,
dat type p0041-dat01,
end of str.
do 12 times varying str from p0041-dar01 next p0041-dar01.
v_date = str-dat01.
enddo.
‎2007 May 14 7:52 AM
Hi
report ZXYZ.
Tables :PERNR.
infotypes :0041.
data: begin of dates,
dar like pa0041-dar01,
dat like pa0041-dat01,
end of dates.
get pernr.
rp_provide_from_last p0041 space pn-begda pn-endda.
do 20 times varying dates
from p0041-dar01 next p0041-dar02.
write: / dates-dar, dates-dat.
enddo.
this will give you the corresponding DATXX value for the corresponding DARXX value.
Reward points if useful
Regards
Anji
‎2007 May 14 10:31 AM
Hi Anji,
With the code you have mentioned, i am getting an error message as
"p0041-dar01" and "dates" are type in-compatible.
Can you help me on this.
Rgds,
Preeti.
‎2007 May 14 10:49 AM
Suppose Z = DAR**
Declare Y TYPE STRING.
Y = Z.
Y+0(3) = 'T'.
Now Y will have DAT**.
SELECT (Y) FROM ....
Hope this helps.