04-08-2011 7:26 AM
Hi,
Below is my select query
SELECT otype
objid
plvar
rsign
relat
begda
endda
sclas
sobid FROM hrp1001 INTO CORRESPONDING FIELDS OF TABLE it_s2
where otype = 'S' and plvar = '01'..
* Now I have to pass the variable in sobid to pernr, but both have different data type
* and length and also both the tables (hrp1001 and pa0002) do not have a common field
* so im passing the variable in sobid to pernr1 which is like pernr and then im making
* seletion based on pernr1.
loop at it_s2 into wa_s2.
if wa_S2-SCLAS = 'P'.
MOVE wa_s2-sobid to wa_s3-pernr1.
APPEND wa_s3 to it_s3.
select pernr
nachn
vorna FROM pa0002 into CORRESPONDING FIELDS OF TABLE it_s4
where pernr = wa_s3-pernr1 .
endif.
endloop.
Now my requirement is to put the above 12 fields into one internal table. How can that be achieved.
04-08-2011 7:35 AM
Just create a new Type in your program
TYPES:
BEGIN of ty_output,
pernr TYPE persno,
nachn TYPE string,
... ,
END OF ty_output.
DATA: lw_output TYPE ty_output,
lt_output TYPE STANDARD TABLE OF ty_output.
...
loop at it_s2 into wa_s2.
if wa_S2-SCLAS = 'P'.
MOVE wa_s2-sobid to wa_s3-pernr1.
APPEND wa_s3 to it_s3.
select pernr
nachn
vorna FROM pa0002 into CORRESPONDING FIELDS OF lw_output
where pernr = wa_s3-pernr1 .
MOVE-CORRESPONDING wa_s2 TO lw_output
APPEND lw_output.
endselect.
endif.
endloop.
04-08-2011 7:35 AM
Just create a new Type in your program
TYPES:
BEGIN of ty_output,
pernr TYPE persno,
nachn TYPE string,
... ,
END OF ty_output.
DATA: lw_output TYPE ty_output,
lt_output TYPE STANDARD TABLE OF ty_output.
...
loop at it_s2 into wa_s2.
if wa_S2-SCLAS = 'P'.
MOVE wa_s2-sobid to wa_s3-pernr1.
APPEND wa_s3 to it_s3.
select pernr
nachn
vorna FROM pa0002 into CORRESPONDING FIELDS OF lw_output
where pernr = wa_s3-pernr1 .
MOVE-CORRESPONDING wa_s2 TO lw_output
APPEND lw_output.
endselect.
endif.
endloop.
04-08-2011 9:59 AM
Just create a new type with both the fields and using this create a new table. And use select * from... into corresponding fields of new table in second select and that should work fine.
04-08-2011 11:07 AM
Hi
Can you tell us your requirement? There could be an alternate way of doing it.
From the select query I presume you're trying to get the Positions employee was/is associated with.
Regards,
Rupesh
04-08-2011 11:22 AM
Hi Rupesh,
My requirement is to select a list of OBJID from table hrp1001, for those OBJID I should get their corresponding SOBID and SCLAS. SCLAS has many values but when SCLAS = 'P' and for that SOBID I have to fetch the corresponding NACHN and VORNA, they are the first name and last name respectively from table pa0002. And there are no common fields between the tables but the data in hrp1001-SOBID and pa0002-PERNR are same for hrp1001-SCLAS = 'P'.
04-08-2011 11:55 AM
Hi
HRP1001 table contains the relationship between OM objects in HR module.
An object type Person(P) is always related to an object type Position(S) wih a relationship A008 / B008 i.e Holder of the position.
To narrow down your resultset, also give RELAT and RSIGN fields in the WHERE clause.
So, when you make selection from HRP10001 be assured that field RELAT will be 'A' and RSIGN will always be '008'. As a result, the SOBID will always be a personnel number.
Regards,
Rupesh