‎2019 Dec 26 5:06 AM
Hi Experts,

My requirement is based on the sales document number i need to display all material details. for that i designed a query as shown in below. But problem is i am getting only single material details repeatedly as shown in above fig. Can you please help to resolve this problem by getting all material details based corresponding so number
SELECT single
*VBELN
MATNR
ARKTX
MEINS
netpr
kwmeng
netwr
mwsbp
FROM VBAP
INTO wa_vbap
*for all entries in wa_vbak
WHERE VBELN = I_vbeln.
Regards,
Bhavani.
‎2019 Dec 26 6:02 AM
bhavani123,
You have written a Select Single Query from VBAP table to get entries, in this case you will only get one entry irrespective of the number of entries in there.
I would recommend you to change your query as below:
SELECT SINGLE
VBELN
MATNR
ARKTX
MEINS
netpr
kwmeng
netwr
mwsbp
FROM VBAP
INTO table @data(lt_vbap)
WHERE VBELN = I_vbeln.
if sy-subrc eq 0.
SORT LT_VBAP by VBELN MATNR.
endif.The above query will have all the materials related to the Sales order in the internal table LT_VBAP, now you just loop the table inside the smartform and map the fields accordingly so that during each iteration all the line items are picked progressivley.
Regards!
‎2019 Dec 26 6:43 AM
‎2019 Dec 26 6:59 AM
But i am getting error like
Field "table" is unknown. It is neither in one of specified tables nor defined by a "Data" Statement. "Data" Statement.
‎2019 Dec 26 7:09 AM
bhavani123,
May be because you are using older version, this syntax is only with newer versions.
Recommend you to follow the traditional way declaring the table up front and the use it in your query.
‎2019 Dec 27 4:53 AM
Can you please help me by sending the select query because i developed a query as shown in below but still i am getting only single material number details.
SELECT
VBELN
MATNR
ARKTX
MEINS
netpr
kwmeng
netwr
mwsbp
FROM VBAP
INTO table it_vbap
**for all entries in wa_vbak
WHERE VBELN = I_vbeln.
‎2019 Dec 27 5:59 AM
‎2019 Dec 27 10:31 AM
Thanks for the catch sandra.rossi
Hello bhavani123,,
Please find the code below,
SELECT SINGLE
VBELN,
MATNR,
ARKTX,
MEINS,
netpr,
kwmeng,
netwr,
mwsbp
FROM VBAP
INTO table @data(lt_vbap)
WHERE VBELN = @I_vbeln.
if sy-subrc eq 0.
SORT LT_VBAP by VBELN MATNR.
endif.
Regards!
‎2019 Dec 27 6:02 AM
How can you tell that the error is from this particular query and not from anywhere else? (maybe the fault is from the loop or the smart form or between them).
‎2019 Dec 27 9:14 AM