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: 

sample programs reports with for all entries

Former Member
0 Kudos

send me sample programs reports with for all entries

6 REPLIES 6

Former Member
0 Kudos

Hi,

Check this Program.

DATA: BEGIN OF line,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

END OF line,

itab LIKE TABLE OF line.

line-cityfrom = 'FRANKFURT'.

line-cityto = 'BERLIN'.

APPEND line TO itab.

line-cityfrom = 'NEW YORK'.

line-cityto = 'SAN FRANCISCO'.

APPEND line TO itab.

SELECT carrid connid cityfrom cityto

INTO CORRESPONDING FIELDS OF line

FROM spfli

FOR ALL ENTRIES IN itab

WHERE cityfrom = itab-cityfrom AND cityto = itab-cityto.

WRITE: / line-carrid, line-connid, line-cityfrom, line-cityto.

ENDSELECT.

Reward if useful.

Regards,

Narasimha

Former Member
0 Kudos

Hey...Look into this code.....

here for the reference INNERJOIN is there commented...u can compare both

tables: vbak, vbap.

select-options: s_vbeln for vbak-vbeln.

types:

begin of t_vbak,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of t_vbak,

begin of t_vbap,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

arktx type vbap-arktx,

matnr like vbap-matnr,

meins like vbap-meins,

end of t_vbap,

begin of lt_report,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

ernam type vbak-ernam,

netwr type vbak-netwr,

posnr like vbap-posnr,

arktx type vbap-arktx,

matnr like vbap-matnr,

meins like vbap-meins,

end of lt_report.

data:

li_vbak type t_vbak occurs 0 with header line,

li_vbap type t_vbap occurs 0 with header line,

t_report type lt_report occurs 0 with header line.

at selection-screen.

start-of-selection.

select vbeln erdat ernam netwr

from vbak

into table li_vbak where vbeln in s_vbeln.

if not li_vbak[] is initial.

sort li_vbak by vbeln.

DELETE ADJACENT DUPLICATES FROM li_vbak.

select vbeln posnr arktx matnr meins

from vbap

into table li_vbap

for all entries in li_vbak

where vbeln = li_vbak-vbeln.

endif.

+*select a~vbeln a~erdat a~ernam a~netwr+
+*       b~posnr b~arktx b~matnr b~meins+
+*       into table t_report+
+*       from vbak as a inner join vbap as b+
+*       on a~vbeln = b~vbeln+
+*       where a~vbeln in s_vbeln.+

loop at li_vbap.

t_report-vbeln = li_vbap-vbeln.

t_report-posnr = li_vbap-posnr.

t_report-arktx = li_vbap-arktx.

t_report-matnr = li_vbap-matnr.

t_report-meins = li_vbap-meins.

read table li_vbak with key vbeln = li_vbap-vbeln.

if sy-subrc = 0.

t_report-vbeln = li_vbak-vbeln.

t_report-erdat = li_vbak-erdat.

t_report-ernam = li_vbak-ernam.

t_report-netwr = li_vbak-netwr.

endif.

append t_report.

clear li_vbap.

endloop.

refresh: li_vbak, li_vbap.

sort t_report by vbeln.

DELETE ADJACENT DUPLICATES FROM t_report.

end-of-selection.

sort t_report by vbeln.

loop at t_report.

write: / t_report-vbeln, t_report-erdat, t_report-ernam,

t_report-netwr, t_report-posnr, t_report-arktx,

t_report-matnr, t_report-meins.

endloop.

Reward the helpful answers.

Thanks

Edited by: Sagar@MM on May 30, 2008 11:36 AM

Former Member
0 Kudos

check the theard for sample programs

https://forums.sdn.sap.com/click.jspa?searchID=12343845&messageID=3312694

Regards

Kiran Sure

Former Member
0 Kudos

Hi!!

check and try this

REPORT zmeng_perf .

DATA: it_mara TYPE STANDARD TABLE OF mara,

wa_mara TYPE mara,

it_makt TYPE STANDARD TABLE OF makt,

wa_makt TYPE makt,

it_temp_mara TYPE STANDARD TABLE OF mara,

wa_temp_mara TYPE mara.

  • Get all the records from MARA

SELECT * FROM mara

INTO TABLE it_temp_mara.

IF sy-subrc = 0.

IF NOT it_temp_mara[] IS INITIAL.

  • Duplicate the driver table with the data

DO 100 TIMES.

APPEND LINES OF it_temp_mara TO it_mara.

ENDDO.

IF NOT it_mara[] IS INITIAL.

  • Select MAKT

PERFORM select_makt.

SORT it_mara BY matnr.

PERFORM select_makt.

  • After deleting duoplicateentries

DELETE ADJACENT DUPLICATES FROM it_mara COMPARING matnr.

PERFORM select_makt.

ENDIF.

ENDIF.

ENDIF.

&----


*& Form select_makt

&----


  • Select data friom MAKT

----


FORM select_makt .

DATA: t1 TYPE i,

t2 TYPE i,

tmin TYPE i.

REFRESH it_makt[].

GET RUN TIME FIELD t1.

SELECT *

FROM makt

INTO TABLE it_makt

FOR ALL ENTRIES IN it_mara

WHERE matnr = it_mara-matnr.

GET RUN TIME FIELD t2.

tmin = t2 - t1.

tmin = tmin .

WRITE:/ ' Time(ms) = ', tmin.

ENDFORM.

hope it helps.

kindly rewrd points.

Former Member
0 Kudos

Hi,

Sample program for all entries

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

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

Former Member
0 Kudos

Hi

Just check this out -

DATA: tab_spfli TYPE TABLE OF spfli,

tab_sflight TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY table_line,

wa LIKE LINE OF tab_sflight.

SELECT carrid connid

INTO CORRESPONDING FIELDS OF TABLE tab_spfli

FROM spfli

WHERE cityfrom = 'NEW YORK'.

SELECT carrid connid fldate

INTO CORRESPONDING FIELDS OF TABLE tab_sflight

FROM sflight

FOR ALL ENTRIES IN tab_spfli

WHERE carrid = tab_spfli-carrid AND

connid = tab_spfli-connid.

LOOP AT tab_sflight INTO wa.

AT NEW connid.

WRITE: / wa-carrid, wa-connid.

ENDAT.

WRITE: / wa-fldate.

ENDLOOP.

Hope it helps.

Reward if useful.

Regards

Megha Sharma