12-27-2016 8:26 PM
I've tried a number of different things trying to comparing the field lop_d_list_hd-doc_item_no to wbhi-tposn. Nothing seems to be working. Neither of the bold options below is working.
doc_item_no: 0000000010 would be item 10. The data type is NUMC and the length is 10.
tposn: 000010 would be item 10. The data type is numc and the length is 6.
Does anyone know of a way to compare the two columns inside the inner join so I don't have to loop through the table to do the compare?
SELECT DISTINCT
A~DOC_NO, ", -- Document Number (TC #)
A~DOC_ITEM_NO, " DOC_ITEM_NO,
A~MASTER_NO, ", -- List Number
A~LOP_CAT, ", -- Option Category
A~LOP_ID, ", -- Option Category Description
B~MATNR, ", -- Material
C~TPOSN
INTO Table @IT_LOP_TEMP FROM LOP_D_LIST_HD AS A
INNER JOIN LOP_D_LIST_IT AS B
ON A~LIST_GUID = B~LIST_GUID
INNER JOIN WBHI AS C ON
C~TKONN = A~DOC_NO
* AND C~TPOSN = RIGHT(A~DOC_ITEM_NO)
*AND A~DOC_ITEM_NO = C~TPOSN
INNER JOIN WBHK AS D ON D~TKONN = C~TKONN
wHERE
A~LOP_CAT = P_LOP_CAT AND
B~MATNR in so_matnr AND
D~KUNNR = i_kunnr AND " -- Customer
D~btbsta in T_BTBSTA_RFC_SELOPT.
12-27-2016 9:15 PM
Why not use a string compare instead of "="?
https://help.sap.com/saphelp_di471/helpdata/EN/fc/eb3516358411d1829f0000e829fbfe/content.htm
12-28-2016 4:17 PM
I see you tried to use the RIGHT function, but it won't work if you don't run ABAP 7.50.
As the 2 fields contain different values (0000000010 versus 000010), you can only use a join by using the new functions RIGHT or SUBSTR of ABAP 7.50. The only other way I know before 7.50 is to use 2 SELECT statements, the second being with FOR ALL ENTRIES where it's possible to indicate a substring, possibly with a join:
But of course it may be counter-performing especially if the first SELECT returns too many lines.