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: 

Can not select data from COPA Internal Table

former_member294408
Participant
0 Kudos

Dear All ,

     I'm beginner in ABAP Field and need a help from you , Can any one give me a reason why when I make select statement for internal it doesn't return any data ? For example there isn't any data from COPA internal table " CE1FRAG " , I'm  typing the following Code :

DATA: BEGIN OF itab01 OCCURS 0,

         Company_Code   LIKE CE1FRAG-BUKRS,

         Controlling_Area    LIKE CE1FRAG-KOKRS,

         Sales_Organization   LIKE CE1FRAG-VKORG,

         Sales_Office     LIKE CE1FRAG-VKBUR,

         Sales_Group       LIKE CE1FRAG-VKGRP,

         Sales_Revenuee      LIKE CE1FRAG-VVR01,

END OF itab01.

Select * from CE1FRAG

   where   BELNR eq '14148024'. " Valid Document number


   MOVE CE1FRAG-BUKRS   TO itab01-Company_Code.

   MOVE CE1FRAG-KOKRS    TO itab01-Controlling_Area.

   MOVE CE1FRAG-VKORG   TO itab01-Sales_Organization.

   MOVE CE1FRAG-VKBUR      TO itab01-Sales_Office.

   MOVE CE1FRAG-VKGRP        TO itab01-Sales_Group.

   MOVE CE1FRAG-VVR01        TO itab01-Sales_Revenuee.

   APPEND itab01.

ENDSELECT.

LOOP AT itab01.

   WRITE: / itab01-Company_Code, itab01-Controlling_Area,itab01-Sales_Organization,itab01-Sales_Office, itab01-Sales_Group,itab01-Sales_Revenuee.

ENDLOOP.



It doesn't get any data or we can say it doesn't execute SELECT Statement , So any one can help me on it .



Thanks , 





1 ACCEPTED SOLUTION

former_member294408
Participant
0 Kudos

Dear All ,

Thanks a lot for yours answer it is very helpful , I found the reason of it like at the following code

data: i_input like  CE1FRAG-BELNR ,

i_output  like  CE1FRAG-BELNR  .

i_input  = '14148024'.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'

            exporting

                 input  = i_input

            importing

                 output = i_output

            exceptions

                 others = 1.

*Internal Table with Header line

TYPES: BEGIN OF struc01 ,

         Company_Code   TYPE CE1FRAG-BUKRS,

         Controlling_Area    TYPE CE1FRAG-KOKRS,

         Sales_Organization  TYPE CE1FRAG-VKORG,

         Sales_Office     TYPE CE1FRAG-VKBUR,

         Sales_Group      TYPE CE1FRAG-VKGRP,

         Sales_Revenuee     TYPE CE1FRAG-VVR01,

END OF struc01.

data: itab01 type STANDARD TABLE OF struc01 .

  data  wa TYPE struc01.

Select BUKRS KOKRS VKORG VKBUR VKGRP VVR01 from CE1FRAG into TABLE itab01

   where BELNR eq i_output.

8 REPLIES 8

Former Member
0 Kudos

if you are confident that 14148024 is in CE1FRAG table, then do conversion first for that value.

Try using : CONVERSION_EXIT_ALPHA_INPUT for you document number.

former_member197916
Active Participant
0 Kudos

hi,

if you have declared itab01 as internal table(and work area) then use

Select  from CE1FRAG into table itab01

   where   BELNR eq '14148024'.


debug the code to check whats actually happening


hope it helps

0 Kudos

^ its assuming CE1FRAG is declared as tables

0 Kudos

hi,

if you are trying to select from internal table then it is not possibe as it a database operation and works only on db tables.If you want to access an internal table use read or loop statements

0 Kudos

hi amr,

Add leading zero to BELNR no in where condition., means  14148024 should be 0014148024 .

Correct would be:

Types: BEGIN OF ty_table,

         Company_Code   LIKE CE1FRAG-BUKRS,

         Controlling_Area    LIKE CE1FRAG-KOKRS,

         Sales_Organization   LIKE CE1FRAG-VKORG,

         Sales_Office     LIKE CE1FRAG-VKBUR,

         Sales_Group       LIKE CE1FRAG-VKGRP,

         Sales_Revenuee      LIKE CE1FRAG-VVR01,

END OF ty_table.

data: itab01 type table of ty_table,

        wa like line of itab01.

Select * from CE1FRAG into table itab01

   where   BELNR eq '0014148024'. " Valid Document number


loop at itab01 into wa.

   WRITE: / wa-Company_Code,wa-Controlling_Area,wa-Sales_Organization,wa-Sales_Office, wa-Sales_Group,wa-Sales_Revenuee.

ENDLOOP.

sinagam,

Former Member
0 Kudos

Hi amr tabl,

In your code you have to do four  things to know about execution of select query.

1.use sy-subrc below select query.

2.use sy-dbcnt below select query.

3.use describe lines for internal table

4.use conversion routine for document number.

use the following code.

the following code will help you.

copy and paste in se38.

___________________________________________________________________

DATA: BEGIN OF itab01 OCCURS 0,

          Company_Code   LIKE CE1FRAG-BUKRS,

          Controlling_Area    LIKE CE1FRAG-KOKRS,

          Sales_Organization   LIKE CE1FRAG-VKORG,

          Sales_Office     LIKE CE1FRAG-VKBUR,

          Sales_Group       LIKE CE1FRAG-VKGRP,

          Sales_Revenuee      LIKE CE1FRAG-VVR01,

END OF itab01.

data i type i.

data belnr type belnr_d VALUE '14148024'.

 

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'  " convert your input value to sap standard value

    EXPORTING

      input         = belnr

   IMPORTING

     OUTPUT        = belnr.

Select * from CE1FRAG into table itab01

    where   BELNR eq belnr. " Valid Document number

  if sy-subrc eq 0."used to check status of select query

message  'quey execute' type 'I'.

message 'values fetched' with sy-dbcnt."give you no.of records selected from database

else.

message : 'data fetched is incorrect' type 'W'.

endif.

describe table itab01 lines i."tell you no of records in your internal table

write : 'number of lines',i.

LOOP AT itab01.

    WRITE: / itab01-Company_Code, itab01-Controlling_Area,itab01-Sales_Organization,itab01-Sales_Office, itab01-Sales_Group,itab01-Sales_Revenuee.

ENDLOOP.

Clemenss
Active Contributor
0 Kudos

Hi AMR TABL,

enter the BELNR via parameter or select-options. This will do the input conversion for you. As the others already noted: BELNR may refer to data type BELNR_D which is based on domain BELNR. This is a 10 characater field with conversion exit ALPHA. So any BELNR eq must compare to 10 characters, if numeric then preceded by zeroes,

And then, pleas close the thread.

Regards Clemens

former_member294408
Participant
0 Kudos

Dear All ,

Thanks a lot for yours answer it is very helpful , I found the reason of it like at the following code

data: i_input like  CE1FRAG-BELNR ,

i_output  like  CE1FRAG-BELNR  .

i_input  = '14148024'.

  call function 'CONVERSION_EXIT_ALPHA_INPUT'

            exporting

                 input  = i_input

            importing

                 output = i_output

            exceptions

                 others = 1.

*Internal Table with Header line

TYPES: BEGIN OF struc01 ,

         Company_Code   TYPE CE1FRAG-BUKRS,

         Controlling_Area    TYPE CE1FRAG-KOKRS,

         Sales_Organization  TYPE CE1FRAG-VKORG,

         Sales_Office     TYPE CE1FRAG-VKBUR,

         Sales_Group      TYPE CE1FRAG-VKGRP,

         Sales_Revenuee     TYPE CE1FRAG-VVR01,

END OF struc01.

data: itab01 type STANDARD TABLE OF struc01 .

  data  wa TYPE struc01.

Select BUKRS KOKRS VKORG VKBUR VKGRP VVR01 from CE1FRAG into TABLE itab01

   where BELNR eq i_output.