cancel
Showing results for 
Search instead for 
Did you mean: 

smartforms

Former Member
0 Kudos

Hi folks,

I have written a driver program as follows but i am getting an empty fom could somebody corerct me..i am not able to capture the nast entries into this....

report ZOP_TFB_S008_DRIVER.

*&----


*

*& Internal Table declarations

*&----


*

tables : NAST.

data :

WA_JPTIDCDASSIGN type JPTIDCDASSIGN,

WA_MAKT type MAKT,

WA_EKKO type EKKO,

WA_EKPO type EKPO,

IT_EKPO type standard table of EKPO,

WA_LFA1 type LFA1,

WA_KNA1 type KNA1,

WA_T001W type T001W,

WA_ADRC type ADRC,

WA_ADRC1 type ADRC.

data : FM_NAME type RS38L_FNAM.

data : FORMNAME type TDSFNAME.

data: WA_OUTPUT_OPTION type SSFCOMPOP.

data: WA_CONTROL_PARAM type SSFCTRLOP.

data: WA_SSFCRESC1 type SSFCRESCL.

data : V_LEN_IN type I.

data : PDF_TAB like TLINE occurs 0 with header line.

data : TAB_OTF_FINAL type ITCOO occurs 0 with header line.

WA_CONTROL_PARAM-NO_DIALOG = 'X'.

WA_OUTPUT_OPTION-TDDELETE = 'X'.

WA_OUTPUT_OPTION-TDFINAL = 'X'.

WA_OUTPUT_OPTION-TDIEXIT = 'X'.

*&----


*

*& Event Processing

*&----


*

start-of-selection.

perform GET_DATA.

perform PRINT_FORM.

*&----


*

*& Form get_data

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form GET_DATA .

select single EBELN

LIFNR

ZTERM

BEDAT

INCO1

KUNNR

from EKKO

into corresponding fields of WA_EKKO

where EBELN = NAST-OBJKY.

if SY-SUBRC eq 0.

select EBELN

MATNR

EBELP

WERKS

MENGE

MEINS

NETPR

NETWR

KUNNR

from EKPO

into corresponding fields of table IT_EKPO

where EBELN = WA_EKKO-EBELN.

endif.

loop at IT_EKPO into WA_EKPO.

select single MATNR

SPRAS

MAKTX

from MAKT

into corresponding fields of WA_MAKT

where MATNR = WA_EKPO-MATNR and SPRAS = 'E'.

call function 'ISM_SD_GET_IDENTCODE'

exporting

IN_MATNR = WA_EKPO-MATNR

  • IN_IDCODETYPE =

importing

OUT_IDENTCODE = WA_JPTIDCDASSIGN-IDENTCODE

OUT_IDCODETYPE = WA_JPTIDCDASSIGN-IDCODETYPE

exceptions

NOT_FOUND = 1

others = 2

.

if SY-SUBRC <> 0.

message id SY-MSGID type SY-MSGTY number SY-MSGNO

with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

select single KUNNR

ADRNR

from KNA1

into corresponding fields of WA_KNA1

where KUNNR = WA_EKPO-KUNNR.

endloop.

if SY-SUBRC eq 0.

select single ADDRNUMBER

NAME1

STREET

HOUSE_NUM1

MC_CITY1

POST_CODE1

REGION

COUNTRY

from ADRC into corresponding fields of WA_ADRC1

where ADDRNUMBER = WA_KNA1-ADRNR.

endif.

select single LIFNR

ADRNR

from LFA1

into corresponding fields of WA_LFA1

where LIFNR = WA_EKKO-LIFNR.

if SY-SUBRC eq 0.

select single ADDRNUMBER

NAME1

STREET

HOUSE_NUM1

MC_CITY1

POST_CODE1

REGION

COUNTRY

from ADRC

into corresponding fields of WA_ADRC

where ADDRNUMBER = WA_LFA1-ADRNR.

endif.

if not IT_EKPO[] is initial.

select WERKS

NAME1

STRAS

PSTLZ

ORT01

LAND1

REGIO

from T001W

into corresponding fields of WA_T001W

for all entries in IT_EKPO

where WERKS = IT_EKPO-WERKS.

endselect.

endif.

endform. " get_data

*&----


*

*& Form print_form

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form PRINT_FORM .

data: I_OTF type ITCOO occurs 0 with header line,

I_TLINE type table of TLINE with header line,

I_RECEIVERS type table of SOMLRECI1 with header line,

I_RECORD like SOLISTI1 occurs 0 with header line,

  • Objects to send mail.

I_OBJPACK like SOPCKLSTI1 occurs 0 with header line,

I_OBJTXT like SOLISTI1 occurs 0 with header line,

I_OBJBIN like SOLISTI1 occurs 0 with header line,

I_RECLIST like SOMLRECI1 occurs 0 with header line,

  • Work Area declarations

WA_OBJHEAD type SOLI_TAB,

W_CTRLOP type SSFCTRLOP,

W_COMPOP type SSFCOMPOP,

W_RETURN type SSFCRESCL,

WA_DOC_CHNG type SODOCCHGI1,

W_DATA type SODOCCHGI1,

WA_BUFFER type STRING,"To convert from 132 to 255

MY_TABIX type SY-TABIX,

ID_RECEIVER like SY-SUBRC,

  • Variables declarations

V_FORM_NAME type RS38L_FNAM,

V_LEN_IN like SOOD-OBJLEN,

V_LEN_OUT like SOOD-OBJLEN,

V_LEN_OUTN type I,

V_LINES_TXT type I,

V_LINES_BIN type I.

****************for the first smartform*******************************

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

FORMNAME = 'ZOP_TFB_S008'

importing

FM_NAME = V_FORM_NAME

exceptions

NO_FORM = 1

NO_FUNCTION_MODULE = 2

others = 3.

if SY-SUBRC <> 0.

message id SY-MSGID type SY-MSGTY number SY-MSGNO

with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

W_CTRLOP-GETOTF = ' '.

W_CTRLOP-NO_DIALOG = 'X'.

W_COMPOP-TDNOPREV = ' '.

call function V_FORM_NAME

exporting

CONTROL_PARAMETERS = W_CTRLOP

OUTPUT_OPTIONS = W_COMPOP

USER_SETTINGS = 'X'

WA_EKKO = WA_EKKO

WA_KNA1 = WA_KNA1

WA_LFA1 = WA_LFA1

WA_ADRC = WA_ADRC

WA_ADRC1 = WA_ADRC1

WA_T001W = WA_T001W

WA_JPTIDCDASSIGN = WA_JPTIDCDASSIGN

WA_MAKT = WA_MAKT

importing

JOB_OUTPUT_INFO = W_RETURN

tables

IT_EKPO = IT_EKPO

exceptions

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 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.

endif.

I_OTF[] = W_RETURN-OTFDATA[].

**********removing the initial and final markers from the OTF data*********

delete W_RETURN-OTFDATA where TDPRINTCOM = '//'.

****************searching for the end-of-page in OTF table***********

read table I_OTF with key TDPRINTCOM = 'EP'. MY_TABIX = SY-TABIX + 1.

*

********appending the modified OTF table to the final OTF table*******

insert LINES OF W_RETURN-OTFDATA into I_OTF index MY_TABIX.

                        • converting OTF data into pdf data**************************

call function 'CONVERT_OTF'

exporting

FORMAT = 'PDF'

MAX_LINEWIDTH = 132

importing

BIN_FILESIZE = V_LEN_IN

tables

OTF = I_OTF

LINES = I_TLINE

exceptions

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

others = 4.

  • Fehlerhandling

if SY-SUBRC <> 0.

endif.

loop at I_TLINE.

translate I_TLINE using '~'.

concatenate WA_BUFFER I_TLINE into WA_BUFFER.

endloop.

translate WA_BUFFER using '~'.

do.

I_RECORD = WA_BUFFER.

append I_RECORD.

shift WA_BUFFER left by 255 places.

if WA_BUFFER is initial.

exit.

endif.

enddo.

  • Attachment

refresh:

I_RECLIST,

I_OBJTXT,

I_OBJBIN,

I_OBJPACK.

clear WA_OBJHEAD.

I_OBJBIN[] = I_RECORD[].

  • APPEND I_RECORD.

              • Create Message Body Title and Description****************

I_OBJTXT = 'test with pdf-Attachment!'.

append I_OBJTXT.

describe table I_OBJTXT lines V_LINES_TXT.

read table I_OBJTXT index V_LINES_TXT.

WA_DOC_CHNG-OBJ_NAME = 'smartform'.

WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.

WA_DOC_CHNG-OBJ_DESCR = 'smartform'.

WA_DOC_CHNG-SENSITIVTY = 'F'.

WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.

        • Main Text*****************************

clear I_OBJPACK-TRANSF_BIN.

I_OBJPACK-HEAD_START = 1.

I_OBJPACK-HEAD_NUM = 0.

I_OBJPACK-BODY_START = 1.

I_OBJPACK-BODY_NUM = V_LINES_TXT.

I_OBJPACK-DOC_TYPE = 'PDF'.

append I_OBJPACK.

        • Attachment (pdf-Attachment)*************

I_OBJPACK-TRANSF_BIN = 'X'.

I_OBJPACK-HEAD_START = 1.

I_OBJPACK-HEAD_NUM = 1.

I_OBJPACK-BODY_START = 1.

I_OBJPACK-BODY_NUM = V_LINES_BIN.

I_OBJPACK-DOC_TYPE = 'PDF'.

I_OBJPACK-OBJ_NAME = 'smartform'.

concatenate I_OBJPACK-OBJ_NAME I_OBJPACK-DOC_TYPE into I_OBJPACK-OBJ_DESCR separated by '.'.

  • I_OBJPACK-OBJ_DESCR = 'test'.

I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .

append I_OBJPACK.

  • Länge des Attachment ermitteln

clear I_RECLIST.

I_RECLIST-RECEIVER = 'prabhaschandv@gmail.com'.

I_RECLIST-REC_TYPE = 'U'.

I_RECLIST-EXPRESS = 'X'.

data: TAB_LINES like SY-TABIX.

describe table I_OBJBIN lines TAB_LINES.

append I_RECLIST.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

DOCUMENT_DATA = WA_DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

tables

PACKING_LIST = I_OBJPACK

OBJECT_HEADER = WA_OBJHEAD

CONTENTS_BIN = I_OBJBIN

CONTENTS_TXT = I_OBJTXT

RECEIVERS = I_RECLIST

exceptions

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

DOCUMENT_TYPE_NOT_EXIST = 3

OPERATION_NO_AUTHORIZATION = 4

PARAMETER_ERROR = 5

X_ERROR = 6

ENQUEUE_ERROR = 7

others = 8.

if SY-SUBRC <> 0.

write:/ 'Error When Sending the File', SY-SUBRC.

else.

write:/ 'Mail sent'.

endif.

endform. "print_form

any help reg this would be appreciated..

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

Keep a break point at the line

call function V_FORM_NAME

and execute the program

and see the values coming into different internal tables

if the values are coming here and the smartform is not coming then something wrong with form display.

see the doc

How to create a New smartfrom, it is having step by step procedure

http://sap.niraj.tripod.com/id67.html

Here is the procedure

1. Create a new smartforms

Transaction code SMARTFORMS

Create new smartforms call ZSMART

2. Define looping process for internal table

Pages and windows

First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)

Here, you can specify your title and page numbering

&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)

Main windows -> TABLE -> DATA

In the Loop section, tick Internal table and fill in

ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2

3. Define table in smartforms

Global settings :

Form interface

Variable name Type assignment Reference type

ITAB1 TYPE Table Structure

Global definitions

Variable name Type assignment Reference type

ITAB2 TYPE Table Structure

4. To display the data in the form

Make used of the Table Painter and declare the Line Type in Tabstrips Table

e.g. HD_GEN for printing header details,

IT_GEN for printing data details.

You have to specify the Line Type in your Text elements in the Tabstrips Output options.

Tick the New Line and specify the Line Type for outputting the data.

Declare your output fields in Text elements

Tabstrips - Output Options

For different fonts use this Style : IDWTCERTSTYLE

For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&

5. Calling SMARTFORMS from your ABAP program

REPORT ZSMARTFORM.

  • Calling SMARTFORMS from your ABAP program.

  • Collecting all the table data in your program, and pass once to SMARTFORMS

  • SMARTFORMS

  • Declare your table type in :-

  • Global Settings -> Form Interface

  • Global Definintions -> Global Data

  • Main Window -> Table -> DATA

  • Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming

  • http://sapr3.tripod.com

TABLES: MKPF.

DATA: FM_NAME TYPE RS38L_FNAM.

DATA: BEGIN OF INT_MKPF OCCURS 0.

INCLUDE STRUCTURE MKPF.

DATA: END OF INT_MKPF.

SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.

SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.

MOVE-CORRESPONDING MKPF TO INT_MKPF.

APPEND INT_MKPF.

ENDSELECT.

  • At the end of your program.

  • Passing data to SMARTFORMS

call function 'SSF_FUNCTION_MODULE_NAME'

exporting

formname = 'ZSMARTFORM'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

if sy-subrc <> 0.

WRITE: / 'ERROR 1'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

call function FM_NAME

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

GS_MKPF = INT_MKPF

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 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.

endif.

Reward points for useful Answers

Regards

Anji