Application Development and Automation 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: 
Read only

Select Details

Former Member
0 Likes
539

Hi Guru's,

Select query is how many type , type wise example.

it's needed.

Regards,

S.Hari

3 REPLIES 3
Read only

Former Member
0 Likes
459

Hi hari,

The select command is the most fundamental function of writing ABAP programs allowing the retrieval of

data from SAP database tables. The most efficient use of the select statement is to retrieve data directly into an internal table, Below

is an example of how this would be performed.

REPORT  ZSELECTCOMMAND.
*Code to demonstrate select into internal table command
data: it_ekko type STANDARD TABLE OF ekko,
      wa_ekko like line of it_ekko,
      it_ekpo type standard table of ekpo,
      wa_ekpo like line of it_ekpo.

*Select directly into an internal table
SELECT *  "all fields
  FROM ekko
  INTO TABLE it_ekko.
write:/ 'SELECT directly into an internal table'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.

Select-End Select Command.

REPORT ZSELECTCOMMAND.

data: it_ekko type STANDARD TABLE OF ekko,
      wa_ekko like line of it_ekko,
      it_ekpo type standard table of ekpo,
      wa_ekpo like line of it_ekpo.

SELECT ebeln BUKRS BSTYP BSART
  FROM ekko
  INTO wa_ekko.

  APPEND wa_ekko TO it_ekko.
ENDSELECT.
write:/ 'SELECT... endselect command'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.

SELECT directly into an internal table when field order is different

REPORT  ZSELECTCOMMAND.
*Code to demonstrate select into internal table command
data: it_ekko type STANDARD TABLE OF ekko,
      wa_ekko like line of it_ekko,
      it_ekpo type standard table of ekpo,
      wa_ekpo like line of it_ekpo.

*Select directly into an internal table
* Please note the order of these field are not different but you can still see the code 
* that would perform this functionality if they were!
SELECT *  "all fields
  FROM ekko
  INTO TABLE it_ekko.
write:/ 'SELECT directly into an internal table'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.

SELECT for all entries command

data: it_ekko type STANDARD TABLE OF ekko,
      wa_ekko like line of it_ekko,
      it_ekpo type standard table of ekpo,
      wa_ekpo like line of it_ekpo.

SELECT *
  UP TO 100 ROWS  "only return first 100 hits
  FROM ekko
  INTO TABLE it_ekko
 where ebeln = '0000154421'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.

IF sy-subrc EQ 0.
* The FOR ALL ENTRIES comand only retrieves data which matches
* entries within a particular internal table.
  SELECT *
    FROM ekpo
    INTO TABLE it_ekpo
    FOR ALL ENTRIES IN it_ekko
    WHERE ebeln EQ it_ekko-ebeln.
  write:/ 'FOR ALL ENTRIES comand '.
  loop at it_ekpo into wa_ekpo.
    write:/ wa_ekpo-ebeln, wa_ekpo-ebelp.
  endloop.
ENDIF.

Pls reward if useful.

Thanks,

Sirisha.

Read only

Former Member
0 Likes
459

Please have a look at below link.

[Select Statement|http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/frameset.htm]

I hope it gives all the details you are looking for.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member
0 Likes
459

Hi,

Check This Link for Select Details

http://help.sap.com/saphelp_nw04/helpdata/en/af/a16c3c50ac854ce10000000a11405a/frameset.htm

Reward Points if Usefull

Regards

Fareedas