Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql query trouble

Author  Topic 

Jennifer_72
Starting Member

1 Post

Posted - 2010-05-27 : 12:43:47

Hi all,

Iam using the following query to read data from tables stpo,mast and makt (These are ABAP tables).
am using open sql.

Have filtered some data to an internal table "gt_slitab", which should be applied to the below query using "For all Entries".

Data in gt_slitab

UDATE , CHNGIND ,NEW_V ,OLD_V ,TABNAME, TABKEY

20100520, U, 2.000 ,1.000, STPO, 020M000340220000000100000002
20100527, U 1.000 2.000 STPO 020M000340220000000100000002
20100527 D STPO 020M000340220000000400000008
20100527 U 3.000 2.000 STPO 020M000340220000000400000008
20100525 D STPO 020M000340220000000500000010
20100525 I STPO 020M000340220000000500000010
20100527 D STPO 020M000340220000000600000012
20100527 I STPO 020M000340220000000600000012

By applying the query below


SELECT stpo~mandt stpo~stlty stpo~stlnr stpo~stlkn stpo~stpoz stpo~posnr stpo~idnrk mast~matnr
makt~maktx INTO CORRESPONDING FIELDS OF TABLE gt_slitab
FROM stpo INNER JOIN mast
ON stpo~stlnr = mast~stlnr
INNER JOIN makt ON mast~matnr = makt~matnr
FOR ALL entries IN gt_stpotabkey // gt_stpotabkey is an itab with only tabkey entries from gt_slitab.
WHERE stpo~mandt = gt_stpotabkey-mandt
AND stpo~stlty = gt_stpotabkey-stlty
AND stpo~stlnr = gt_stpotabkey-stlnr
AND stpo~stlkn = gt_stpotabkey-stlkn
AND stpo~stpoz = gt_stpotabkey-stpoz
AND stpo~stlty = 'M'
AND mast~stlan = p_bom // Parameter(For Exmaple 8)
AND mast~matnr IN so_matnr.//(a list of values)


I got the following result_value:

MANDT STLTY STLNR   STLKN  STPOZ POSNR	IDNRK	        MATNR	         MAKTX

20 M 34022 1 2 10 2002025921 SB10008502 kt, Nürnberg


But I expected the following entries as well as the output apart from the above one.


020M000340220000000400000008
020M000340220000000500000010
020M000340220000000600000012

Note that in result_value,the first 5 fields when concatenated results in the tabkey.(For example 020M000340220000000100000002)


What am i doing wrong in the query.Any help is appreciated.

Thanks
Jen

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-05-27 : 17:48:04
This is a Microsoft SQL Server Forum, I don't recognize that syntax that you're using, but www.dbforums.com might be a good place to start.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -