on 05-16-2011 8:32 AM
Hi all,
I am using one FM in my application, at one place i am reading table using sy-tabix. But it is showing 0 even table contains values.
In some other place in this code tabix is working. perticular in that place it is not working.
And i check this by executing se37 there it is working fine...
Here the code..
SELECT vbeln vkorg vtweg kunnr spart FROM vbak INTO TABLE it_vbak
where vbeln in s_vbeln.
IF it_vbak[] IS NOT INITIAL.
SELECT kunnr "Customer Number 1
adrnr "Address
FROM kna1 INTO CORRESPONDING FIELDS OF TABLE it_kna1
FOR ALL ENTRIES IN it_vbak
WHERE kunnr = it_vbak-kunnr.
//Here sy-tabix always showing 0.
READ TABLE it_kna1 INTO wa_kna1 INDEX sy-tabix.
IF sy-subrc = 0.
gv_kunnr = wa_kna1-kunnr.
ENDIF.
In some other place it is working...
SELECT lifnr "ACCOUNT NUMBER OF VENDOR OR CREDITOR
adrnr "ADDRESS
FROM lfa1
INTO CORRESPONDING FIELDS OF TABLE it_lfa1
FOR ALL ENTRIES IN it_knvp
WHERE lifnr = it_knvp-lifnr.
ENDIF.
READ TABLE it_lfa1 INTO wa_lfa1 INDEX sy-tabix. // Here it is working.
IF sy-subrc = 0.
gv_lifnr = wa_lfa1-lifnr.
ENDIF.
Can anyone give me any suggetions.. i think code is correct, any fault is there...
Tahnks,
Venkat.
is there any difference in the declaration of the two internal tables that you have pointed out in examples.
also sy-tabix is 0 for hashed tables.
only works for index tables.
and to set the value of sy-tablix you need to first do some operation on the table
like append collect loop or read using some fixed value.
otherwise it will point to zero only.
are you sure it is working fine in SE37.
thanks
sarbjeet singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I Think you are reading based on kunnr you can use index also.
Check This..
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm
Cheers,
Kris.
Venkat,
There are two selects, 1 from KNa1 and other from LFA1 and a read statement after each select.
For your first select, your sy-tabix will always be 0. Sy-tabix will be filled with Loop or read. Now when execution reaches your second statement of read, the sy-tabix is already filled by the first read.
So, two things: 1. Always use debugging, 2. please explore yourself first on these issues. You can use sy-dbcnt which fills with the total number of records returned.
Regards,
Santosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.