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: 

How to display excel sheet on module pool screen?

arpita_churi3
Active Participant
0 Kudos

Hi all,

I have multiplerecords in internal table and want that records to be displayed on screen

in module pool in excel format?

Pls help me in this condition.

Thanks and Regrads,

Arpita.

1 ACCEPTED SOLUTION

former_member235056
Active Contributor
0 Kudos

Hi,

U can go ahead with some table control or if u want excel sheet output then go ahead with OLE programming as under.


*&---------------------------------------------------------------------*
*& Report  ZCOG_OLE1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZCOG_OLE1 NO STANDARD PAGE HEADING LINE-SIZE 250.

TYPE-POOLS: OLE2.

TABLES: PA0000, PA0001, PA0002.

DATA: EXCEL TYPE OLE2_OBJECT,
      WBOOKL TYPE OLE2_OBJECT,
      WBOOKS TYPE OLE2_OBJECT,
      CELL TYPE OLE2_OBJECT,
      FONT TYPE OLE2_OBJECT,
      CNT TYPE I.

DATA: BEGIN OF IT_ALL OCCURS 10,
      PERNR LIKE PA0001-PERNR,
      ENAME LIKE PA0001-ENAME,
      PLANS LIKE PA0001-PLANS,
      ORGEH LIKE PA0001-ORGEH,
      STELL LIKE PA0001-STELL,
      ABKRS LIKE PA0001-ABKRS,
      BUKRS LIKE PA0001-BUKRS,
      WERKS LIKE PA0001-WERKS,
      PERSG LIKE PA0001-PERSG,
      END OF IT_ALL.

SELECT-OPTIONS: PERNR FOR PA0001-PERNR.

START-OF-SELECTION.
SELECT PERNR ENAME PLANS ORGEH STELL ABKRS BUKRS WERKS PERSG ENDDA FROM PA0001 INTO CORRESPONDING FIELDS OF TABLE IT_ALL WHERE PERNR IN PERNR ORDER BY ENDDA DESCENDING.
SORT IT_ALL DESCENDING BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_ALL COMPARING PERNR.
ULINE.
WRITE: / SY-VLINE NO-GAP,
       (20) 'PERSONNEL NUMBER', SY-VLINE NO-GAP,
       (45) 'NAME', SY-VLINE NO-GAP,
       (20) 'POSITION', SY-VLINE NO-GAP,
       (20) 'ORG UNIT', SY-VLINE NO-GAP,
       (20) 'JOB', SY-VLINE NO-GAP,
       (10) 'PY AREA', SY-VLINE NO-GAP,
       (10) 'COMPANY', SY-VLINE NO-GAP,
       (20) 'PERS AREA', SY-VLINE NO-GAP,
       (20) 'PERS SUBAREA', SY-VLINE NO-GAP.
ULINE.

LOOP AT IT_ALL.
WRITE: / SY-VLINE NO-GAP,
       (20) IT_ALL-PERNR, SY-VLINE NO-GAP,
       (45) IT_ALL-ENAME, SY-VLINE NO-GAP,
       (20) IT_ALL-PLANS, SY-VLINE NO-GAP,
       (20) IT_ALL-ORGEH, SY-VLINE NO-GAP,
       (20) IT_ALL-STELL, SY-VLINE NO-GAP,
       (10) IT_ALL-ABKRS, SY-VLINE NO-GAP,
       (10) IT_ALL-BUKRS, SY-VLINE NO-GAP,
       (20) IT_ALL-WERKS, SY-VLINE NO-GAP,
       (20) IT_ALL-PERSG, SY-VLINE NO-GAP.
ENDLOOP.

CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
SET PROPERTY OF EXCEL 'VISIBLE' = 1.

CALL METHOD OF EXCEL 'WORKBOOKS' = WBOOKL.

CALL METHOD OF WBOOKL 'ADD' = WBOOKS.

PERFORM FILL_CELL USING 1 1 1 'PERSONNEL NUMBER'.
PERFORM FILL_CELL USING 1 2 1 'NAME'.
PERFORM FILL_CELL USING 1 3 1 'POSITION'.
PERFORM FILL_CELL USING 1 4 1 'ORG UNIT'.
PERFORM FILL_CELL USING 1 5 1 'JOB'.
PERFORM FILL_CELL USING 1 6 1 'PY AREA'.
PERFORM FILL_CELL USING 1 7 1 'COMPANY'.
PERFORM FILL_CELL USING 1 8 1 'PERS AREA'.
PERFORM FILL_CELL USING 1 9 1 'PERS SUBAREA'.

LOOP AT IT_ALL.
CNT = SY-TABIX + 1.
PERFORM FILL_CELL USING CNT 1 0 IT_ALL-PERNR.
PERFORM FILL_CELL USING CNT 2 0 IT_ALL-ENAME.
PERFORM FILL_CELL USING CNT 3 0 IT_ALL-PLANS.
PERFORM FILL_CELL USING CNT 4 0 IT_ALL-ORGEH.
PERFORM FILL_CELL USING CNT 5 0 IT_ALL-STELL.
PERFORM FILL_CELL USING CNT 6 0 IT_ALL-ABKRS.
PERFORM FILL_CELL USING CNT 7 0 IT_ALL-BUKRS.
PERFORM FILL_CELL USING CNT 8 0 IT_ALL-WERKS.
PERFORM FILL_CELL USING CNT 9 0 IT_ALL-PERSG.
ENDLOOP.
FREE OBJECT EXCEL.

FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF EXCEL 'CELLS' = CELL EXPORTING #1 = I #2 = J.
SET PROPERTY OF CELL 'VALUE' = VAL.
SET PROPERTY OF CELL 'FONT' = FONT.
SET PROPERTY OF CELL 'BOLD' = BOLD.
ENDFORM.

Regards,

Ameet

5 REPLIES 5

Former Member
0 Kudos

U can display internal table content in 2 ways in module pool:

1) Table Control

2) Object Orianted ALV using Custom control

there is no other way

former_member235056
Active Contributor
0 Kudos

Hi,

U can go ahead with some table control or if u want excel sheet output then go ahead with OLE programming as under.


*&---------------------------------------------------------------------*
*& Report  ZCOG_OLE1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZCOG_OLE1 NO STANDARD PAGE HEADING LINE-SIZE 250.

TYPE-POOLS: OLE2.

TABLES: PA0000, PA0001, PA0002.

DATA: EXCEL TYPE OLE2_OBJECT,
      WBOOKL TYPE OLE2_OBJECT,
      WBOOKS TYPE OLE2_OBJECT,
      CELL TYPE OLE2_OBJECT,
      FONT TYPE OLE2_OBJECT,
      CNT TYPE I.

DATA: BEGIN OF IT_ALL OCCURS 10,
      PERNR LIKE PA0001-PERNR,
      ENAME LIKE PA0001-ENAME,
      PLANS LIKE PA0001-PLANS,
      ORGEH LIKE PA0001-ORGEH,
      STELL LIKE PA0001-STELL,
      ABKRS LIKE PA0001-ABKRS,
      BUKRS LIKE PA0001-BUKRS,
      WERKS LIKE PA0001-WERKS,
      PERSG LIKE PA0001-PERSG,
      END OF IT_ALL.

SELECT-OPTIONS: PERNR FOR PA0001-PERNR.

START-OF-SELECTION.
SELECT PERNR ENAME PLANS ORGEH STELL ABKRS BUKRS WERKS PERSG ENDDA FROM PA0001 INTO CORRESPONDING FIELDS OF TABLE IT_ALL WHERE PERNR IN PERNR ORDER BY ENDDA DESCENDING.
SORT IT_ALL DESCENDING BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_ALL COMPARING PERNR.
ULINE.
WRITE: / SY-VLINE NO-GAP,
       (20) 'PERSONNEL NUMBER', SY-VLINE NO-GAP,
       (45) 'NAME', SY-VLINE NO-GAP,
       (20) 'POSITION', SY-VLINE NO-GAP,
       (20) 'ORG UNIT', SY-VLINE NO-GAP,
       (20) 'JOB', SY-VLINE NO-GAP,
       (10) 'PY AREA', SY-VLINE NO-GAP,
       (10) 'COMPANY', SY-VLINE NO-GAP,
       (20) 'PERS AREA', SY-VLINE NO-GAP,
       (20) 'PERS SUBAREA', SY-VLINE NO-GAP.
ULINE.

LOOP AT IT_ALL.
WRITE: / SY-VLINE NO-GAP,
       (20) IT_ALL-PERNR, SY-VLINE NO-GAP,
       (45) IT_ALL-ENAME, SY-VLINE NO-GAP,
       (20) IT_ALL-PLANS, SY-VLINE NO-GAP,
       (20) IT_ALL-ORGEH, SY-VLINE NO-GAP,
       (20) IT_ALL-STELL, SY-VLINE NO-GAP,
       (10) IT_ALL-ABKRS, SY-VLINE NO-GAP,
       (10) IT_ALL-BUKRS, SY-VLINE NO-GAP,
       (20) IT_ALL-WERKS, SY-VLINE NO-GAP,
       (20) IT_ALL-PERSG, SY-VLINE NO-GAP.
ENDLOOP.

CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
SET PROPERTY OF EXCEL 'VISIBLE' = 1.

CALL METHOD OF EXCEL 'WORKBOOKS' = WBOOKL.

CALL METHOD OF WBOOKL 'ADD' = WBOOKS.

PERFORM FILL_CELL USING 1 1 1 'PERSONNEL NUMBER'.
PERFORM FILL_CELL USING 1 2 1 'NAME'.
PERFORM FILL_CELL USING 1 3 1 'POSITION'.
PERFORM FILL_CELL USING 1 4 1 'ORG UNIT'.
PERFORM FILL_CELL USING 1 5 1 'JOB'.
PERFORM FILL_CELL USING 1 6 1 'PY AREA'.
PERFORM FILL_CELL USING 1 7 1 'COMPANY'.
PERFORM FILL_CELL USING 1 8 1 'PERS AREA'.
PERFORM FILL_CELL USING 1 9 1 'PERS SUBAREA'.

LOOP AT IT_ALL.
CNT = SY-TABIX + 1.
PERFORM FILL_CELL USING CNT 1 0 IT_ALL-PERNR.
PERFORM FILL_CELL USING CNT 2 0 IT_ALL-ENAME.
PERFORM FILL_CELL USING CNT 3 0 IT_ALL-PLANS.
PERFORM FILL_CELL USING CNT 4 0 IT_ALL-ORGEH.
PERFORM FILL_CELL USING CNT 5 0 IT_ALL-STELL.
PERFORM FILL_CELL USING CNT 6 0 IT_ALL-ABKRS.
PERFORM FILL_CELL USING CNT 7 0 IT_ALL-BUKRS.
PERFORM FILL_CELL USING CNT 8 0 IT_ALL-WERKS.
PERFORM FILL_CELL USING CNT 9 0 IT_ALL-PERSG.
ENDLOOP.
FREE OBJECT EXCEL.

FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF EXCEL 'CELLS' = CELL EXPORTING #1 = I #2 = J.
SET PROPERTY OF CELL 'VALUE' = VAL.
SET PROPERTY OF CELL 'FONT' = FONT.
SET PROPERTY OF CELL 'BOLD' = BOLD.
ENDFORM.

Regards,

Ameet

arpita_churi3
Active Participant
0 Kudos

Hi,

Thanks Ameet.

The program that u given will open excel sheet as a new window but i

want to display excel sheet on screen painter.

is there any way to display that?

Regards,

Arpita.

former_member223537
Active Contributor
0 Kudos

Hi Arpita,

Please refer sample program SAPRDEMODOCUMENTCONTAINER2.

Click NEW => Microsoft office Excel

Best regards,

Prashant

arpita_churi3
Active Participant
0 Kudos

Hi all,

I want display excel sheet on screen painter.

whether it is possible using CUSTOM CONTROL on screen painter?

if possible then how it is done?

Thanks,

Arpita.