2012 Mar 14 1:38 PM
Hi Experts,
I am getting error as below:
Error when inserting or changing in a sorted table.
A line is to be inserted or changed at position 3 in the sorted
internal table (type SORTED_TABLE)
"\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER".
In doing so, the sorting sequence - determined by the table key - was
Error Program is as follow:
693 CLEAR r_final1.
694 REFRESH: i_final1, i_sum.
695
696 r_final1-bukrs = r_bkpf-bukrs. "Company code
697 r_final1-belnr = r_bkpf-belnr. "Accounting Document Number
698 r_final1-gjahr = r_bkpf-gjahr. "Fiscal Year
699 r_final1-usnam = r_bkpf-usnam. "User Name
700 r_final1-budat = r_bkpf-budat. "Posting date "+RT25298
701 r_final1-cpudt = r_bkpf-cpudt. "Accounting Document Entry Date
702 r_final1-bldat = r_bkpf-bldat. "Document Date in Document
703
704 * Get the user name.
705 CLEAR r_user.
706 READ TABLE i_user INTO r_user WITH KEY usnam = r_bkpf-usnam.
707
708 IF sy-subrc NE 0.
709 * Look up the user name that goes with ID
710 CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
711 EXPORTING
712 user_name = r_final1-usnam
713 IMPORTING
714 user_usr03 = r_user_usr03
715 EXCEPTIONS
716 user_address_not_found = 1
717 OTHERS = 2.
718
719 IF sy-subrc = 0.
720 r_user-usnam = r_bkpf-usnam.
721 CONCATENATE r_user_usr03-name1 r_user_usr03-name2
722 INTO r_user-name SEPARATED BY space.
>>>> INSERT r_user INTO i_user INDEX sy-tabix.
724 ENDIF.
725 ENDIF.
726
727 * Assign User Name into dummy final table
728 r_final1-name1 = r_user-name.
729
730 CLEAR : r_bseg.
731 * Process the line items for the document
732 LOOP AT i_bseg INTO r_bseg
733 WHERE bukrs = r_bkpf-bukrs
734 AND belnr = r_bkpf-belnr
735 AND gjahr = r_bkpf-gjahr.
736
737 * Move fields to output
738 r_final1-hkont = r_bseg-hkont. "General Ledger Account
Please provide me with a solution.
Thanks in Advance.
Regards,
Vikas.
2012 Mar 15 7:03 AM
Hi,
Use the statement "INSERT r_user INTO TABLE i_user." In your Insert statement TABLE is missing.
Thanks and Regards
Bala Krishna
2012 Mar 14 11:04 PM
Moved to the ABAP Development space, where Discussions/Forums about ABAP are located.
Audrey, SCN Team
2012 Mar 14 11:37 PM
Hi,
where to discuss the new SCN surface?
- need Style ABAP code
- need setting for line space
- need help features
Regards Clemens
2012 Mar 14 11:32 PM
Hi,
INSERT r_user INTO TABLE i_user. "No index - sorted means always in sorted order
READ TABLE i_user INTO r_user WITH TABLE KEY usnam = r_bkpf-usnam."increase speed using index
Regards
Clemens
2012 Mar 15 6:41 AM
Thanks for the efforts...but this solution is not working.Am getting another dump.i had updated it down the discussion
2012 Mar 14 11:35 PM
If I_USER is defined as a sorted table, then a non-catchable exception will occur if a line to be inserted would disrupt the sort order of the table. I suppose this is what happens here. So the program must be changed to insert the new entry at the correct position according to the sort order.
2012 Mar 14 11:57 PM
Clemens has provided the solution. Basically your statement:
INSERT r_user INTO i_user INDEX sy-tabix.
is trying to put an entry into position 3(sy-tabix must have a value of 3) but in doing this it will then contradict the sort order you have got in the definition of i_user.
Changing the insert to:
INSERT r_user INTO i_user INDEX.
will let the sytem determine where the new entry goes.
2012 Mar 15 4:40 AM
Hi,
For Sorted Tables no need to specify Index Number , as the new record will be inserted at corresponding location based on its content because inserting a new record will change Sort Sequence,
Regards,
Ravindra.
2012 Mar 15 6:35 AM
Hi,
As Clemens, Neil and Chundru had said, you must not use index for a sorted table unless you are sure the index position which you are giving will not affect the order of the sorted table.
Regards,
Josh
2012 Mar 15 6:45 AM
Am still getting a new error as follow after changing my stmt to
INSERT r_user INTO i_user.
the error is as follow:
You attempted to change, delete or create a row in the
internal table "\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER", but no
valid cursor exists
for the table.
Error in an ABAP/4 statement when processing an internal table.
Possible reasons:
1. The relevent ABAP language command does not include the addition
"...INDEX...", although the statement is not
inside a "LOOP...ENDLOOP" loop processing this table.
2. In the body of a loop started with "LOOP ... USING KEY ...", an ABAP
statement has been issued with an implicit index specification. This
is only permitted in connection with the "USING KEY loop_key"
addition and applies to the "DELETE itab" and "MODIFY itab"
statements.
3. The relevent ABAP language command statement was called from within a
"LOOP...ENDLOOP" loop after a DELETE
"\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER".
2012 Mar 15 6:45 AM
Am still getting a new error as follow after changing my stmt to
INSERT r_user INTO i_user.
the error is as follow:
You attempted to change, delete or create a row in the
internal table "\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER", but no
valid cursor exists
for the table.
Error in an ABAP/4 statement when processing an internal table.
Possible reasons:
1. The relevent ABAP language command does not include the addition
"...INDEX...", although the statement is not
inside a "LOOP...ENDLOOP" loop processing this table.
2. In the body of a loop started with "LOOP ... USING KEY ...", an ABAP
statement has been issued with an implicit index specification. This
is only permitted in connection with the "USING KEY loop_key"
addition and applies to the "DELETE itab" and "MODIFY itab"
statements.
3. The relevent ABAP language command statement was called from within a
"LOOP...ENDLOOP" loop after a DELETE
"\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER".
2012 Mar 15 6:39 AM
Am still getting a new error as follow after changing my stmt to
INSERT r_user INTO i_user.
the error is as follow:
You attempted to change, delete or create a row in the
internal table "\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER", but no
valid cursor exists
for the table.
Error in an ABAP/4 statement when processing an internal table.
Possible reasons:
1. The relevent ABAP language command does not include the addition
"...INDEX...", although the statement is not
inside a "LOOP...ENDLOOP" loop processing this table.
2. In the body of a loop started with "LOOP ... USING KEY ...", an ABAP
statement has been issued with an implicit index specification. This
is only permitted in connection with the "USING KEY loop_key"
addition and applies to the "DELETE itab" and "MODIFY itab"
statements.
3. The relevent ABAP language command statement was called from within a
"LOOP...ENDLOOP" loop after a DELETE
"\PROGRAM=ZGLFINGLRX_MANUAL_JOURNALAUDIT\DATA=I_USER".
2012 Mar 15 6:51 AM
If you have declared the table with unique key then, may be its trying to insert a record with same key value.
2012 Mar 15 7:03 AM
Hi,
Use the statement "INSERT r_user INTO TABLE i_user." In your Insert statement TABLE is missing.
Thanks and Regards
Bala Krishna
2012 Mar 15 8:04 AM
Bala Krishna is right. Insert statement syntax is wrong, Table keyword missing.
2012 Mar 15 10:07 AM
Hi,
Its working.Thanks a lot for your valuable contribution ..
2012 Mar 15 11:16 AM
Hi vikas,
all readers are happy, if you
- let us know the solution that worked for you
- close the thread as "solved"
- mark answers as helpful/solved
Regards
Clemens
2012 Mar 15 8:57 AM
Hi Vikas,
Just check you SY-TABIX value when you are inserting record into the table. You read an internal table after that calling a function module , then concatenating values, and then finally inserting record. In between think that sy-index is getting changed to a number that is beyond the number of records into the internal table.
Try to get SY-TABIX into a local variable just after you read the table, after that use that local variable as an index value while inserting record.
Please check this and let me know if it works.
2012 Mar 15 11:55 AM
Use append to add to a sorted table. SAP will put the record into the correct sequence.