Sie sind auf Seite 1von 10

SAP ECC

July 2013
English

PDF Based Print Forms

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com


ALL RIGHTS RESERVED. This training material contains material protected under International
Copyright Laws and Treaties. Any unauthorized reprint or use of this material is prohibited. No part of
this material may be reproduced or transmitted in any form or by any means, electronic or mechanical,
including photocopying, recording, or by any information storage and retrieval system
without
express written permission from Enterprise Consultancy Services Company.

Contents
Working with Internal Tables ........................................................................................................................ 3
Calling Forms in Application Programs ......................................................................................................... 7
Collecting the Application Data .................................................................................................................. 10
Getting the Interface Fields ........................................................................................................................ 10

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 2

Working with Internal Tables


Two ways for using dynamic internal tables in a PDF form.
1- Fill internal table in printing program and send it to PDF form in the import parameter.
Use ABAP Dictionary table type or create a z one from SE11.

Use ABAP statements to fill internal table in printing program

Send it as an exporting parameter in the function module calling the PDF form.

In form interface, add internal table in import section.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 3

In some cases when using internal tables with currency and quantity fields, defining field names
and their reference fields would be important.

In form context, drag and drop the ITAB into the context folder.

Deactivate fields that you will not use.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 4

Finally in the layout tab, drag the ITAB from data view to the design page.

Activate the form and test the printing program the result would show a table as follows
according to the data on your testing server:

2- Define internal table type in PDF and fill it in code initialization


In global data define an internal table with either an ABAP dictionary table type like vbap_t or
by a customized type that you will define in Types section.

Defining a table type in Types section:

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 5

Filling the internal table in code initialization section.

In form layout , drag the ITAB2 from global data to Context.

In layout tab, drag ITAB2 from data view to form design.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 6

Test from the printing program, the result would be as follows:

Calling Forms in Application Programs


Create an executable program from SE38:

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 7

*&---------------------------------------------------------------------*
*& Report ZPRINTING_PROGRAM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT

ZPRINTING_PROGRAM.

"Selections
"Processing Data
"Data Declarations
DATA:
fm_name
fp_docparams
fp_outputparams

TYPE rs38l_fnam,
TYPE sfpdocparams,
TYPE sfpoutputparams.

* Sets the output parameters and opens the spool job


CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
IE_OUTPUTPARAMS
= FP_OUTPUTPARAMS
EXCEPTIONS
CANCEL
= 1
USAGE_ERROR
= 2
SYSTEM_ERROR
= 3
INTERNAL_ERROR
= 4
OTHERS
= 5.
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
" <error handling>
ENDIF.

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'


EXPORTING
I_NAME
= ''" pdf name
IMPORTING
E_FUNCNAME = FM_NAME.
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
<error handling>
ENDIF.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 8

CALL FUNCTION FM_NAME


EXPORTING
/1BCDWB/DOCPARAMS
"add import data
EXCEPTIONS
USAGE_ERROR
SYSTEM_ERROR
INTERNAL_ERROR
OTHERS
.

= FP_DOCPARAMS

=
=
=
=

1
2
3
4

IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
<error handling>
ENDIF.

* Close the spool job


CALL FUNCTION 'FP_JOB_CLOSE'
*
IMPORTING
*
E_RESULT
=
EXCEPTIONS
USAGE_ERROR
= 1
SYSTEM_ERROR
= 2
INTERNAL_ERROR
= 3
OTHERS
= 4.
IF SY-SUBRC <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
" <error handling>
ENDIF.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 9

Collecting the Application Data


Depending on the requirement that you get, mostly data are found in the standard interfaces. For some
other data, select statements will be used to gather data needed.

Getting the Interface Fields


You can navigate through the standard interface fields to know all the fields that could be used.
Double click on type name to navigate to its components:

To use the address for example in the code, you can type LS_HEADER-ADRNR.

Copyright 2013, Enterprise Consultancy Services, info@ecs-co.com

Page 10

Das könnte Ihnen auch gefallen