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

Reg select query from

dinamols
Participant
0 Likes
789

Hi All,

I need a help to select the relevant field.In Hr (pa0008) there r fields with name lga01 to lga40 .My requirement is i need to fetch any of these fields for which the value should be '1000' '1100' etc.could anyone help me .

With Thanks,

Dina

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
682

hi

u can use ..

loop at <table>.

do 40 times varying v_lga from lga01 next lga02.

if v_lga = '1000'.

<ur logic>

endif.

enddo.

endloop.

hope it helps...

4 REPLIES 4
Read only

Former Member
0 Likes
683

hi

u can use ..

loop at <table>.

do 40 times varying v_lga from lga01 next lga02.

if v_lga = '1000'.

<ur logic>

endif.

enddo.

endloop.

hope it helps...

Read only

Former Member
0 Likes
682

Hi

See the sample code and do accordingly

Report Zabc.

tables:pernr.

infotypes:0008.

data: begin of wagetypes,

lga like pa0008-lga01,

bet like pa0008-bet01,

anz like pa0008-anz01,

end of wagetypes.

get pernr.

rp_provide_from_last p0008 space pn-begda pn-endda.

do 20 times varying wagetypes

from p0008-lga01 next p0008-lga02.

if not wagetypes-lga is initial.

write:/ wagetypes-lga, wagetypes-bet, wagetypes-anz.

endif.

enddo.

<b><REMOVED BY MODERATOR></b>

regards

Anji

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
682

tables : pa0001.

select-options : s_pernr for pa0001-pernr,

s_date for sy-datum.

data : v_lgann type pa0008-lga01.

data : begin of i_0008 occurs 0,

pernr like pa0008-pernr,

endda like pa0008-endda,

lga01 like pa0008-lga01,

lga02 like pa008-lga02,

lga03 like pa008-lga03,

*--Similarly do upto lga40...and other fields u need to include....

end of i_0008.

select pernr subty endda

lga01

lga02

lga03

*and other fields...upto lga40

from pa0008

into table i_0008

WHERE pernr in s_pernr "based on which pernrs u need

AND endda GE s_date-low

AND begda LE s_date-high.

if sy-subrc = 0.

loop at i_0008.

do 20 times varying v_lgann from i_0008-lga01 next i_0008-lga02.

if v_lgann is initial.

exit.

endif.

if v_lgann = '1000' or v_lgann = '1100'.

write 😕 v_lgann.

*--perform what u want to do with these fields.....or related fields...like bet01 etc.

*--but u need to include these fields in internal table structure as well as select.....

endif.

enddo.

endloop.

endif.

Regards

Vasu

Read only

0 Likes
682

Hi,

Till i didn't get the result,As mention in the thread i have coded the program but i have to get corresponding bet(01 or 05) and move this to another int table.I have taken only 10 of these fields instead of 40.This is one part of my requirement,please could anyone give any sugessions or different codings for this,i will be gratefull.

please see the codings

TABLES : pa0008.

SELECT-OPTIONS : s_pernr FOR pa0008-pernr.

DATA : wage TYPE pa0008-lga01.

TYPES:BEGIN OF str,

bas1 TYPE pa0008-bet01,

bas2 TYPE pa0008-bet01,

bas3 TYPE pa0008-bet01,

bas4 TYPE pa0008-bet01,

bas5 TYPE pa0008-bet01,

begdt TYPE pa0008-begda,

enddt TYPE pa0008-endda,

END OF str.

DATA : it TYPE TABLE OF str WITH HEADER LINE.

types : BEGIN OF wa_0008 ,

pernr LIKE pa0008-pernr,

begda LIKE pa0008-begda,

endda LIKE pa0008-endda,

lga01 LIKE pa0008-lga01,

lga02 LIKE pa0008-lga02,

lga03 LIKE pa0008-lga03,

lga04 LIKE pa0008-lga03,

lga05 LIKE pa0008-lga03,

lga06 LIKE pa0008-lga03,

lga07 LIKE pa0008-lga03,

lga08 LIKE pa0008-lga03,

lga09 LIKE pa0008-lga03,

lga10 LIKE pa0008-lga03,

bet01 LIKE pa0008-bet01,

bet02 LIKE pa0008-bet02,

bet03 LIKE pa0008-bet03,

bet04 LIKE pa0008-bet04,

bet05 LIKE pa0008-bet05,

bet06 LIKE pa0008-bet06,

bet07 LIKE pa0008-bet07,

bet08 LIKE pa0008-bet08,

bet09 LIKE pa0008-bet09,

bet10 LIKE pa0008-bet10,

END OF wa_0008.

DATA : i_0008 TYPE TABLE OF wa_0008 WITH HEADER LINE.

START-of-SELECTION.

SELECT pernr begda endda

lga01 bet01

lga02 bet02

lga03 bet03

lga04 bet04

lga05 bet05

lga06 bet06

lga07 bet07

lga08 bet08

lga09 bet09

lga10 bet10

FROM pa0008

INTO CORRESPONDING FIELDS OF TABLE i_0008

WHERE pernr IN s_pernr .

IF sy-subrc = 0.

LOOP AT i_0008.

DO 20 TIMES VARYING wage FROM i_0008-lga01 NEXT i_0008-lga02.

IF wage IS INITIAL.

EXIT.

ENDIF.

IF wage = '0100' .(Here suppose the field lga01 has this value i have to move the corresponding bet01 value to it-bas1)

move i_0008-bet01 to it-bas1.

APPEND it.

ENDIF.

IF wage = '0101' .(similarly if lga03 has this value i have to move corresponding

bet03 to it-bas3)

move i_0008-bet03 to it-bas3.

modify it TRANSPORTING bas3.

ENDIF.

IF wage = '0102' .

move i_0008-bet02 to it-bas2.

modify it TRANSPORTING bas2.

ENDIF.

IF wage = '0103' .

move i_0008-bet04 to it-bas4.

modify it TRANSPORTING bas4.

ENDIF.

IF wage = '0104' .

move i_0008-bet05 to it-bas5.

modify it TRANSPORTING bas5.

ENDIF.

ENDDO.

ENDLOOP.

ENDIF.