Application Development 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: 

Re:Urgent

Former Member
0 Kudos
84

Hi,

What does this select stmt mean, iam not understanding how they have related ,Plz help me

data: v_xblnr like mkpf-xblnr,

S_PGIDT FOR LIKP-WADAT_IST,

H_OBJ LIKE THEAD-TDNAME,

S_VBELN FOR LIKP-VBELN.

SELECT distinct XBLNR into v_xblnr FROM MKPF

where BLART = 'WL' AND

CPUDT IN S_PGIDT -


> but before PGI i need to insert the values in my

AND XBLNR IN S_VBELN. customised table so i have removed tht condition but still not working

SELECT single * FROM VBUK

WHERE VBELN = v_xblnr.

IF SY-SUBRC EQ 0.

SELECT single * FROM LIKP

WHERE VBELN = v_xblnr.

MOVE LIKP-VBELN TO H_OBJ.

3 REPLIES 3

Former Member
0 Kudos
55

Hi Sravanthigopal,

Pls modify ur program as follows


tables : likp.
data: v_xblnr like mkpf-xblnr.
data : ls_vbuk like vbuk,
       ls_likp like likp.
data :H_OBJ LIKE THEAD-TDNAME.

select-options: S_PGIDT FOR likp-WADAT_IST,
               S_VBELN FOR LIKP-VBELN.





SELECT distinct XBLNR into v_xblnr FROM MKPF
where BLART = 'WL' AND CPUDT IN S_PGIDT AND XBLNR IN S_VBELN.
endselect.
SELECT single * FROM VBUK into ls_vbuk
WHERE VBELN = v_xblnr.
IF SY-SUBRC EQ 0.

SELECT single * FROM LIKP into ls_likp
WHERE VBELN = v_xblnr.
endif.

<i>You can also use the optional additions SINGLE or DISTINCT to indicate that only certain lines in the result set should be visible to the program:

SINGLE

The result of the selection should be a single entry. If it is not possible to identify a unique entry, the system uses the first line of the selection. If you use the FOR UPDATE addition, the selected entry is protected against parallel updates from other transactions until the next database commit (see LUW and database lock mechanism). If the database system identifies a deadlock, a runtime</i>

reward pts if found usefull

Regards

Sathish

former_member189059
Active Contributor
0 Kudos
55

'Select distinct' means that if more than one similar entry for XBLNR exists, only one will be selected

'Select single' only select the first record that matched the condition

eg: if you have values like

0080003837

0065654685

0080003837

0080003837

then the output for select distinct will be

0080003837

0065654685

and the output for select single will be

0080003837

former_member189059
Active Contributor
0 Kudos
55

<i>SELECT distinct XBLNR into v_xblnr FROM MKPF

where BLART = 'WL' AND

CPUDT IN S_PGIDT -


> but before PGI i need to insert the values in my

AND XBLNR IN S_VBELN. customized table so i have removed tht condition but still not working </i>

Please note that the above select statement only moves the data into a workarea one row at a time

You need to use the append statement to append it to an internal table and then close it with an 'endselect' statement

An alternative would be to use 'into <b>table</b> itab'

this will directly select all the data into an internal table and removes the need for an 'endselect' statement