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

SELECT PROBLEM

Former Member
0 Likes
803

Hallow I have a complicated question.(function module) in the select 2 and select 3 I have a problem that the value that I put in objid (select 2 and 3) is probable is not write because It have to change to value of itab and in itab the value is not constant but changing

In the debug I get in

How can I do it maybe in loop.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(BEGDA) TYPE BEGDA DEFAULT '19000101'

*" REFERENCE(ENDDA) TYPE ENDDA DEFAULT '99991231'

*" REFERENCE(UNAME) TYPE SYUNAME

*" TABLES

*" Z_COURSE_TABLE STRUCTURE HROBJECT

*"----


TABLES: hrp1001 , hrp1000.

DATA:i77pr LIKE t77pr,

obj_tab LIKE hrobject OCCURS 0 WITH HEADER LINE.

DATA: a_person_objid(8) TYPE n .

DATA: person_tab TYPE rhldapp OCCURS 0 WITH HEADER LINE.

DATA: wa_person_tab LIKE LINE OF person_tab .

a_person_objid = person_tab-objid.

*----


TYPES: BEGIN OF 1_itab,

objid TYPE hrobjid,

lastname TYPE pad_nachn,

firstname TYPE pad_vorna,

sobid TYPE sobid,

begda TYPE begdatum,

endda TYPE enddatum,

priox TYPE priox,

END OF 1_itab.

DATA: itab TYPE TABLE OF 1_itab,

wa_itab LIKE LINE OF itab.

TYPES: BEGIN OF 2_itab,

objid TYPE hrobjid,

sobid TYPE sobid,

begda TYPE begdatum,

endda TYPE enddatum,

priox TYPE priox,

END OF 2_itab.

DATA: b_itab TYPE TABLE OF 2_itab,

wa_b_itab LIKE LINE OF b_itab.

TYPES: BEGIN OF 3_itab,

objid TYPE hrobjid,

sobid TYPE sobid,

begda TYPE begdatum,

endda TYPE enddatum,

priox TYPE priox,

END OF 3_itab.

DATA: c_itab TYPE TABLE OF 3_itab,

wa_c_itab LIKE LINE OF c_itab.

TYPES: BEGIN OF 4_itab,

objid TYPE hrobjid,

sobid TYPE sobid,

begda TYPE begdatum,

endda TYPE enddatum,

priox TYPE priox,

END OF 4_itab.

DATA: d_itab TYPE TABLE OF 4_itab,

wa_d_itab LIKE LINE OF d_itab.

*----


  • org_unit of manager

CALL FUNCTION 'RH_GET_MANAGER_ASSIGNMENT'

EXPORTING

i77pr = i77pr

uname = uname

TABLES

obj_tab = obj_tab.

*employye of manager

CALL FUNCTION 'RH_DIR_ORG_STRUC_GET'

EXPORTING

act_orgunit = obj_tab-objid

act_plvar = '01'

act_date = sy-datum

sort_flag = 'X'

add_flag_pdata = 'X'

TABLES

person_tab = person_tab

EXCEPTIONS

no_active_plvar = 1

OTHERS = 2.

  • append objid and names of employee into itab

LOOP AT person_tab INTO wa_person_tab.

MOVE-CORRESPONDING wa_person_tab TO wa_itab.

APPEND wa_itab TO itab.

ENDLOOP.

*1 select E of the course in table that i get in input

SELECT objid begda endda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE b_itab

FOR ALL ENTRIES IN z_course_table

WHERE objid = z_course_table-objid

AND otype = z_course_table-otype

AND plvar = '01'

AND relat = '020'

AND rsign = 'B'

AND begda LE sy-datum

AND endda GE sy-datum.

IF sy-subrc = 0.

*2 for all 'E' read hrp1001

SELECT objid sobid priox begda endda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE c_itab

WHERE ( otype EQ 'E' OR otype EQ 'ET' )

<b>AND objid = wa_b_itab-objid</b>

AND ( relat EQ '025' OR relat EQ '614' )

AND sclas EQ 'P'

AND begda LE sy-datum

AND endda GE sy-datum.

ENDIF.

*3 select the employye who register to course

SELECT objid sobid priox

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

where otype = 'D'

<b>AND objid = wa_itab-objid</b>

AND relat = '027'

AND sclas = 'P'

AND begda LE sy-datum

AND endda GE sy-datum.

thankes

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
719

The loop is missing for the SELECTS.

You will have to have the SELECTS inside the loop where you the value of the WA_ITAB changing.

Regards,

Ravi

Note - Please mark all the helpful answers

6 REPLIES 6
Read only

Former Member
0 Likes
720

The loop is missing for the SELECTS.

You will have to have the SELECTS inside the loop where you the value of the WA_ITAB changing.

Regards,

Ravi

Note - Please mark all the helpful answers

Read only

Former Member
0 Likes
719

Try the below instead of your select queries !!

SELECT objid sobid priox begda endda

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE c_itab

FOR all enteries in table b_tab

WHERE ( otype EQ 'E' OR otype EQ 'ET' )

AND objid = b_itab-objid

AND ( relat EQ '025' OR relat EQ '614' )

AND sclas EQ 'P'

AND begda LE sy-datum

AND endda GE sy-datum.

*3 select the employye who register to course

SELECT objid sobid priox

FROM hrp1001

INTO CORRESPONDING FIELDS OF TABLE d_itab

FOR all enteries in table b_tab

where otype = 'D'

AND objid = b_itab-objid

AND relat = '027'

AND sclas = 'P'

AND begda LE sy-datum

AND endda GE sy-datum.

Read only

0 Likes
719

what is a b_tab

Read only

0 Likes
719

what is a b_tab

Read only

0 Likes
719

Sorry b_tab is a typo error it should b_itab your internal table

Regards

Anurag

Read only

Former Member
0 Likes
719

Use the FOR ALL ENTRIES adition instead of LOOP - ENDLOOP.

Its better once you don't have to go to DB every loop pass.

Regards,

Felipe Cunha.