‎2013 Nov 28 5:53 PM
Hello,
I am using the following code to return the data from a specified KONZS:
TABLES lfa1.
DATA: gt_lfa1 TYPE TABLE OF lfa1.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: so_konzs FOR lfa1-konzs MATCHCODE OBJECT zshfi_konzs.
SELECTION-SCREEN: END OF BLOCK b1.
IF so_konzs IS NOT INITIAL.
SELECT * INTO TABLE gt_lfa1 FROM lfa1 WHERE konzs IN so_konzs.
ENDIF.
The problem is this: when values ​​with the last digit of 0 are informed, it returns data where KONZS equals the number without the 0 end.
For example: twhen I enter to the SO_KONZS 14520-14530, are returned the following records (LFA1-KONZS):
1452
1453
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
Anyone have any idea what might be happening?
Sorry my english
João Antônio Soares
‎2013 Nov 29 11:37 AM
It is because LFA1-KONZS have data type CHAR (length 10), so "number ranges" will not work as numbers but as characters.
‎2013 Nov 28 7:01 PM
Hi Joao,
IF so_konzs IS NOT INITIAL.
SELECT * INTO TABLE gt_lfa1 FROM lfa1 WHERE konzs IN so_konzs.
ENDIF.
IF so_konzs[] IS NOT INITIAL. " Write the [ ] along with internal table
SELECT * INTO TABLE gt_lfa1 FROM lfa1 WHERE konzs IN so_konzs.
ENDIF.
Because when u create the Select option it automatically create workarea for the same name same name with the internal table name. so with internal table write the explicitly [ ] along with the internal table.
Regards.
Nishant Bansal.
‎2013 Nov 28 7:37 PM
I have used following test code:
report ztest.
TABLES sflight.
DATA: gt_lfa1 TYPE TABLE OF sflight,
lw_lfa1 TYPE sflight.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: so_konzs FOR sflight-SEATSOCC." MATCHCODE OBJECT zshfi_konzs.
SELECTION-SCREEN: END OF BLOCK b1.
IF so_konzs IS NOT INITIAL.
SELECT * INTO TABLE gt_lfa1 FROM sflight WHERE SEATSOCC IN so_konzs.
ENDIF.
sort gt_lfa1 by SEATSOCC ASCENDING.
loop at gt_lfa1 into lw_lfa1.
Write:/ lw_lfa1-SEATSOCC.
ENDLOOP.
There is no problem in it.
‎2013 Nov 28 7:16 PM
Hi João , how is going, tell me how you see the data result, how you do the "write" sentence (s) or ALV or any way of publication.
thanks..
*-*-*--*-*-
this is a unexpected error, I ´ll look for information.
‎2013 Nov 29 2:52 PM
Hi, Alejandro,
I was seeing the contents of the table gt_lfa1 in debug mode.
Thanks.
‎2013 Nov 29 8:52 AM
Hi,
Yes you are right! As per my knowledge it is not possible to restrict. I think you need to update the Group key with right justified or leading zeros.
for example see the below screen shot. I think you can educate the users to update the group key with leading zeros. (ex: 000014520,
00001452)
My opinion: either you can use the equal values instead of range or change field updaes with leading zeros.
Thanks,
Kiran
‎2013 Nov 29 10:42 AM
Hi check weather conversion exits used in standard table and check domain,data element of that filed in table. also check you customized search help.
‎2013 Nov 29 11:37 AM
It is because LFA1-KONZS have data type CHAR (length 10), so "number ranges" will not work as numbers but as characters.
‎2013 Nov 29 3:09 PM
Hi Tomas,
Exactly this!
I could resolve as follows:
I created three variables of type integer to store the values ​​of "so_konzs-high", "so_konzs-low" and the actual konzs from internal table (like a iterator inside a loop at).
With the variables of type integer, I could to test into the internal table that was in range, and thus excludes the values ​​that was incorrect.
Below is the code:
TABLES: lfa1,
kna1.
TYPES: BEGIN OF ys_konzs_int,
low TYPE i,
high TYPE i,
END OF ys_konzs_int.
DATA: gt_lfa1 TYPE TABLE OF lfa1,
gt_kna1 TYPE TABLE OF kna1,
gt_konzs TYPE TABLE OF ys_konzs_int WITH HEADER LINE,
gs_konzs TYPE ys_konzs_int,
gs_lfa1 TYPE lfa1,
gs_kna1 TYPE kna1,
tmp_konzs TYPE i.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: so_konzs FOR lfa1-konzs MATCHCODE OBJECT zshfi_konzs.
SELECTION-SCREEN: END OF BLOCK b1.
IF NOT so_konzs IS INITIAL.
SELECT *
INTO TABLE gt_lfa1
FROM lfa1
WHERE konzs IN so_konzs.
SELECT *
INTO TABLE gt_kna1
FROM kna1
WHERE konzs IN so_konzs.
gt_konzs-low = so_konzs-low.
gt_konzs-high = so_konzs-high.
APPEND gt_konzs.
LOOP AT gt_lfa1 INTO gs_lfa1.
tmp_konzs = gs_lfa1-konzs.
IF tmp_konzs NOT BETWEEN gt_konzs-low AND gt_konzs-high.
DELETE gt_lfa1 INDEX sy-tabix.
ENDIF.
ENDLOOP.
LOOP AT gt_kna1 INTO gs_kna1.
tmp_konzs = gs_kna1-konzs.
IF tmp_konzs NOT BETWEEN gt_konzs-low AND gt_konzs-high.
DELETE gt_kna1 INDEX sy-tabix.
ENDIF.
ENDLOOP.
ENDIF.
As I had answered to friend Alejandro Alvarez, I am seeing the output in debug mode, and now I can find the correct values​​.
Thanks to all for the help.