Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regd select query.

Former Member
0 Likes
778

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.

1 ACCEPTED SOLUTION
Read only

former_member225631
Active Contributor
0 Likes
673

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.

5 REPLIES 5
Read only

Former Member
0 Likes
673

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

Read only

former_member225631
Active Contributor
0 Likes
674

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.

Read only

Former Member
0 Likes
673

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

Read only

0 Likes
673

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.

Read only

Former Member
0 Likes
673

Suppose Z = DAR**

Declare Y TYPE STRING.

Y = Z.

Y+0(3) = 'T'.

Now Y will have DAT**.

SELECT (Y) FROM ....

Hope this helps.