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

Print option in a module pool program with table control

Former Member
0 Likes
1,333

Hi,

I have developed a module pool program which contains a table control in it.

I have a requriement where in I need to print the conents of the table control.

Please could anyone help me out with this.

Regards,

Sushanth H.S.

7 REPLIES 7
Read only

naveen_inuganti2
Active Contributor
0 Likes
1,111

.

Edited by: Naveen Inuganti on Jun 19, 2008 11:52 AM

Read only

Former Member
0 Likes
1,111

hi,

you can use below mentioned function module to convert table controls internal table into a spool.

& from spool number received you can take print from SP01.

Function module is 'SLVC_TABLE_PS_TO_SPOOL'.

Read only

Former Member
0 Likes
1,111

Hi,

When I use the function module SLVC_TABLE_PS_TO_SPOOL, it is giving me a short dump.

The reason for this is that the internal table of the table control is not of type LVC_S_1022 .

Please can you help me with this.

Regards,

Sushanth H.S.

Read only

Former Member
0 Likes
1,111

You could simply try writing the data to a list (usual leave to list-processing approach), but preceeding the output with a "new-page print on" type setup... the code below was borrowed from the online help... in your cae, just loop at the internal table tha represents the table control contents and list that out.

Jonathan


report demo.

data: spfli_wa type spfli,
      sflight_wa type sflight.

data: print_parameters type pri_params,
      valid_flag       type c length 1.

start-of-selection.

  call function 'GET_PRINT_PARAMETERS'
    importing
      out_parameters       = print_parameters
      valid                = valid_flag
    exceptions
      invalid_print_params = 2
      others               = 4.

  if valid_flag = 'X' and sy-subrc = 0.
    select carrid connid
      from spfli
      into corresponding fields of spfli_wa.
      write: / spfli_wa-carrid, spfli_wa-connid.
      hide:    spfli_wa-carrid, spfli_wa-connid.
    endselect.
  else.
    ...
  endif.

at line-selection.
  new-page print on parameters print_parameters
                    no dialog.
  select *
         from sflight
         into sflight_wa
         where carrid = spfli_wa-carrid and
               connid = spfli_wa-connid.
    write: / sflight_wa-carrid, sflight_wa-connid,
             sflight_wa-fldate ...
  endselect.
  new-page print off.

Read only

Former Member
0 Likes
1,111

Hi,

In the Table control screen (main screen) place print/print preview button. if this is selected, provide an ALV list output withe the table contrao contents. The ALV will have the standard print functionality, using that we can print the data.

Standard SAP is also foloowing the same way, if you observe ant table maintenace view (SM30) it will have the table control, There if you perform print, it will take you to the ALV list output in next screen. There you can print the data.

Thanks,

Rajinikanth.

Read only

Former Member
0 Likes
1,111

hi frnds

my requirement is in table control if i enter the data it should go and sit in DB table.

now the problem is wer to write code in pbo r pai.

plz gve the sample code........

Do we need create a structure for dat......

?

Read only

0 Likes
1,111

Hi,

You will have to write the code in the PAI for the given task.

I will just write the pseudocode for you.

For example:-

In PAI,

CASE SY-UCOMM.

WHEN 'ENTER'.

IF IT IS A NEW ENTRY.

INSERT DATABASE TABLE FROM THE INTERNAL TABLE.

(YOU WILL HAVE TO DECLARE AN INTERNAL TABLE

WHOSE DATA TYPE IS THE SAME AS THE DATABASE

TABLE ).

IF SY-SUBRC = 0.

COMMIT WORK.

ELSE.

ROLLBACK WORK.

ENDIF.

ELSE.

UPDATE DATABASE TABLE FROM INTERNAL TABLE.

IF SY-SUBRC = 0 .

COMMIT WORK.

ELSE

DELETE FROM DATABASE TABLE WHERE KEY =

TABLE-CONTROL ENTRY.

INSERT FROM DATABASE TABLE WHERE KEY =

TABLE-CONTROL ENTRY.

IF SY-SUBRC = 0 .

COMMIT WORK.

ELSE.

ROLLBACK WORK.

ENDIF.

ENDIF.