Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with select sentence to remove "into corresponding fields" and "select/endselect"

Former Member
0 Kudos

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!!

5 REPLIES 5

jitendra_it
Active Contributor
0 Kudos

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.

0 Kudos

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,

0 Kudos

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.

0 Kudos

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!


0 Kudos

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.