sap exercise on smartforms

20
EXERCISE ON ALV AND SMARTFORMS Requirements FUNCTIONAL DESCRIPTION The purpose of this document is to display Sales Order acknowledgement. The smart form displays detail of the order which can be printed 1. execute custom transaction to display the sales order data based on selection screen entries 2. display of an ALV report based on the layout selected in selection screen with sales order fields 3. proving an option to the user to view smart form with organization details Functional Specification. 1. Create a report with the following in selection screen. a. Sales document(VBAK-VBELN) b. Document Creation date(VBAK-ERDAT) c. Sales Organization(VBAK-VKORG) d. Layout (DISVARIANT-VARIANT) 2. Display ALV Grid Report with the following fields a. Sales document no b. Document creation date c. Document category d. Sales Organization e. Distribution Channel f. Division g. Sales Group h. Sales office i. Customer number. 3. If user clicks on the SD number then display the Smart form with a. Order Number b. Order Line Item c. Order Type d. Creation Date e. Created By

Upload: waseem-ahmad

Post on 17-Nov-2015

140 views

Category:

Documents


12 download

DESCRIPTION

smartforms exercises

TRANSCRIPT

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

EXERCISE ON ALV AND SMARTFORMS

RequirementsFUNCTIONAL DESCRIPTION The purpose of this document is to display Sales Order acknowledgement. The smart form displays detail of the order which can be printed

1. execute custom transaction to display the sales order data based on selection screen entries

2. display of an ALV report based on the layout selected in selection screen with sales order fields

3. proving an option to the user to view smart form with organization details

Functional Specification.

1. Create a report with the following in selection screen.

a. Sales document(VBAK-VBELN)

b. Document Creation date(VBAK-ERDAT)

c. Sales Organization(VBAK-VKORG)

d. Layout (DISVARIANT-VARIANT)

2. Display ALV Grid Report with the following fields

a. Sales document no

b. Document creation date

c. Document category

d. Sales Organization

e. Distribution Channel

f. Division

g. Sales Group

h. Sales office

i. Customer number.

3. If user clicks on the SD number then display the Smart form with

a. Order Number

b. Order Line Item

c. Order Type

d. Creation Date

e. Created By

f. Header Sold to

g. Customer Group

h. Material number

i. Material Description

j. Line Item sold to

4. If user clicks on the Customer number then display with the following dataa. Customer numberb. Name

c. House number and street

d. City

e. Region state

f. Postal code

Team Members SHANKAR BM

YASHWANTH REDDY

SHAIK FAHAD

SHRADDHA SHARMA ----------------------------------------------**&ReportZ_CASESTUDY_GROUP1*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*

REPORTZ_CASESTUDY_GROUP1.

TYPE-POOLS:SLIS.TABLES:VBAK,VBAP,VBPA,KNA1,VBKD,MAKT.

*DECLAREASTRUCTURESELECTINGDESIREDFIELDSFROMVBAKANDVBPATABLESTYPES:BEGINOFTY_VBAK,VBELNTYPEVBAK-VBELN,ERDATTYPEVBAK-ERDAT,VBTYPTYPEVBAK-VBTYP,VKORGTYPEVBAK-VKORG,VTWEGTYPEVBAK-VTWEG,SPARTTYPEVBAK-SPART,VKGRPTYPEVBAK-VKGRP,ERNAMTYPEVBAK-ERNAM,VKBURTYPEVBAK-VKBUR,KUNNRTYPEVBPA-KUNNR,ENDOFTY_VBAK.

*CREATEANINTERNALTABLEANDAWORKAREAFORINTERNALTABLE

DATA:IT_VBAKTYPESTANDARDTABLEOFTY_VBAK,WA_VBAKTYPETY_VBAK.

*DECLAREASTRUCTURESELECTINGDESIREDFIELDSFROMVBPATABLETYPES:BEGINOFT_VBPA,VBELNTYPEVBPA-VBELN,KUNNRTYPEVBPA-KUNNR,ENDOFT_VBPA.

*CREATEANINTERNALTABLEANDAWORKAREAFORINTERNALTABLE

DATA:IT_VBPATYPESTANDARDTABLEOFT_VBPA,WA_VBPATYPET_VBPA.

*DECLAREASTRUCTURESELECTINGDESIREDFIELDSFROMKNA1TABLE

TYPES:BEGINOFT_KNA1,KUNNRTYPEKNA1-KUNNR,NAME1TYPEKNA1-NAME1,STRASTYPEKNA1-STRAS,ORT01TYPEKNA1-ORT01,REGIOTYPEKNA1-REGIO,PSTLZTYPEKNA1-PSTLZ,TELF1TYPEKNA1-TELF1,TELFXTYPEKNA1-TELFX,ENDOFT_KNA1.

*CREATEANINTERNALTABLEANDAWORKAREAFORINTERNALTABLE

DATA:IT_KNA1TYPESTANDARDTABLEOFT_KNA1,WA_KNA1TYPET_KNA1.

*CREATEANINTERNALTABLEUSINGTABLETYPEDEFINEDINDATADICTIONARYANDITSCORRESPONDINGWORKAREA

DATA:I_TABLETYPEZWT_SMART,WA_TABLETYPEZWA_SMART.

*DECLAREINTERNALTABLESTOBUILDFIELDCATALOG

DATA:FIELDCATALOGTYPESLIS_T_FIELDCAT_ALVWITHHEADERLINE,"foralvFIELDCATALOG_POPTYPESLIS_T_FIELDCAT_ALVWITHHEADERLINE."forpopup

DATA:Z_SAVETYPECVALUE'A',Z_VARIANTLIKEDISVARIANT,ZX_VARIANTLIKEDISVARIANT,Z_EXITTYPEC,REPNAMELIKESY-REPID.

DATA:DUMMYTYPEVBAK-VKORG.

*INITIALIZATIONEVENT

INITIALIZATION.REPNAME=SY-REPID.PERFORMINITIALIZE_VARIANT.

*DATA:Z_LAYOUTTYPESLIS_LAYOUT_ALV.

SELECTION-SCREEN:BEGINOFBLOCKB1WITHFRAMETITLETEXT-001.SELECT-OPTIONS:S_VBELNFORVBAK-VBELNOBLIGATORY,S_ERDATFORVBAK-ERDATOBLIGATORY.

PARAMETERS:P_VKORGTYPEVBAK-VKORG.PARAMETERS:P_LAYOUTTYPEDISVARIANT-VARIANT.SELECTION-SCREENENDOFBLOCKB1.

ATSELECTION-SCREENONVALUE-REQUESTFORP_LAYOUT.PERFORMF4_VALUE_REQUEST.

ATSELECTION-SCREEN.SELECTSINGLEVKORGFROMVBAKINTODUMMYWHEREVKORG=P_VKORG.IFSY-SUBRC0.MESSAGEE398(00)WITHTEXT-003.ENDIF.PERFORMPAI_OF_SELECTION_SCREEN.

*START-OF-SELECTIONEVENT

START-OF-SELECTION.

PERFORMDATA_RETRIEVAL."POPULATEINTERNALTABLESPERFORMBUILD_FIELDCATOLOG."POPULATEFIELDCATALOGINTERNALTABLEFORCREATINGALVGRIDDISPLAYPERFORMBUILD_FIELDCATALOG_POP."POPULATEFIELDCATALOG_POPINTERNALTABLEFORCREATINGpopup*PERFORMZY_LAYOUT.PERFORMALVDISPLAY."TODISPLAYALVGRIDREPORT

*&---------------------------------------------------------------------**&FormDATA_RETRIEVAL*&---------------------------------------------------------------------**text*----------------------------------------------------------------------**-->p1text*p1text*p1text*FP_FCODEtext*-->FP_SELFIELDtext*----------------------------------------------------------------------*FORMUSER_COMMANDUSINGFP_FCODETYPESY-UCOMMFP_SELFIELDTYPESLIS_SELFIELD.

*DECLARELOCALVARIABLES

DATA:LV_FIELD_CLICKEDTYPESLIS_SELFIELD-FIELDNAME,LV_FIELD_VALUETYPESLIS_SELFIELD-VALUE,LV_DATATYPESTRING.

LV_FIELD_CLICKED=FP_SELFIELD-FIELDNAME.LV_FIELD_VALUE=FP_SELFIELD-VALUE.

LV_DATA=LV_FIELD_VALUE."TYPECONVERSION

SELECTPOSNRMATNRKWMENGFROMVBAPINTOCORRESPONDINGFIELDSOFTABLEI_TABLEWHEREVBELN=LV_DATA."CORRESPONDINGFIELDSPOPULATEDINTOI_TABLE

LOOPATI_TABLEINTOWA_TABLE.

SELECTSINGLEMAKTXFROMMAKTINTOWA_TABLE-MAKTXWHEREMATNR=WA_TABLE-MATNR.SELECTSINGLEKUNNRFROMVBPAINTOWA_TABLE-KUNNRWHEREVBELN=LV_DATA.

MODIFYI_TABLEFROMWA_TABLE.ENDLOOP."INTERNALTABLEI_TABLEPOPULATED

DATA:KD_GRPTYPEVBKD-KDGRP.SELECTSINGLEKDGRPFROMVBKDINTOKD_GRPWHEREVBELN=LV_DATA.

DATA:WA_SMARTTYPEZTY_SMART.CLEARWA_VBAK.READTABLEIT_VBAKINTOWA_VBAKINDEXFP_SELFIELD-TABINDEX.MOVE-CORRESPONDINGWA_VBAKTOWA_SMART.WA_SMART-KDGRP=KD_GRP.

CASELV_FIELD_CLICKED.

WHEN'VBELN'."WHENUSERCLICKSONSALESDOCUMENTNUMBERFIELD(HOTSPOT)

DATA:WA_SOLDTYPEZSOLDTO.SELECTSINGLEKUNNRNAME1ORT01FROMKNA1INTOWA_SOLDWHEREKUNNR=LV_FIELD_VALUE.

DATA:DATA1TYPETDSFNAMEVALUE'ZCASESTUDY1',DATA2TYPERS38L_FNAM.

CALLFUNCTION'SSF_FUNCTION_MODULE_NAME'"FMUSEDTORETRIEVESYSTEMGENERATEDSMARTFORMFUNCTIONNAMEEXPORTINGFORMNAME=DATA1*VARIANT=''*DIRECT_CALL=''IMPORTINGFM_NAME=DATA2EXCEPTIONSNO_FORM=1NO_FUNCTION_MODULE=2OTHERS=3.IFSY-SUBRC0.MESSAGEIDSY-MSGIDTYPESY-MSGTYNUMBERSY-MSGNOWITHSY-MSGV1SY-MSGV2SY-MSGV3SY-MSGV4.ENDIF.CALLFUNCTIONDATA2"CALLFMGENERATEDFORSMARTFORMEXPORTINGVBELN_VALUE=LV_DATAWA_SMARTFORM=WA_SMARTI_INTERFACE=I_TABLEWA_SOLDTO=WA_SOLD.

WHEN'KUNNR'."WHENUSERCLICKSONCUSTOMERNUMBERFIELD(HOTSPOT)

SELECTKUNNRNAME1STRASORT01REGIOPSTLZTELF1TELFXFROMKNA1INTOTABLEIT_KNA1WHEREKUNNR=LV_FIELD_VALUE.

CALLFUNCTION'REUSE_ALV_POPUP_TO_SELECT'"FMUSEDTOCREATEPOPUPATRUNTIMEEXPORTING*I_TITLE=*I_SELECTION='X'*I_ALLOW_NO_SELECTION=*I_ZEBRA=''*I_SCREEN_START_COLUMN=0*I_SCREEN_START_LINE=0*I_SCREEN_END_COLUMN=0*I_SCREEN_END_LINE=0*I_CHECKBOX_FIELDNAME=*I_LINEMARK_FIELDNAME=*I_SCROLL_TO_SEL_LINE='X'I_TABNAME='IT_KNA1'*I_STRUCTURE_NAME=IT_FIELDCAT=FIELDCATALOG_POP[]*IT_EXCLUDING=*I_CALLBACK_PROGRAM=*I_CALLBACK_USER_COMMAND=*IS_PRIVATE=*IMPORTING*ES_SELFIELD=*E_EXIT=TABLEST_OUTTAB=IT_KNA1*EXCEPTIONS*PROGRAM_ERROR=1*OTHERS=2.IFSY-SUBRC0.*MESSAGEIDSY-MSGIDTYPESY-MSGTYNUMBERSY-MSGNO*WITHSY-MSGV1SY-MSGV2SY-MSGV3SY-MSGV4.ENDIF.ENDCASE.

*

ENDFORM."USER_COMMANDWhen we press F8 we will get the following selection screen

Executing the above will take you to the below screen where you will get the ALV display

Clicking on any sales document number will generate the SmartForm for the corresponding entry

Here 1st entry is clicked

When you click on the customer number on ALV a pop up is displayed with the following fields