Skip to Content
0
Jan 21, 2013 at 01:45 PM

Need help on Converting Classical output to PDF

22 Views

Hi Experts ,

Need help on Converting Classical output to PDF am able to convert the out to PDF, but the PDF doesn't have the full out put for example If there are 10 Columns in the Classical output view in SAP, the PDF attached(sent Via Email) I can see only 4-5 Columns the rest of the columns doesn't appear in the PDF can some one hlep on this am not able to figure out whwere did it go wrong

Below is the Code

Report ZTEST_EMAIL.

***&---------------------------------------------------------------------*

***& Form SEND_PDF

***&---------------------------------------------------------------------*

*** text

***----------------------------------------------------------------------*

*** --> p1 text

*** <-- p2 text

***----------------------------------------------------------------------*

*FORM SEND_PDF .

DATA: L_PARAMS TYPE PRI_PARAMS,

L_VALID TYPE STRING,

W_SPOOL_NR LIKE TSP01-RQIDENT.

DATA : IT_PDF TYPE TABLE OF TLINE.

DATA : IT_PDFDATA TYPE TABLE OF SOLISTI1.

DATA : WA_PDF TYPE TLINE,

WA_PDFDATA TYPE SOLISTI1,

I TYPE I,

J TYPE I,

K TYPE I,

L TYPE I.

DATA: LI_OBJCONT TYPE STANDARD TABLE OF SOLISTI1,

LI_RECLIST TYPE STANDARD TABLE OF SOMLRECI1,

LI_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1,

LI_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1,

LI_CONTENT TYPE STANDARD TABLE OF SOLISTI1,

LWA_OBJCONT TYPE SOLISTI1,

LWA_RECLIST TYPE SOMLRECI1,

LWA_OBJPACK TYPE SOPCKLSTI1,

LWA_OBJHEAD TYPE SOLISTI1,

LWA_CONTENT TYPE SOLISTI1,

LWA_DOC TYPE SODOCCHGI1,

L_LINES TYPE I,

OBJ_LIST TYPE TABLE OF ABAPLIST,

LWA_LIST TYPE ABAPLIST.

REFRESH: LI_OBJCONT[], LI_RECLIST[],

LI_OBJPACK[], LI_OBJHEAD[],

LI_CONTENT[].

CLEAR: LWA_OBJCONT, LWA_RECLIST,

LWA_OBJPACK, LWA_OBJHEAD,

LWA_CONTENT, LWA_DOC.

**

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

NO_DIALOG = 'X'

IMPORTING

OUT_PARAMETERS = L_PARAMS

VALID = L_VALID.

IF SY-SUBRC <> 0.

ENDIF.

DATA: BEGIN OF I_RSPARAMS OCCURS 0.

INCLUDE STRUCTURE RSPARAMS.

DATA: END OF I_RSPARAMS.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

CURR_REPORT = 'ZORDER_STATUS_HIST_REP_COPY'

TABLES

SELECTION_TABLE = I_RSPARAMS.

SUBMIT ZORDER_STATUS_HIST_REP_COPY WITH SELECTION-TABLE I_RSPARAMS

TO SAP-SPOOL

SPOOL PARAMETERS L_PARAMS

WITHOUT SPOOL DYNPRO

AND RETURN.

SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01

WHERE RQCLIENT = SY-MANDT

AND RQOWNER = SY-UNAME.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = W_SPOOL_NR

TABLES

PDF = IT_PDF.

* TO CONVERT TLINE WITH LENGHT 134 TO 255

I = 134. "LENGTH FOR TLINE IN PDF FORMAT.

LOOP AT IT_PDF INTO WA_PDF.

MOVE WA_PDF(I) TO WA_PDFDATA+J.

J = J + I.

IF J >= 255. "255 LENGTH FOR solisti1

APPEND WA_PDFDATA TO IT_PDFDATA.

CLEAR WA_PDFDATA.

CLEAR J.

K = 134 - I.

IF K > 0.

MOVE WA_PDF+I(K) TO WA_PDFDATA+0(K).

ENDIF.

J = J + K.

ENDIF.

L = J + I.

IF L >= 255.

I = 255 - J.

ELSE.

I = 134.

ENDIF.

ENDLOOP.

* END OF CONVERT.

LI_OBJCONT[] = IT_PDFDATA[].

LWA_RECLIST-RECEIVER = 'harikrishna1984@gmail.com'.

LWA_RECLIST-REC_TYPE = 'U'.

APPEND LWA_RECLIST TO LI_RECLIST.

LWA_OBJHEAD = 'SEND OUTPUT AS PDF'.

APPEND LWA_OBJHEAD TO LI_OBJHEAD.

LWA_CONTENT = 'Hi'.

APPEND LWA_CONTENT TO LI_CONTENT.

CLEAR LWA_CONTENT.

APPEND LWA_CONTENT TO LI_CONTENT.

LWA_CONTENT = 'Please find attached document as output in pdf format'. "test anmol

APPEND LWA_CONTENT TO LI_CONTENT. "test anmol

CLEAR L_LINES.

DESCRIBE TABLE LI_CONTENT LINES L_LINES.

READ TABLE LI_CONTENT INTO LWA_CONTENT INDEX L_LINES.

LWA_DOC-DOC_SIZE = ( L_LINES - 1 ) * 255 + STRLEN( LWA_CONTENT ).

LWA_DOC-OBJ_LANGU = 'E'.

LWA_DOC-OBJ_NAME = 'PDF OUTPUT'.

LWA_DOC-OBJ_DESCR = 'OUTPUT AS PDF'.

CLEAR LWA_OBJPACK-TRANSF_BIN.

LWA_OBJPACK-HEAD_START = 1.

LWA_OBJPACK-HEAD_NUM = 0.

LWA_OBJPACK-BODY_START = 1.

LWA_OBJPACK-BODY_NUM = L_LINES.

LWA_OBJPACK-DOC_TYPE = 'RAW'.

APPEND LWA_OBJPACK TO LI_OBJPACK.

CLEAR: LWA_OBJPACK, L_LINES.

DESCRIBE TABLE LI_OBJCONT LINES L_LINES.

READ TABLE LI_OBJCONT INTO LWA_OBJCONT INDEX L_LINES.

LWA_OBJPACK-DOC_SIZE = ( L_LINES - 1 ) * 255 + STRLEN( LWA_OBJCONT ).

LWA_OBJPACK-TRANSF_BIN = 'X'.

LWA_OBJPACK-HEAD_START = 1.

LWA_OBJPACK-HEAD_NUM = 0.

LWA_OBJPACK-BODY_START = 1.

LWA_OBJPACK-BODY_NUM = L_LINES.

LWA_OBJPACK-DOC_TYPE = 'PDF' .

LWA_OBJPACK-OBJ_NAME = 'PDF OUTPUT'.

LWA_OBJPACK-OBJ_DESCR = 'OUTPUT AS PDF'.

APPEND LWA_OBJPACK TO LI_OBJPACK.

*Sending the mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = LWA_DOC

PUT_IN_OUTBOX = 'X'

TABLES

PACKING_LIST = LI_OBJPACK

OBJECT_HEADER = LI_OBJHEAD

CONTENTS_BIN = LI_OBJCONT

CONTENTS_TXT = LI_CONTENT

RECEIVERS = LI_RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

IF SY-SUBRC NE 0.

WRITE:/ 'Document sending failed'.

ELSE.

WRITE:/ 'Document successfully sent'.

COMMIT WORK.

ENDIF.

*ENDFORM. " SEND_PDF