07-30-2014 9:02 AM
Good morning,
we have had to copy the code of cji3 transaction due to a request from our internal customer. We use some rules which do not permit us to develop a program using "into corresponding field" and "select/endselect" structure in selection senteces. The problem is that I do not find the way to change the following select in order to respect the rules:
SELECT (VT_FIELDS) INTO CORRESPONDING FIELDS OF GS_COVP_EXT
FROM (V_DB_TABLE)
WHERE LEDNR = '00'
AND OBJNR IN LR_OBJNR
AND GJAHR IN GR_GJAHR
AND VERSN IN GR_VERSN
AND WRTTP IN GR_WRTTP
AND KSTAR IN LR_KSTAR
AND PERIO IN GR_PERIO
AND BUDAT IN GR_BUDAT
AND PAROB IN GR_PAROB
AND (VT_VAR_COND).
CHECK GS_COVP_EXT-KOKRS = GD-KOKRS.
* optimization of cost element ranges
CHECK GS_COVP_EXT-KSTAR IN LR_KSTAR_OPT.
* delta version
REFRESH: LT_COSSA.
MOVE-CORRESPONDING GS_COVP_EXT TO LT_COSSA.
CALL FUNCTION 'K_DELTA_VERSNS_CHECK_ENTRY'
EXPORTING
DB_STRUCT = LT_COSSA
TABNAME = 'COSSA'
TABLES
DB_TABLE = LT_COSSA
EXCEPTIONS
OTHERS = 0.
LOOP AT LT_COSSA.
MOVE-CORRESPONDING LT_COSSA TO GS_COVP_EXT.
APPEND GS_COVP_EXT TO GT_COVP_EXT.
ENDLOOP.
* collect master keys into global tables
MOVE-CORRESPONDING GS_COVP_EXT TO LS_COVP.
PERFORM COLLECT_MASTER_KEYS_COVP USING LS_COVP.
PERFORM GUI_COUNTER TABLES GT_COVP_EXT
CHANGING LD_EXIT.
IF NOT LD_EXIT IS INITIAL.
EXIT.
ENDIF.
ENDSELECT.
I have tried with the following code but the result is a dump...
SELECT (VT_FIELDS) INTO TABLE GS_COVP_EXT
FROM (V_DB_TABLE)
WHERE LEDNR = '00'
AND OBJNR IN LR_OBJNR
AND GJAHR IN GR_GJAHR
AND VERSN IN GR_VERSN
AND WRTTP IN GR_WRTTP
AND KSTAR IN LR_KSTAR
AND PERIO IN GR_PERIO
AND BUDAT IN GR_BUDAT
AND PAROB IN GR_PAROB
AND (VT_VAR_COND).
IF SY-SUBRC = 0.
ENDIF.
LOOP AT GS_COVP_EXT.
CHECK GS_COVP_EXT-KOKRS = GD-KOKRS.
* optimization of cost element ranges
CHECK GS_COVP_EXT-KSTAR IN LR_KSTAR_OPT.
* delta version
REFRESH: LT_COSSA.
MOVE-CORRESPONDING GS_COVP_EXT TO LT_COSSA.
CALL FUNCTION 'K_DELTA_VERSNS_CHECK_ENTRY'
EXPORTING
DB_STRUCT = LT_COSSA
TABNAME = 'COSSA'
TABLES
DB_TABLE = LT_COSSA
EXCEPTIONS
OTHERS = 0.
LOOP AT LT_COSSA.
MOVE-CORRESPONDING LT_COSSA TO GS_COVP_EXT.
APPEND GS_COVP_EXT TO GT_COVP_EXT.
ENDLOOP.
* collect master keys into global tables
MOVE-CORRESPONDING GS_COVP_EXT TO LS_COVP.
PERFORM COLLECT_MASTER_KEYS_COVP USING LS_COVP.
PERFORM GUI_COUNTER TABLES GT_COVP_EXT
CHANGING LD_EXIT.
IF NOT LD_EXIT IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
Can anybody help me please??
Thanks!!
07-30-2014 11:06 AM
Hello Luis,
What dump you are getting ??
SELECT (VT_FIELDS) INTO TABLE GS_COVP_EXT
from above code it seems that number of dynamic columns can create a problem if they exceeds than columns defined in GS_COVP_EXT table OR their order is different from mentioned in defined table.
Also ,I would suggest do not use table with header line. It is obsolete.
Rather define a table and corresponding work area. It will be clear in understanding the code also.
07-30-2014 12:54 PM
Hello Jitendra,
first of all, thank you very much for your answer. On the other hand, this is the information shown by Dumo message.
Termination occurred in the ABAP program "SAPLZKAEP" - in "SELECT_COVP".
The main program was "ZRKPEP003 ".
In the source code you have the termination point in line 204
of the (Include) program "LZKAEPFSL".
The termination is caused because exception "CX_SY_OPEN_SQL_DB" occurred i
procedure "SELECT_COVP" "(FORM)", but it was neither handled locally nor
declared
in the RAISING clause of its signature.
The procedure is in program "SAPLZKAEP "; its source code begins in line
44 of the (Include program "LZKAEPFSL ".
I have checked the fields in (VT_FIELDS) and all of them are includen in GS_COVP_EXT. In addition, I have tried to do a selection using some fields included in (VT_FIELDS) and taking care about the order of these fields in table GS_COVP_EXT but the same Dump appears.
Thanks! Regards,
07-30-2014 1:41 PM
Hello,
Not able to conclude about cause with above information.
May be you can try with Try and Catch statements. In catch use method IF_MESSAGE~GET_TEXT
to get exception text.
Also,you can check "Source Code Extract & How to correct the error" section in ST22 to get more details.
07-31-2014 12:06 PM
Hello Jitendra!,
As you told me, the problem is with the order of the fields. I wil try to change the definition of internal table and try to define a dynamic internal table.
Thank you very much for your help!
08-04-2014 1:19 PM
Hello Luis,
You can try with creating dynamic table based on the columns supplied in VT_FIELDS using Run Time Type Services.
Check this link ABAP Keyword Documentation
Hope this helps you.