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

for all entries

Former Member
0 Likes
1,254

send me sample code : for all entries with report prgograms

send me sample code : for all entries with report prgograms

8 REPLIES 8
Read only

Former Member
0 Likes
1,220

SELECT connid
FROM spfli
FOR ALL ENTRIES IN gt_scarr
WHERE carrid = gt_scarr-carrid.
Read only

Former Member
0 Likes
1,220

Hi,

Check this code how to use for all entries in select.

FORM get_data.

  • select Purchase doc for Order type 'NB', 'ZLP', 'UB'. Stock

*transfers are considered only for supplying plant P194 (port

*Plant)

select ekkobedat ekkolifnr ekkoknumv ekkobsart

ekko~waers

ekpoebeln ekpoebelp ekpo~matnr

ekpotxz01 ekpomenge ekpobprme ekpowerks

  • added by SS04

ekpo~meins

  • end of addition

into corresponding fields of table t_podata

from ekko inner join ekpo

on ekpoebeln = ekkoebeln

where ekko~bukrs = p_bukrs

and ( ekko~bsart = c_nb

or ekko~bsart = c_zlp

  • or ( ekkobsart = c_ub and ekkoreswk = p_reswk ) )

"UK001-

or ( ekkobsart = c_ub and ekkoreswk in s_reswk ) )

"UK001+

and ekko~ebeln in s_ebeln

and ekko~bedat in s_bedat

and ekko~loekz = space

and ekpo~werks in s_werks.

  • added by SSHAH on 12/3/2003

perform find_original_po.

  • end of addition

if not t_podata[] is initial.

  • Vendor master

select lifnr land1 name1 ort01

into table t_lfa1

from lfa1

for all entries in t_podata

where lifnr = t_podata-lifnr.

  • PO History

select * from ekbe

into table t_ekbe

for all entries in t_podata

where ebeln = t_podata-ebeln

and ebelp = t_podata-ebelp

and vgabe = '2'.

  • PO History - delivery costs

select * from ekbz

into table t_ekbz

for all entries in t_podata

where ebeln = t_podata-ebeln

and ebelp = t_podata-ebelp

and vgabe = '2'.

  • PO History for GRN data

select ebeln ebelp belnr budat from ekbe

into table t_grdata

for all entries in t_podata

where ebeln = t_podata-ebeln

and ebelp = t_podata-ebelp

and vgabe = '1'.

Reward if useful.

Regards,

Narasimha

Read only

Former Member
0 Likes
1,220

hi,

SELECT * FROM sflight INTO wa_sflight

FOR ALL ENTRIES IN ftab

WHERE CARRID = ftab-carrid AND

CONNID = ftab-connid AND

fldate = '20010228'.

this condition, return all entries of the sflight

Read only

Former Member
0 Likes
1,220

hi

check this sample code

select * into table tvbrk from vbrk

where fkart in ('F2', 'F3', 'RE',

'ZVEC' , 'ZVEM' , 'ZVED',

'S1')

and erdat in so_erdat

and kunag in s_kunag. "Added on 25.11.03

. erdat in so_erdat

and fkart in ('F2', 'F3', 'RE',

'ZVEC' , 'ZVEM' ,'ZVED')

FOR ALL ENTRIES

if s_regio ne space.

select * into table t_zregion from zregion

for all entries in tvbrk

where country = tvbrk-land1

and region = s_regio.

endif

Thanks

sitaram

Read only

Former Member
0 Likes
1,220

Suppose u want data from two tables EKKO and EKPO. based on data gathered in EKKO u want to fetch data in EKPO.

In that case the select query will be as follows:

select ebeln blart ....

from ekko

into corresponding fields of table it_ekko

where aedat in p_date.

if not it_ekko is initial.

select *

from ekpo

into table it_ekpo

FOR ALL ENTRIES IN it_ekko

where ebeln = it_ekko-ebeln.

I hope this solves your problem.

please award points if u find this helpful.

Read only

Former Member
0 Likes
1,220

Before taking up some code Bhuvanesran, please do try to understand that why is FOR ALL ENTRIES used for.

JOINS in SELECT statements in ABAP is considered to be highly performance degrading. So an alternative to using JOINS in ABAP to fetch data in an internal table in ABAP is using FOR ALL ENTRIES.

Consider a case where you are joining two tables which will have a common key. say EKKO and EKPO.

Now instead of that, there will be two steps involved in FOR ALL ENTRIES.

You will have two internal tables.

You will select into first internal table. Now putting data into second internal table you will use FOR ALL ENTRIES based on the key of the first internal table (say DDIC table also). This will increase your performance a lot compared to joins and you will clearer understanding of what data is selected by you into the internal tables rather than using JOINS.

Reward If Useful.

Regards,

Yogesh Bhatia

Read only

Former Member
0 Likes
1,220

Hi,

Heres a sample code............

REPORT Z94406_ALV_NEW .

TABLES: ekko,ekpo,lfa1.

TYPE-POOLS slis.

DATA: t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA: wa_variant LIKE disvariant.

DATA: wa_keyinfo TYPE slis_keyinfo_alv.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: pur FOR ekko-ekorg OBLIGATORY,

ord1 FOR ekko-ebeln,

date1 FOR ekko-aedat OBLIGATORY.

PARAMETERS: list RADIOBUTTON GROUP grp1,

grid RADIOBUTTON GROUP grp1,

hier RADIOBUTTON GROUP grp1.

SELECTION-SCREEN END OF BLOCK b1.

DATA: BEGIN OF itab_ekko occurs 10,

ord LIKE ekko-ebeln,

org LIKE ekko-ekorg,

dat LIKE ekko-aedat,

ven LIKE ekko-lifnr,

END OF itab_ekko.

DATA: BEGIN OF itab_ekpo OCCURS 0,

doc LIKE ekpo-ebeln,

itm LIKE ekpo-ebelp,

mat LIKE ekpo-matnr,

plt LIKE ekpo-werks,

txt LIKE ekpo-txz01,

qty LIKE ekpo-menge,

END OF itab_ekpo.

DATA: BEGIN OF t_output OCCURS 0,

c1 LIKE ekko-ebeln,

c2 LIKE ekko-ekorg,

c3 LIKE ekko-aedat,

c4 LIKE ekko-lifnr,

c5 LIKE ekpo-ebelp,

c6 LIKE ekpo-werks,

c7 LIKE ekpo-txz01,

c8 LIKE ekpo-matnr,

c9 LIKE ekpo-menge,

END OF t_output.

SELECT ebeln ekorg aedat lifnr

FROM ekko

INTO TABLE itab_ekko

WHERE ebeln IN ord1

AND ekorg IN pur

AND aedat IN date1.

write sy-dbcnt.

SELECT ebeln ebelp werks

txz01 matnr menge

FROM ekpo

INTO TABLE itab_ekpo

FOR ALL ENTRIES IN itab_ekko

WHERE ebeln = itab_ekko-ord.

write sy-dbcnt.

LOOP AT itab_ekpo.

--


MOVING THE DATA TO O/P TABLE--

MOVE: itab_ekpo-itm TO t_output-c5,

itab_ekpo-plt TO t_output-c6,

itab_ekpo-txt TO t_output-c7,

itab_ekpo-mat TO t_output-c8,

itab_ekpo-qty TO t_output-c9.

CLEAR itab_ekko.

READ TABLE itab_ekko WITH KEY ord = itab_ekpo-doc.

IF sy-subrc = 0.

MOVE : itab_ekko-ord TO t_output-c1,

itab_ekko-org TO t_output-c2,

itab_ekko-dat TO t_output-c3,

itab_ekko-ven TO t_output-c4.

ENDIF.

APPEND t_output.

CLEAR t_output.

ENDLOOP.

END-OF-SELECTION.

IF list = 'X'.

PERFORM create_fieldcatalog.

PERFORM list_display.

.

ELSEIF grid = 'X'.

PERFORM create_fieldcatalog.

PERFORM grid_output.

ELSE.

PERFORM build_fieldcatalog.

PERFORM build_fieldcatalog2.

PERFORM hierarchical_display.

ENDIF.

----


form create_fieldcatalog .

--


CALLING THE FUNCTION--

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'T_OUTPUT'

i_inclname = sy-repid

CHANGING

ct_fieldcat = t_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " create_fieldcatalog

form list_display .

--


CALLING THE FUNCTION--

--


FOR LIST DISPLAY--

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = t_fieldcat[]

TABLES

t_outtab = t_output

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " list_display

form grid_output .

--


CALLING THE FUNCTION--

--


FOR GRID DISPLAY--

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = t_fieldcat[]

i_save = 'X'

is_variant = wa_variant

TABLES

t_outtab = t_output

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " grid_output

form hierarchical_display .

wa_keyinfo-header01 = 'ORD'.

wa_keyinfo-item01 = 'DOC'.

--


CALLING THE FUNCTION--

--


FOR HIERARCHICAL DISPLAY--

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

it_fieldcat = t_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = 'itab_ekko'

i_tabname_item = 'itab_ekpo'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = wa_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab_header = itab_ekko[]

t_outtab_item = itab_ekpo[]

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " hierarchical_display

*&----


*

*& Form build_fieldcatalog

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form build_fieldcatalog .

--


CALLING THE FUNCTION--

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'itab_ekko'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = sy-repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = t_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " build_fieldcatalog

*&----


*

*& Form build_fieldcatalog2

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form build_fieldcatalog2 .

--


CALLING THE FUNCTION--

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'itab_ekpo'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = sy-repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = t_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endform. " build_fieldcatalog2

***********************************************

Reward if helpful.

Regards,

Syed

Read only

Former Member
0 Likes
1,220

Data : itab1 type table of kna1,

itab2 type table of vbak.

select-options : s_kuunr for kna1-kunnr.

select kunnr name1 from kna1 into table itab1 where kunnr in s_kunnr.

select kunnr vbeln from vbak into table itab2 for all entries in itab1 where kunnr = itab1-kunnr.

Try this.

if it helps reward me with points.

Naveen.