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

Syntax SQL

Former Member
0 Likes
940

Hi

Simple request.

I want to write a program, ie

SELECT * FROM tbl1

OUTPUT TO SCREEN.

What is the ABAP syntax.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
914

Hi Abu,

SELECT * 
  FROM table1
  INTO TABLE itab.

LOOP AT itab.
  write:
    / 'Field 1 : ', itab-field1,
      'Field 2 : ', itab-field2,
      'Field 3 : ', itab-field3.
ENDLOOP.

Regards,

Sunil

9 REPLIES 9
Read only

Former Member
0 Likes
915

Hi Abu,

SELECT * 
  FROM table1
  INTO TABLE itab.

LOOP AT itab.
  write:
    / 'Field 1 : ', itab-field1,
      'Field 2 : ', itab-field2,
      'Field 3 : ', itab-field3.
ENDLOOP.

Regards,

Sunil

Read only

0 Likes
914

whats the syntax for declaring itab.

Thanks

Read only

0 Likes
914

I wrote this:

DATA:

itab TYPE STANDARD TABLE OF HRHAP,

wa_hap type itab.

SELECT *

FROM HRHAP

INTO TABLE itab.

LOOP AT itab INTO wa_hap.

write:

/ 'Field 1 : ', wa_hap-APPRAISAL_ID,

'Field 2 : ', wa_hap-AP_START_DATE,

'Field 3 : ', wa_hap-AP_END_DATE,

'Field 2 : ', wa_hap-AP_STATUS,

'Field 3 : ', wa_hap-AP_STATUS_SUB,

'Field 2 : ', wa_hap-AP_OBJ_DATE_SET.

ENDLOOP.

Error: The data object WA_HAP does not have a component called 'APPRAISAL_ID'.

APPRAISAL_ID is a component of HRHAP.

Thanks

Read only

0 Likes
914

hi check this...

tables : hrhap .

DATA:

itab TYPE STANDARD TABLE OF HRHAP with header line,

wa_hap type hrhap.

SELECT *

FROM HRHAP

INTO TABLE itab.

LOOP AT itab into wa_hap .

write:

/ 'Field 1 : ', wa_hap-APPRAISAL_ID,

'Field 2 : ', wa_hap-AP_START_DATE,

'Field 3 : ', wa_hap-AP_END_DATE,

'Field 4: ', wa_hap-AP_STATUS,

'Field 5 : ', wa_hap-AP_STATUS_SUB,

'Field 6 : ', wa_hap-OBJ_DATE_SET.

ENDLOOP.

regards,

venkat

Read only

Former Member
0 Likes
914

hi,


 SELECT * FROM tbl1 into table itab where <conditions>.
 if sy-subrc = 0.
 endif.

 loop at itab.
    write: itab-fld1,
            itab-fld2,
............. 
 endloop. 

Read only

0 Likes
914

hi,

data : itab type standard table of tbl1.

Read only

Former Member
0 Likes
914

Hi Abu,

The Syntax for declaring itab is;

DATA:
  BEGIN OF itab OCCURS 0,
     Field1      TYPE i,
     Field2(10) TYPE c,
     Field3(5)   TYPE n,  
  END OF itab.

or

DATA:
     itab TYPE TABLE OF table1.

Regards,

Sunil

Read only

Former Member
0 Likes
914

Hi,

  • types declaration

types: begin of ty_mara,

matnr type mara-matnr,

mbrsh type mara-mbrsh,

end of ty_mara.

*data declaration

data : it_mara type table of ty_mara, "body

wa_mara type ty_mara. " workarea

start-of-selection.

SELECT matnr mbrsh

FROM mara

INTO TABLE it_mara.

end-of-selection.

LOOP AT it_mara into wa_mara.

write:

/ 'Matnr : ', wa_mara-matnr,

'Mbrsh : ', wa_mara-mbrsh.

ENDLOOP.

Reward points if helpful.

thanks and regards.

Read only

Former Member
0 Likes
914

hi check this..

tables: mara .

data: itab like mara occurs 0 with header line .

select * from mara into table itab .

if sy-subrc = 0.

loop at itab .

write:/ itab-matnr ,

itab-meins,

itab-mtart .

endloop.

endif.

regards,

venkat.