2013 Jun 28 9:36 AM
Dear Experts,
Please see the code below.
(This is while debugging with single material code)
select matnr lgort charg sobkz kalab from mska into corresponding fields of table it_mska
for all entries in itab where matnr = itab-matnr and lgort = 'XYZ1' and sobkz = 'E'.
This code gives me 6 rows, but when I query table MSKA (SE16) with same inputs, it gives me 23 lines.
This is happening with almost all material codes.
Then when I hardcode the matnr value in the code for testing, it returns all the 23 values.
select matnr lgort charg sobkz kalab from mska into corresponding fields of table it_mska
for all entries in itab1
where matnr = '000019876123456789' and lgort = 'XYZ1' and sobkz = 'E'.
Why so?
Jogeswara Rao K
2013 Jun 28 9:59 AM
Add the max key fields of table mska to your select statement
like VBELN , POSNR
Modify the code like this
select matnr lgort charg sobkz kalab vbeln posnr from mska into corresponding fields of table it_mska
for all entries in itab where matnr = itab-matnr and lgort = 'XYZ1' and sobkz = 'E'.
(it_mska structure to be modified accordingly)
Regards
Rakhee Prabhu
Dear Experts,
Please see the code below.
(This is while debugging with single material code)
select matnr lgort charg sobkz kalab from mska into corresponding fields of table it_mska
for all entries in itab where matnr = itab-matnr and lgort = 'XYZ1' and sobkz = 'E'.
This code gives me 6 rows, but when I query table MSKA (SE16) with same inputs, it gives me 23 lines.
This is happening with almost all material codes.
Then when I hardcode the matnr value in the code for testing, it returns all the 23 values.
select matnr lgort charg sobkz kalab from mska into corresponding fields of table it_mska
for all entries in itab1
where matnr = '000019876123456789' and lgort = 'XYZ1' and sobkz = 'E'.
Why so?
Jogeswara Rao K
2013 Jun 28 9:59 AM
Add the max key fields of table mska to your select statement
like VBELN , POSNR
Modify the code like this
select matnr lgort charg sobkz kalab vbeln posnr from mska into corresponding fields of table it_mska
for all entries in itab where matnr = itab-matnr and lgort = 'XYZ1' and sobkz = 'E'.
(it_mska structure to be modified accordingly)
Regards
Rakhee Prabhu
2013 Jun 28 10:16 AM
Thank you both Rakhee and Vijay,
I've just tested and found issue solved.
This is good learning for me.
Jogeswara Rao K
2013 Jun 28 10:51 AM
Here's some more tips
1. Rewrite as an INNER JOIN, instead of FAE, and see the benefits.
2. NEVER EVER use itab as the name of a internal table. Use meaningful variable names.
2013 Jun 28 11:53 AM
Thank you for tips
itab is used in the example. We use git_ prefixes.
Jogeswara Rao K
2013 Jun 28 1:18 PM
Only if it's global. And you do know that the fewer global variables the better?
2013 Jun 28 2:17 PM
2013 Jun 28 10:02 AM
hello,
When you use for all entries it always gives you unique records according to your selection.
In a select query you didn't get all primary key fields.
whereas when you goto to se16, system always considers all primary keys and returns 23 lines.
So use all primary fields in your select query
Regards,
Vj
2013 Jun 28 10:17 AM
Dear Jogeswara,
Please pass all key fields on your select queries
SELECT MATNR WERKS LGORT CHARG SOBKZ VBELN POSNR
FROM MSKA INTO TABLE GT_MSKA
XXXXXX.
Because,duplicates entries are deleting internally that's what you are not getting all the entries.
Thanks and Regards,
buz_sap
2013 Jun 28 11:54 AM
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |