2018 Jul 30 2:21 PM
Hallo experts,
I am trying to find a specific value 'material number' in an internal table , to do this I have wrote the code below , but it still missing me something, as I am receiving no results.
TYPES: BEGIN OF tab2,
lo_matnr TYPE matnr,
END OF tab2.
DATA: BEGIN OF wa_tab1,
wa_matnr TYPE matnr,
END OF wa_tab1,
tbl_tab1 LIKE TABLE OF wa_tab1
WITH KEY wa_column1,
tbl_tab1_result TYPE match_result_tab,
wa_tab1_result LIKE LINE OF tbl_tab1_result.
wa_tab1-wa_matnr = wa_mara-matnr.
APPEND wa_tab1 TO tbl_tab1.
FIND ALL OCCURRENCES OF '20-30412' IN TABLE tbl_tab1
RESULTS tbl_tab1_result IN CHARACTER MODE.
LOOP AT tbl_tab1_result INTO wa_tab1_result.
READ TABLE tbl_tab1 INTO wa_tab1 INDEX wa_tab1_result-line.
IF sy-subrc = 0.
WRITE:/ 'Line:', wa_tab1_result-line, 'Offset:', wa_tab1_result-offset.
WRITE: 'Value is:', wa_tab1+wa_tab1_result-offset(3).
ENDIF.
ENDLOOP.
Many thanks in advance
Jenie
2018 Jul 31 10:34 AM
Hello Jenie,
1. counting the position specification for a charater begins with 0.
You can test this e.g.
write: wa_mara-matnr+1. -> 0-30412
write: wa_mara-matnr+0. -> 20-30412
online help
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenoffset_glosry.htm
2. Regarding Line of match: You are right. See please my second attachment.
3. Value is = -20. It is not negative, but you use command
wa_tab1+wa_tab1_result-offset(3) -> "20-" and the third chca-del-pngoffset-0.pngaracter is -.
Best regards,
Hedvig
Hallo experts,
I am trying to find a specific value 'material number' in an internal table , to do this I have wrote the code below , but it still missing me something, as I am receiving no results.
TYPES: BEGIN OF tab2,
lo_matnr TYPE matnr,
END OF tab2.
DATA: BEGIN OF wa_tab1,
wa_matnr TYPE matnr,
END OF wa_tab1,
tbl_tab1 LIKE TABLE OF wa_tab1
WITH KEY wa_column1,
tbl_tab1_result TYPE match_result_tab,
wa_tab1_result LIKE LINE OF tbl_tab1_result.
wa_tab1-wa_matnr = wa_mara-matnr.
APPEND wa_tab1 TO tbl_tab1.
FIND ALL OCCURRENCES OF '20-30412' IN TABLE tbl_tab1
RESULTS tbl_tab1_result IN CHARACTER MODE.
LOOP AT tbl_tab1_result INTO wa_tab1_result.
READ TABLE tbl_tab1 INTO wa_tab1 INDEX wa_tab1_result-line.
IF sy-subrc = 0.
WRITE:/ 'Line:', wa_tab1_result-line, 'Offset:', wa_tab1_result-offset.
WRITE: 'Value is:', wa_tab1+wa_tab1_result-offset(3).
ENDIF.
ENDLOOP.
Many thanks in advance
Jenie
2018 Jul 31 1:50 AM
I think this may be the problem:
tbl_tab1 LIKE TABLE OF wa_tab1 WITHKEY wa_column1,
as the table must be standard table with no secondary table keys, why dont you try: (orelse your table dont have that data pattern)
TBL_TAB1 TYPE TABLE OF TAB2 WITH KEY LO_MATNR,
2018 Jul 31 5:17 AM
If you need only one entry try using 'READ' or if you need multiple entries and you need to loop then you can use 'LOOP AT WHERE'.
LOOP AT tbl_tab1 INTO wa_tab1 WHERE wa_matnr = '20-30412'.
* Write the code here
ENDLOOP
2018 Jul 31 7:35 AM
Hello Jenie,
see my attachment, with a little modification your code is working.
(do not use "-" in names in Unicode programs (WA_MARA-MATNR) or wa_MARA was an internal table?
Best regards,
Hedvig
2018 Jul 31 8:21 AM
2018 Jul 31 8:26 AM

Hallo Jenie, I uploaded again, I hope you can see it now.
Best regards,
Hedvig
2018 Jul 31 9:55 AM
Thank you very much, really helpful.
I have some questions that i hope you can clarify them to me as I find the results somehow not realistic or maybe I am misunderstanding this opertion. So the result above showes :
Line of Match = 1 ' this mean for me that once i do to mara i will find the matnr 20-30412 in the first line and this is not case as 20-30412 will be found in the row 50250.
Offset from Beginning of Line = 0 ' here once LINE = 1 so the offset will be accordingly 0.
Value is = -20. I don't know why here the Value is negative.
Many thanks in advance .
Jenie
2018 Jul 31 8:02 AM
You should really try debugging before asking these kinds of questions.
2018 Jul 31 10:34 AM
Hello Jenie,
1. counting the position specification for a charater begins with 0.
You can test this e.g.
write: wa_mara-matnr+1. -> 0-30412
write: wa_mara-matnr+0. -> 20-30412
online help
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenoffset_glosry.htm
2. Regarding Line of match: You are right. See please my second attachment.
3. Value is = -20. It is not negative, but you use command
wa_tab1+wa_tab1_result-offset(3) -> "20-" and the third chca-del-pngoffset-0.pngaracter is -.
Best regards,
Hedvig
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |