Saturday, December 18, 2010
REPORT  ztest_notepad.
*--------------------------------------------------------*
"  Data retrieval related declarations
*--------------------------------------------------------*
"Variables
DATA:
      g_spool_no TYPE tsp01-rqident.
"Types
TYPES:
BEGIN OF t_emp_dat,
    pernr     TYPE pa0001-pernr,
    persg     TYPE pa0001-persg,
    persk     TYPE pa0001-persk,
    plans     TYPE pa0001-plans,
    stell     TYPE pa0001-stell,
END OF t_emp_dat.
"Work area
DATA:
      w_emp_data  TYPE t_emp_dat.
"Internal tables
DATA:
      i_emp_data  TYPE STANDARD TABLE OF t_emp_dat.
*--------------------------------------------------------*
"Top-of-page.
*--------------------------------------------------------*
TOP-OF-PAGE.
  PERFORM top_of_page.

*--------------------------------------------------------*
  "Start-of-selection.
*--------------------------------------------------------*
START-OF-SELECTION.
  PERFORM get_data.
  IF i_emp_data[] IS INITIAL.
    PERFORM test_data.
  ENDIF.
  PERFORM do_print_n_get_spoolno.

*--------------------------------------------------------*
  "End-of-selection.
*--------------------------------------------------------*
END-OF-SELECTION.
  WRITE: 'Spool no', g_spool_no.

*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.
  DATA: inc_colnum TYPE i.
  ULINE.
  inc_colnum = sy-linsz - 60.
  WRITE: / 'Report: ', sy-repid(18).
  WRITE AT 30(inc_colnum) sy-title CENTERED.
  inc_colnum = sy-linsz - 20.
  WRITE: AT inc_colnum 'Page: ', (11) sy-pagno RIGHT-JUSTIFIED.
  WRITE: / 'Client: ', sy-mandt.
  inc_colnum = sy-linsz - 20.
  WRITE: AT inc_colnum 'Date: ', sy-datum.
  WRITE: / 'User  : ', sy-uname.
  inc_colnum = sy-linsz - 60.
  WRITE AT 30(inc_colnum) 'Company Confidential' CENTERED.
  inc_colnum = sy-linsz - 20.
  WRITE: AT inc_colnum 'Time: ', (10) sy-uzeit RIGHT-JUSTIFIED.
  ULINE .
  SKIP.
  ULINE AT /(127).
  WRITE:/ sy-vline,'pernr' COLOR COL_HEADING,13
  sy-vline,'persg' COLOR COL_HEADING,20
  sy-vline,'persk' COLOR COL_HEADING,26
  sy-vline,'plans' COLOR COL_HEADING,35
  sy-vline,'stell' COLOR COL_HEADING,46
  sy-vline.
  ULINE AT /(46).
ENDFORM.                    "top_of_page
*&--------------------------------------------------------*
"Form  get_data from PA0001
*&--------------------------------------------------------*
FORM get_data.

  SELECT pernr
  persg
  persk
  plans
  stell
  FROM pa0001
  INTO CORRESPONDING FIELDS OF TABLE i_emp_data
  UP TO 4 ROWS.

ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
"Form  do_print_n_get_spoolno
*&---------------------------------------------------------------------*
FORM do_print_n_get_spoolno.

  "Display Output
  LOOP AT i_emp_data INTO w_emp_data .
    AT FIRST.
      PERFORM get_print_parameters.
    ENDAT.
    WRITE:/ sy-vline,w_emp_data-pernr,13
    sy-vline,w_emp_data-persg,20
    sy-vline,w_emp_data-persk,26
    sy-vline,w_emp_data-plans,35
    sy-vline,w_emp_data-stell,46
    sy-vline.
    ULINE AT /(46).
    AT LAST.
      g_spool_no  = sy-spono.
      NEW-PAGE PRINT OFF.
      CALL FUNCTION 'ABAP4_COMMIT_WORK'.
    ENDAT.
  ENDLOOP.

ENDFORM.                    "do_print_n_get_spoolno
*&---------------------------------------------------------------------*
*&      Form  get_print_parameters
*&---------------------------------------------------------------------*
FORM get_print_parameters .
  "Variables
  DATA:
  l_lay    TYPE pri_params-paart,
  l_lines  TYPE pri_params-linct,
  l_cols   TYPE pri_params-linsz,
  l_val    TYPE c.
*Types
  TYPES:
  t_pripar TYPE pri_params,
  t_arcpar TYPE arc_params.
  "Work areas
  DATA:
  lw_pripar TYPE t_pripar,
  lw_arcpar TYPE t_arcpar.

  l_lay   = 'X_65_132'.
  l_lines = 65.
  l_cols  = 132.
  "Read, determine, change spool print parameters and archive parameters
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      in_archive_parameters  = lw_arcpar
      in_parameters          = lw_pripar
      layout                 = l_lay
      line_count             = l_lines
      line_size              = l_cols
      no_dialog              = 'X'
    IMPORTING
      out_archive_parameters = lw_arcpar
      out_parameters         = lw_pripar
      valid                  = l_val
    EXCEPTIONS
      archive_info_not_found = 1
      invalid_print_params   = 2
      invalid_archive_params = 3
      OTHERS                 = 4.
  IF l_val <> space AND sy-subrc = 0.
    lw_pripar-prrel = space.
    lw_pripar-primm = space.
    NEW-PAGE PRINT ON
    NEW-SECTION
    PARAMETERS lw_pripar
    ARCHIVE PARAMETERS lw_arcpar
    NO DIALOG.
  ENDIF.
ENDFORM.                    " get_print_parameters
*&---------------------------------------------------------------------*
*&      Form  test_data
*&---------------------------------------------------------------------*
FORM test_data .
  DO 10 TIMES.
    w_emp_data-pernr = sy-index.
    w_emp_data-persg = '2'.
    w_emp_data-persk = '93'.
    w_emp_data-plans = '99999999'.
    w_emp_data-stell = '31414144'.
    APPEND w_emp_data TO i_emp_data.
    CLEAR  w_emp_data.
  ENDDO.

ENDFORM.                    " test_data

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.