Thursday, July 7, 2011

SAP Smart Forms Sample Program


Go tcode smartforms.


click on out options.


If u have parameters must be specified here.


Declare all the global fields here.


Types must be declared here.


TYPES: BEGIN OF T_KNA1,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
PSTLZ TYPE KNA1-PSTLZ,
STRAS TYPE KNA1-STRAS,
END OF T_KNA1.

TYPES: BEGIN OF T_T001,
BUTXT TYPE T001-BUTXT,
ORT01 TYPE T001-ORT01,
LAND1 TYPE T001-LAND1,
END OF T_T001.

TYPES: BEGIN OF T_VBRK,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
KUNAG TYPE KUNAG,
BUKRS TYPE BUKRS,
END OF T_VBRK.

TYPES: BEGIN OF T_VBRP,
VBELN TYPE VBELN,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_VBRP.

TYPES: BEGIN OF T_FINAL,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_FINAL.

TYPES: IT_KNA1 TYPE TABLE OF T_KNA1,
WA_KNA1 TYPE T_KNA1,
IT_T001 TYPE TABLE OF T_T001,
WA_T001 TYPE T_T001,
IT_VBRK TYPE TABLE OF T_VBRK,
WA_VBRK TYPE T_VBRK,
IT_VBRP TYPE TABLE OF T_VBRP,
WA_VBRP TYPE T_VBRP,
IT_FINAL TYPE TABLE OF T_FINAL,
WA_FINAL TYPE T_FINAL.



Click on Initialization .

Input parameters:
S_VBELN

Output parameters:
IT_FINAL
WA_FINAL
IT_VBRK
IT_KNA1
IT_VBRP
WA_KNA1
WA_T001
WA_VBRK
WA_VBRP

code:

select VBELN
FKDAT
WAERK
KUNAG
BUKRS
from VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN = s_vbeln.

SELECT LAND1
NAME1
ORT01
PSTLZ
STRAS INTO CORRESPONDING FIELDS OF TABLE IT_KNA1
FROM KNA1 FOR ALL ENTRIES IN IT_VBRK
WHERE KUNNR = IT_VBRK-KUNAG.

SELECT NETWR
MATNR
ARKTX
POSNR
VBELN
FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
FOR ALL ENTRIES IN IT_VBRK
WHERE VBELN = IT_VBRK-VBELN.

READ TABLE IT_VBRK INTO WA_VBRK INDEX 1.
IF SY-SUBRC = 0.

SELECT SINGLE BUTXT
ORT01
LAND1
FROM T001 INTO CORRESPONDING FIELDS OF WA_T001
WHERE BUKRS = WA_VBRK-BUKRS.

ENDIF.

LOOP AT IT_VBRP INTO WA_VBRP.
READ TABLE IT_VBRK INTO WA_VBRK WITH KEY VBELN = WA_VBRP-VBELN.

IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_VBRK TO WA_FINAL.
MOVE-CORRESPONDING WA_VBRP TO WA_FINAL.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.


Click on main window. option and create windows


select Image u want to dispaly on smart form.


Create a table for a window.

fields in table split it and adjust length of each cell.


give the loop name here.


Now create the table line here.



give the cell name here, then it reads all the cells in it.


Now create the text for the cells


click on the Editor then you will get the below image then give the field thr.


* is important.


Create the same as for all the other cells also.



Now for Header. just create a P1 style.(ZDEMO_SMATRSTYLE given below after this)


same way for all other windows.



for this window we have to create a loop. so follow the image.


give the loop name here.

now give the fields for this window.



Note: this window is created for only coloring the box. CUSTOMER ADDRESS


Now Execute it.


give the vbeln


output preview.






Done!..
-----------------------------------------------------------------


Creating a smart style.










Done!..


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.