Professional Documents
Culture Documents
IIB BM MA AP PD DE EV VT Te ea am m
Table of Contents
2.3.10 CHAPTER 1 USEFUL TRANSACTIONS 3 CHAPTER 3 1.1 EDI SPECIFIC TRANSACTIONS---------------3 1.1.1 SCHEDULING AGREEMENTS........................ 3 1.2 MESSAGE CONTROL ----------------------------3 1.2.1 DELIVERY ................................................. 3 1.2.2 INVOICE .................................................... 3 1.2.3 ORDER RESPONSE .................................... 3 1.2.4 IDOC ADMINISTRATION .............................. 3 1.2.5 IDOC DEVELOPMENT ................................. 4 1.2.6 REQUIREMENTS CODING ............................ 4 CHAPTER 2 USEFUL PROGRAMS AND FUNCTION 5 3.1 GENERAL PROGRAMMING 186 STEP LOOP........................................... 180
3.2 DIALOG PROGRAMMING ------------------- 186 3.2.1 PROCESS ON VALUE REQUEST F4 ....... 186 3.3 REPORTS----------------------------------------- 187 3.3.1 REFRESHING DATA ON REPORTS ........... 187 3.3.2 TREE REPORTS .................................... 188 3.3.3 INITIALIZING DATE RANGES ON SELECTIONOPTIONS 191 3.3.4 REPORT HEADINGS ............................... 191 3.3.5 POPUP SELECTION GET FILENAME ...... 192 3.3.6 CHECKBOXES IN REPORTS ..................... 192 3.3.7 LIST BOXES ON SELECTION SCREENS .... 192 3.3.8 AT LINE SELECTION ............................... 193 3.3.9 TABSTRIPS ON A SELECTION SCREEN ..... 193 3.3.10 DYNAMIC SELECTION SCREENS .............. 194 3.4 FILE PROCESSING ---------------------------- 195 3.4.1 DOWNLOADING TO EXCEL...................... 195 3.4.2 FTP A FILE TO ANOTHER SERVER ........... 196 3.4.3 DATASET ........................................... 197 3.4.4 WS_DOWNLOAD............................... 198 3.4.5 GUI_DOWNLOAD WITH POPUP FILENAME REQUEST 199 3.5 MACROS ------------------------------------------ 200
2.1 FUNCTION MODULES ---------------------------5 2.1.1 STANDARD FUNCTION MODULE .................. 5 2.1.2 CUSTOM FUNCTION MODULE .................... 12 2.2 PROGRAMS --------------------------------------- 18 2.2.1 RHSOBJCH FIXES PD CONTROL TABLES MISSING IN TX SWU3............................................. 18 2.2.2 RV80HGEN........................................... 18 2.2.3 SCHEDULING OF SYSTEM MAINTENANCE JOBS 19 2.2.4 G/L ACCOUNT LINE ITEM DISPLAY ........... 20 2.2.5 FI-SL: REVERSAL OF ACTUAL DOCUMENTS20 2.2.6 SET DOCUMENT SELECT PATH .................. 20 2.2.7 CHECK IF ALL THE CHARACTER IN A STRING ARE NUMERIC 20 2.2.8 BACKGROUND JOB SET BY PROGRAM ....... 21 2.2.9 DYNAMIC INTERNAL TABLE DEFINE ............ 22 2.2.10 INTERNAL TABLE OPTIMIZATION ................ 23 2.2.11 DOWNLOAD OR UPLOAD FORM ................ 24 2.2.12 FIND ENHANCEMENT ............................... 24 2.2.13 FIND IMG TCODE .................................... 28 2.2.14 DYNAMIC REFURBISH REPORT .................. 31 2.2.15 SMW0 --WEB REPOSITORY .................... 34 2.2.16 ALV GROUP ........................................... 34 2.2.17 SAP SCRIPT ........................................... 57 2.3 INTEGRATED TRANSACTION------------- 100 2.3.1 CREATE INFO TYPE ............................... 100 2.3.2 LSMW ................................................. 112 2.3.3 BADI.................................................... 130 2.3.4 REPORT TREE ...................................... 150 2.3.5 DIS-ACTIVE STANDARD BUTTON ............. 152 2.3.6 SCREEN ENHANCEMENT ON MM01........ 153 2.3.7 QUERY ................................................. 154 2.3.8 BTE ..................................................... 170 2.3.9 .............................................. 176
3.6 SELECT STATEMENTS ---------------------- 201 3.6.1 JOINS ................................................... 201 3.6.2 FOR ALL ENTRIES .................................. 202 3.7 GENERAL----------------------------------------- 203 3.7.1 RETRIEVING THE EMAIL ADDRESS OF AN SAP 203 USER 3.7.2 EXECUTING A PROGRAM ........................ 204 3.7.3 CHANGING \ CREATING REQUIREMENTS . 204 3.7.4 DISPLAYING TRANSACTION .................... 204 3.7.5 GUI-STATUS ........................................ 204 3.7.6 DOCUMENT FLOW ................................. 204 3.7.7 MAINTAINING TRAILING SPACES WHEN DOWNLOADING TO PC ......................................... 205 3.7.8 HIDING ABAP SOURCE CODE ............... 205 3.7.9 WHERE IN IMG IS A TABLE CONFIGURED. 205 3.7.10 EDITOR TIPS (*EJECT AND *$*$) .......... 205 3.7.11 LIST OF WAYS TO TRANSPORT VARIANTS 206 3.7.12 CHECKING FOR BACKGROUND PROCESSING 206 CHAPTER 4
2008-09
WORKFLOW PROGRAMS
207
Page 1 of 328
Dong.Ping
4.1
5.3 ALV GRID CONTROL------------------------- 219 5.3.1 ADDING CUSTOM BUTTONS ON ALV GRID CONTROLS .......................................................... 219 5.3.2 HIGHLIGHT LINES................................... 223 5.3.3 FIRST LINE VISIBLE ................................ 223 5.3.4 READ ONLY TEXT BOX ............................ 223 5.3.5 ENTERING TEXT .................................... 224 CHAPTER 6 6.1 6.2 6.3 6.4 IDOC PROGRAMMING 226
CREATING AN IDOC-------------------------- 226 SENDING AN IDOC---------------------------- 226 CHANGING AN IDOC ------------------------- 226 CHANGING AN IDOCS STATUS --------- 227
BDC PROCESSING & IDOC STATUS UPDATE 232 6.10.3 MAILING IN SAP.................................... 234 6.10.4 PROGRAM EXAMPLE REPORT TO SHOW EDI STATUS 239 6.10.5 EXAMPLE UPLOAD FILE TO IDOC ............ 252 6.10.6 IDOC CREATION FROM INBOUND FILE ...... 259 6.10.7 LIST TRANSACTIONS .............................. 271 6.10.8 REPORT WITH JOINS AND MACROS ......... 273 6.10.9 GRAPHICAL POPUP PROGRESS DISPLAY279 6.10.10 CHANGE IDOC STATUS TO ERROR STATUS AND SEND TO WORKFLOW ........................................... 280 6.10.11 REPORT TO DOWNLOAD PROGRAMS ....... 287 6.10.12 DISPLAY TABLE IN HTML....................... 296 6.10.13 TREE REPORTS ..................................... 299 6.10.14 SHELL LIST REPORT OFF A TABLE - NAST302 6.10.15 ALV REPORT ........................................ 307 6.10.16 SAP GENERATED REPORT \ DIALOG PROGRAM 311 6.10.17 LIST OF TRANSACTIONS REPORT ............ 322 CHAPTER 7 BASIS ERRORS AND RESOLUTIONS 325
6.10.2
6.5 READING AN IDOC --------------------------- 227 6.5.1 EXAMPLE OPEN DOCUMENT FOR READ 227 6.6 6.7 6.8 DISPLAYING AN IDOC ----------------------- 228 IDOC TYPE POOL ----------------------------- 228 LAUNCHING AN ERROR WORKFLOW - 228
7.1
GL --------------------------------------------------- 327 OF --------------------------------------------------- 327 CRM ------------------------------------------------ 327 I2 ECOMMERCE -------------------------------- 327 I2 PLANNING ------------------------------------ 327 PE --------------------------------------------------- 327 FI----------------------------------------------------- 328 GPDP----------------------------------------------- 328
6.9 RETURNING IDOCS LINKED TO DOCUMENTS -------------------------------------------- 230 6.9.1 * RETURN THE LIST OF IDOCS LINKED TO THE DELIVERY230 6.9.2 * RETURN THE LIST OF IDOCS LINKED TO THE INVOICE 230 6.9.3 VERSION 4.6X ...................................... 230 6.10 EXAMPLES -------------------------------------- 232 6.10.1 WRITE IDOC STATUS ............................. 232
2008-09
Page 2 of 328
Dong.Ping
1.1
VOE1 VOE2 VOE3 VOE4 OVAI
OVAJ
1.2
NACE
MESSAGE CONTROL
Links to all the message control transactions via the application area
1.2.1 Delivery
V/36 Maintain output determination for deliveries (Output determination procedures) V10000 (Header output) has condition type LAVA (usually with requirement 1 NB: Use V/84 V7ALLE SHAD for grouped ASNs. I.e. Group deliveries into shipments Create output condition records for shipping. LAVA WE (Partner function) - We must add each new partner with VV21 Reissue output for deliveries
VV21 VL71
1.2.2 Invoice
V/54 VV31 VF31 Maintain access sequence for billing documents Create condition records for billing documents. (RD00 RE Billing party) Reissue output for billing documents
Dong.Ping
IDoc lists according to content. View IDocs via specific IDoc number or business application detail contained within the contents of a segment. View IDocs IDoc type documentation tool Partner profile configuration. Add partner detail together with inbound and outbound relationships. We also incorporate message control on the outbound IDocs. Utilize the organizational units to trap functional errors for further processing. Reprocess IDocs in error or waiting for action. (Both inbound and outbound in 4.6. Use BD88 in prior versions)
BD87
2008-09
Page 4 of 328
SD_VBAP_READ_WITH_VBELN EDIT_LINES VIEW_MAINTENANCE_CALL DY_GET_FOCUS DY_GET_SET_FIELD_VALUE F4IF_INT_TABLE_VALUE_REQUEST READ_TEXT CONVERSION_EXIT_CUNIT_OUTPUT SJIS_DBC_TO_SBC SJIS_SBC_TO_DBC CO_R0_CHECK_DECIMAL_POINT POSTAL_CODE_CHECK CONVERSION_EXIT_ALPHA_INPUT GET_JOB_RUNTIME_INFO TERMINAL_ID_GET DATE_CONVERT_TO_FACTORYDATE MESSAGE_TEXT_BUILD POPUP_TO_CONFIRM CONVERSION_EXIT_MATN1_INPUT CONVERSION_EXIT_MATN1_OUTPUT SSF_FUNCTION_MODULE_NAME DATE_CHECK_PLAUSIBILITY cl_gui_frontend_services=>gui_upload cl_gui_frontend_services=>gui_download SSF_FUNCTION_MODULE_NAME SMARTFORMS POPUP_TO_DECIDE_LIST ABAP_DOCU_DOWNLOAD BAL_* BP_EVENT_RAISE BP_JOBLOG_READ CLOI_PUT_SIGN_IN_FRONT CLPB_EXPORT CLPB_IMPORT COMMIT_TEXT CONVERSION_EXIT_ALPHA_INPUT CONVERSION_EXIT_ALPHA_OUTPUT CONVERT_OTF
vbap READ_TEXT LINES TDFORMAT=* help 0 job id form (SmartForm) CHECK CALL HTML ABAP SAP ABAP/4 job log SAP SAP 0 0 SAP (SAP Script)
2008-09
Example
Page 5 of 328
DATE_GET_WEEK DATE_CHECK_PLAUSIBILITY DYNP_VALUES_READ DYNP_VALUES_UPDATE ENQUE_SLEEP ENQUEUE_ESFUNCTION EPS_GET_FILE_ATTRIBUTES EPS_GET_DIRECTORY_LISTING F4_DATE F4IF_SHLP_EXIT_EXAMPLE FILENAME_GET FTP_CONNECT FTP_COMMAND FTP_DISCONNECT GET_GLOBAL_SYMBOLS GET_INCLUDETAB WS_FILE_DELETE GUI_CREATE_DIRECTORY GUI_REMOVE_DIRECTORY cl_gui_frontend_services=>file_delete GUI_DELETE_FILE GUI_DOWNLOAD GUI_EXEC GUI_GET_DESKTOP_INFO GUI_RUN GUI_UPLOAD
SAP SCREEN SELECTION SCREEN ABAP F4 FTP FTP FTP tables, select options, texts, etc selection screen INCLUDES
Delete.txt
WS_EXECUTE WS_QUERY WS_UPLOAD (Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level) Factory Calendar&/ Holiday Calendar SAP INI INI
2008-09
Download.txt
HELP_START
HOLIDAY_GET INIT_TEXT POPUP_TO* PRICING PROFILE_GET PROFILE_SET READ_TEXT REGISTRY_GET REGISTRY_SET RP_CALC_DATE_IN_INTERVAL
Page 6 of 328
RP_LAST_DAY_OF_MONTHS LAST_DAY_IN_PERIOD_GET RPY_DYNPRO_READ SXPG_COMMAND_CHECK TH_DELETE_USER TH_POPUP UNIT_CONVERSION_SIMPLE WS_DOWNLOAD WS_EXCEL WS_EXECUTE WS_MSG WWW_LIST_TO_HTML SD_VBAP_READ_WITH_VBELN EDIT_LINES VIEW_MAINTENANCE_CALL DY_GET_SET_FIELD_VALUE F4IF_INT_TABLE_VALUE_REQUEST CONVERSION_EXIT_CUNIT_OUTPUT SJIS_DBC_TO_SBC SJIS_SBC_TO_DBC CO_R0_CHECK_DECIMAL_POINT POSTAL_CODE_CHECK TERMINAL_ID_GET idDATE_CONVERT_TO_FACTORYDATE MESSAGE_TEXT_BUILD CONVERT_TO_LOCAL_CURRENCY SSF_FUNCTION_MODULE_NAME DATE_CHECK_PLAUSIBILITY CHECKcl_gui_frontend_services=>gui_upload cl_gui_frontend_services=>gui_download SSF_FUNCTION_MODULE_NAME DAY_IN_WEEK RP_CALC_DATE_IN_INTERVAL BKK_ADD_MONTH_TO_DATE GUI_CREATE_DIRECTORY GUI_DELETE_FILE GUI_DOWNLOAD GUI_EXEC GUI_GET_DESKTOP_INFO GUI_RUN GUI_UPLOAD GET_CURRENT_YEAR GET_SF_DUNN_DATA
SM04 EXCEL HTML vbap READ_TEXT LINES TDFORMAT=* help GET_JOB_RUNTIME_INFO job , form (SmartForm) SMARTFORMS CALL / PC PC PC PC PC ShellExecute PC fiscal year
dunning
ReadMess.txt
letter
Page 7 of 328
2008-09
Progress Indicator.txt
.txt
Read Delivery.txt
KOMKBV1_FILL
MASTER_IDOC_DISTRIBUTE IDOC_TYPE_COMPLETE_READ ABAP_DOCU_DOWNLOAD ARFC_GET_TID BAL_* BP_EVENT_RAISE BP_JOBLOG_READ CLOI_PUT_SIGN_IN_FRONT CLPB_EXPORT CLPB_IMPORT COMMIT_TEXT CONVERSION_EXIT_ALPHA_INPUT CONVERSION_EXIT_ALPHA_OUTPUT CONVERT_OTF DATE_GET_WEEK DATE_CHECK_PLAUSIBILITY DOWNLOAD DYNP_VALUES_READ
DYNP_VALUES_UPDATE
F4_DATE
2008-09
Page 8 of 328
documents the different reasons to use a search help exit, and shows how it is done. popup to get a filename from a user, returns blank filename if user selects cancel Open a connection (and log in) to an FTP server Execute a command on the FTP server Close the connection (and log off) the FTP server Takes a message id and number, and puts it into a variable. Works better than WRITE_MESSAGE, since some messages use $ as a place holder, and WRITE_MESSAGE does not accommadate that, it only replaces the ampersands (&) in the message. Returns a list of all tables, select options, texts, etc for a program. Even includes the text definitions for the selection screen Returns a list of all INCLUDES in a program Fetch values from a set Function Group GRAP is now obsolete. SAP recommends using functions in function group SFES instead. Below is an overview of the changes Create a directory on the presentation server Replaces WS_FILE_DELETE. Delete a file on the presentation server Replaces WS_DOWNLOAD. Download table from the app server to presentation server Replaces WS_EXECUTE. Start a File or Program Asynchronously with WinExec Replaces WS_QUERY. Delivers Information About the Desktop (client) Delete a directory on the presentation server Start a File or Program Asynchronously with ShellExecute Replaces WS_UPLOAD. Upoad file from presentation server to the app server Display help for a field. Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level. Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar. is an HR function, but can be used for any data. You pass it data, and column headers, and it provides a table control with the ability to manipulate the data, and send it to Word or Excel. Also see the additional documentation here. Get all leave information (includes leave entitlement, used holidays/paid out holidays) To load long text into SAP Return a list of all plants for a given company code convert an ABAP report (displayed on screen) from OTF to ASCII format Retrieves the output of a report from memory when the report was executed using SUBMIT... EXPORTING LIST TO MEMORY. See also WRITE_LIST. 2008-09 Page 9 of 328
FORMAT_MESSAGE
GET_GLOBAL_SYMBOLS GET_INCLUDETAB
G_SET_GET_ALL_VALUES
HELP_START
HOLIDAY_GET
HR_DISPLAY_BASIC_LIST
LIST_FROM_MEMORY
It returns all the month and names in repective language. will build a file, and automatically start Excel wraps several other function modules. Will convert OTF to ASCII or PDF converts a OTF spool to PDF (i.e. Sapscript document) convert abap spool output to PDF Create a dialog box in which you make a question whether the user wishes to perform a processing step with loss of data. Create a dialog box in which you make a question whether the user wishes to perform the step. Create a dialog box in which you inform the user about a specific decision point during an action. Create a dialog box in which you make a question whether the user wishes to perform a processing step with a particular object Provide user with several choices as radio buttons Create a dialog box in which you inform the user about a specific decision point via a diagnosis text. Create a dialog box in which you display a two-line message Popup to choose a month Provide a display of a table for user to select one, with the value of the table line returned when selected. Return pricing conditions in an internal table. Use structure TCOMK for parameter COMM_HEAD_1, and structure TCOMP for parameter COMM_ITEM_1, and set CALCULATION_TYPE to B. The pricing conditions will be returned in XOMV. You must fill TCOMP, and TCOMK with the appropriate values before callling the function in order for it to work. Read an Entry in an INI File on the frontend Write an Entry in an INI File on the frontend To load long text into SAP Read an Entry from the Registry Set an entry in the Registry Runs an ABAP program that is stored in the table PROGRAM when the MODE = 'F'. Table WRITES contains the ouput of the program. Allows you to run a program without having the source code in the target system. Return the active HR Plan return the day based on the date provied starts Excel with the contents of an internal table. This function finds Excel in the desktop registry. It also uses a local PC working directory to save the file (that's what the "W" value for data path flag does). Very transparent to user! Returns all related org info 2008-09 Page 10 of 328
POPUP_TO_CONFIRM_STEP
POPUP_TO_CONFIRM_WITH_MESSAGE
PRICING
RFC_ABAP_INSTALL_AND_RUN
RH_GET_ACTIVE_WF_PLVAR RH_GET_DATE_DAYNAME
RH_START_EXCEL_WITH_DATA
RH_STRUC_GET
Add/subtract years/months/days from a date Determine last day of month Read dynpro, including screen flow Given a transaction, return the program and screen or given a program and screen, return the transactions that use the program and screen. Returns an internal table that contains a formatted list of all the selection parameters entered for a report. Table is ready to print out. Get the current contents of selection screen Send message from ABAP/4 program to SAPoffice. Returns the contents of the specified variant in a table. Hang the current application from 1 to 5 seconds. Submit a remote report. Read a directory on the Application Server If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server Read a file from the presentation server if no server name is given, or read file from remote server. Very useful to avoid authority checks that occur doing an OPEN DATASET. This function using a SAP C program to read the data. Saves table to the presentation server (not PC). Does not use OPEN DATASET, so it
RPY_TRANSACTION_READ
RZL_READ_DIR
RZL_READ_FILE
RZL_WRITE_FILE_LOCAL
SAPGUI_PROGRESS_INDICATOR SAVE_TEXT
SCROLLING_IN_TABLE
2008-09
Page 11 of 328
SXPG_CALL_SYSTEM
you can check the user's authorization for the specified command and run the command. The command runs on the host system on which the function module is executed. The function module is RFC-capable. It can therefore be run on the host system at which a user happens to be active or on another designated host system at which an R/3 server is active. Select a list of external OS command definitions. Read the definition of a single external OS command from the R/3 System's database. Check whether the user is authorized to execute the specified command on the target host system with the specified arguments. Check a user's authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system. Return the terminal id Logoff a user. Similar results to using SM04. Get the UNIX environment Display a popup system message on a specific users screen. Run a transaction on a remote server. Optionally provide BDC data to be used in the transaction Give information about the current user (sessions, workstation logged in from, etc) Show which users are logged into an app server convert weights from one UOM to another. upload a file to the presentation server (PC) Will load one or more files from app or presentation server Useful for writing out the list contents that result from the function Save Internal Table as File on the Presentation Server Start EXCEL on the PC execute a program on a windows PC Delete File at the Frontend Call File Selector Create a dialog box in which you display an one-line message. Load Files from the Presentation Server to Internal ABAP Tables Get the label from a frontend device After running a report, call this function to convert the list output to HTML.
SXPG_COMMAND_EXECUTE
TERMINAL_ID_GET TH_DELETE_USER TH_ENVIRONMENT TH_POPUP TH_REMOTE_TRANSACTION TH_USER_INFO TH_USER_LIST UNIT_CONVERSION_SIMPLE UPLOAD UPLOAD_FILES WRITE_LIST WS_DOWNLOAD WS_EXCEL WS_EXECUTE WS_FILE_DELETE WS_FILENAME_GET WS_MSG WS_UPLOAD WS_VOLUME_GET WWW_LIST_TO_HTML
2008-09
Page 12 of 328
DATA: w_temp_file(65), "Temp file path for excel template file. w_formkey LIKE wwwdatatab, w_ftemplate LIKE rlgrap-filename, w_fdata LIKE rlgrap-filename. w_formkey = 'MIZARR00414B'. w_ftemplate = 'C:\TEMP\ZARR00414B.XLT'. w_fdata = 'C:\TEMP\ZARR00414B.TXT'. CALL FUNCTION 'DOWNLOAD_WEB_OBJECT' EXPORTING key = w_formkey destination = w_ftemplate CHANGING temp = w_temp_file.
2.1.2.2 SO_DOCUMENT_SEND_API1 SAPoffice: Send new document with attachments using RFC Sample: DATA: it_user TYPE TABLE OF zdepot_mail WITH HEADER LINE, t_time TYPE char8, t_date TYPE char10. * mail DATA: doc TYPE sodocchgi1, pack TYPE TABLE OF sopcklsti1 WITH HEADER LINE, "package cont TYPE TABLE OF solisti1 WITH HEADER LINE, "content recv TYPE TABLE OF somlreci1 WITH HEADER LINE. "user
* user SELECT * INTO TABLE it_user FROM zdepot_mail. IF it_user[] IS INITIAL. EXIT. ENDIF. LOOP AT it_user . recv-receiver = it_user-bname. recv-rec_type = 'B'. "U-INTERNET APPEND recv. ENDLOOP. * content WRITE: sy-datum TO t_date, sy-uzeit TO t_time.
2008-09 Page 13 of 328
CONCATENATE 'Global link has interfaced to SAP system at ' t_time t_date text-011 INTO cont-line SEPARATED BY space. APPEND cont. CLEAR cont-line. cont-line = 'Thank you.'. APPEND cont. * package pack-transf_bin = space. pack-head_start = 1. pack-head_num = 0. pack-body_start = 1. pack-doc_type = 'RAW'. DESCRIBE TABLE cont LINES pack-body_num. APPEND pack. * document header doc-obj_descr = 'Interface Notification'. * mail function CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING document_data = doc TABLES packing_list = pack contents_txt = cont receivers = recv 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. ENDIF.
2008-09 Page 14 of 328
2.1.2.3 ALSM_EXCEL_TO_INTERNAL_TABLE
Upload data from Excel directly Sample: DATA: t1(255). DATA: i_begin_col TYPE i VALUE '1', i_begin_row TYPE i VALUE '2', i_end_col TYPE i VALUE '90', i_end_row TYPE i VALUE '60000'.
DATA: i_intern LIKE alsmex_tabline OCCURS 10 WITH HEADER LINE. DATA: i_return LIKE bapireturn1 OCCURS 10 WITH HEADER LINE.
CLEAR: txline. WRITE 'Upload Excel file from PC,Please wait...' TO txline. write_screen: txline.
DEFINE ins_msg. add 1 to c_err_no. check_msg-no = c_err_no. append check_msg. clear check_msg. c_l_error = 'X'. END-OF-DEFINITION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = p_file i_begin_col = i_begin_col i_begin_row = i_begin_row i_end_col = i_end_col i_end_row = i_end_row TABLES intern = i_intern EXCEPTIONS inconsistent_parameters = 1 upload_ole =2 OTHERS = 3. IF sy-subrc <> 0. CALL FUNCTION 'MESSAGE_TEXT_BUILD' EXPORTING msgid = sy-msgid msgnr = sy-msgno msgv1 = sy-msgv1 msgv2 = sy-msgv2 msgv3 = sy-msgv3 msgv4 = sy-msgv4 IMPORTING message_text_output = t1. check_msg-line = t1. ins_msg. ENDIF.
2008-09
Page 15 of 328
2.1.2.4 G_PERIOD_ALLOWED_CHECK
( Description: Check open posting periods,) SamPle: Spro *All
call function 'G_PERIOD_ALLOWED_CHECK' EXPORTING account_type = + company = bukrs company code period = P_POPER period periv_company = 'Z1' record_type = '0' to_account = ZZZZZZZZZZ default value year = P_GJAHR fiscal year EXCEPTIONS period_not_allowed = 1 not_authorized = 2 others = 3. *Customer call function 'G_PERIOD_ALLOWED_CHECK' EXPORTING account_type = D customer company = bukrs company code period = P_POPER period periv_company = 'Z1' record_type = '0' to_account = ZZZZZZZZZZ default value year = P_GJAHR fiscal year EXCEPTIONS period_not_allowed = 1 not_authorized = 2 others = 3.
2008-09
Page 16 of 328
*"---------------------------------------------------------------------if pi_money = 0. po_chinese = ''. exit. endif. data:money_str(13). money_str = pi_money. if money_str cn '0123456789. '. raise wrong_money. endif. data:i type i. if money_str cs '.'. i = sy-fdpos + 1. money_str+sy-fdpos = money_str+i. endif. condense money_str no-gaps. data:units_off type i, curnt_off type i. data:lastd type n,curntd type n. data:cword(2),weight(2). data:units(30) value '', digts(20) value ''. * clear:po_chinese,units_off. lastd = 0. curnt_off = strlen( money_str ) - 1. while curnt_off >= 0. curntd = money_str+curnt_off(1). i = curntd * 2. cword = digts+i(2). weight = units+units_off(2). i = units_off / 2. if curntd = 0. "Current digit is 0 if i = 2 or i = 6 or i = 10. clear:cword. if curnt_off = 0. clear:weight. endif. elseif lastd = 0. clear:cword,weight. else. clear:weight. endif. endif. concatenate cword weight po_chinese into po_chinese. lastd = curntd. subtract 1 from curnt_off. add 2 to units_off.
2008-09
Page 17 of 328
endwhile. if po_chinese ns ''. concatenate po_chinese '' into po_chinese. else. cword = po_chinese. if cword = ''. shift po_chinese by 2 places. endif. endif. endfunction.
2.2
PROGRAMS
RPR_ABAP_SOURCE_SCAN - Search ABAP code for a string. Has many more options for selecting the ABAPs to search than RSRSCAN1 or RKCTSEAR. RSBDCDRU - Prints the contents of a Batch Input session. No options for error transactions only. RSBDCOS0 - Execute UNIX commands. Looks similar to the old SAPMSOS0 program that disappeared in 3.0 RSWBO060 - put objects into a request and transport it to any other system RPUAUD00 - HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster. RPUAUDDL - HR Report to delete audit data from the PCL4 Audit Cluster. RPDTRA00 - List all HR transactions. RHGRENZ0 - Delimit IT1000 and related 1001s. Program will delete any 1001 infotypes whose start date is after the delimit date. RHGRENZ2 - Delimit IT1001 only. RHGRENZ1 - Extend the end date on delimited records. Very useful when you delimit a bunch of records incorrectly, and need to change the end date.
Notes on HRGRENZ0/HRBRENZ2: RHGRENZ0/2 will abend if there are any inconsistencies between PD and PA (i.e. people in a different controlling area than the position they belong to). Controlling area of a person is determined by the cost centre that a person's position is assigned to. When assigning a person to a position, SAP checks to make sure that the Controlling area of the company that the person belongs to is the same as that of the Cost centre that their position belongs to.
2008-09
Page 18 of 328
RKCTSEAR - Search source code for up to two strings. Also see RSRSCAN1 and RPR_ABAP_SOURCE_SCAN. RPUP1D00/10 - View/Delete data from PCL1 Cluster RPUP2D00/10 - View/Delete data from PCL2 Cluster RPUP3D00/10 - View/Delete data from PCL3 Cluster RPUP4D00/10 - View/Delete data from PCL4 Cluster RSTXSCRP Save a SAPScript layout set to disk, and load it back into SAP. RPUDELPN Delete all info for an employee number, including cluster data and infotypes. RSABAPIV Mass print/display of ABAP/4 help text RSBDCSUB Release batch-input sessions automatically RSBDCBTC - Submit a BDC job with an internal batch number and wait for the end of the batch-input session. RSCLTCOP Copy tables across clients RSAVGL00 Table adjustment across clients RSINCL00 Extended program list RSTXSCRP Transport SAPscript files across systems RSORAREL Get the Oracle Release RSRSCAN1 Search source code for a given string. Will also search includes. Also see RKCTSEAR and RPR_ABAP_SOURCE_SCAN. RSTBSERV Compare a contents of a table between clients RGUGBR00 Substitution/Validation utility RSPARAM Display all instance parameters RSUSR003 Check the passwords of users SAP* and DDIC in all clients RSUSR006 List users last login RSWBO052 Change development class of a sapscript (provided by Alan Cecchini)
2008-09
Page 19 of 328
**--- SELECT SCREEN selection-screen begin of block b1 with frame title text-000 . parameters:p_file type file_table-filename . "File name selection-screen end of block b1. **---- at selection-screen. data: t_file type string, t_rt type boolean. t_file = p_file. t_rt = cl_gui_frontend_services=>file_exist( t_file ). * Get file name at selection-screen on value-request for p_file.
data: t_rc type i, "For class--return code t_it_file type filetable, "For class--internal table t_wa_file type file_table. "For class--work area * Pop-up the dialog call method cl_gui_frontend_services=>file_open_dialog exporting window_title = 'Select file' file_filter = '*.TXT|*.TXT|*.*|*.*|' initial_directory = 'C:' multiselection = c_false changing file_table = t_it_file rc = t_rc exceptions file_open_dialog_failed = 1 cntl_error =2 error_no_gui =3 not_supported_by_gui = 4. * Get single file read table t_it_file into t_wa_file index 1. p_file = t_wa_file-filename.
2008-09
Page 20 of 328
DATA: num TYPE p value 3124141, ex TYPE REF TO cx_root. TRY. num = text. CATCH cx_root INTO ex. flag = c_true. ENDTRY.
"#EC *
* backgroud execute SUBMIT ZARI014 AND RETURN WITH p_back = c_true WITH p_sap = c_true WITH p_srv = c_false USER sy-uname VIA JOB t_jobname NUMBER t_jobcount TO SAP-SPOOL DESTINATION 'TNT_CHINA_FRONTEND' IMMEDIATELY ' ' KEEP IN SPOOL 'X' WITHOUT SPOOL DYNPRO. * close job CALL FUNCTION 'JOB_CLOSE' EXPORTING jobcount = t_jobcount jobname = t_jobname strtimmed = 'X'
"#EC *
2008-09
Page 21 of 328
EXCEPTIONS cant_start_immediate = 1 invalid_startdate = 2 jobname_missing =3 job_close_failed = 4 job_nosteps =5 job_notex =6 lock_failed =7 invalid_target =8 OTHERS = 9. * send message MESSAGE i208(00) WITH text-005. LEAVE PROGRAM.
perform write_table using <tab>. *&---------------------------------------------------------------------* *& Form write_table *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_<TAB> text
2008-09 Page 22 of 328
*----------------------------------------------------------------------* FORM write_table USING p_table type any table. field-symbols: <line> type data, <field> type data. loop at p_table assigning <line>. do. assign component sy-index of structure <line> to <field>. if sy-subrc <> 0. exit. endif. write:<field>. enddo. write:/. endloop. ENDFORM. " write_table
2.2.10
*&---------------------------------------------------------------------* *& Report ZPLATO2 * *&---------------------------------------------------------------------* REPORT ZPLATO2 . types: begin of my_line_type, name type string, birth_date type d, salary type p decimals 2, end of my_line_type, my_table_type type hashed table of my_line_type with unique key name birth_date. data: my_wa type my_line_type, my_table type my_table_type. start-of-selection. my_wa-name = 'plato'. my_wa-birth_date = '19800506'. my_wa-salary = '200000.00'. insert my_wa into table my_table. my_wa-name = 'April may june'.
2008-09 Page 23 of 328
my_wa-birth_date = '18904343'. my_wa-salary = '100000.00'. insert my_wa into table my_table. my_wa-name = 'mark tan'. my_wa-birth_date = '181204343'. my_wa-salary = '100.00'. insert my_wa into table my_table. perform write_table using my_table. *&---------------------------------------------------------------------* *& Form write_table *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM write_table using p_table type any table. field-symbols: <line> type data, <field> type data. write / '{'. loop at p_table assigning <line>. write /4 '('. do. assign component sy-index of structure <line> to <field>. if sy-subrc <> 0. exit. endif. write /8 <field>. enddo. "loop at component write /4 ')'. endloop. "loop at table write / '}'. ENDFORM. " write_table
2.2.11 2.2.12
*&--------------------------------------------------------*
*& Report Z_FIND_ENHANCEMENT *&--------------------------------------------------------* REPORT zbadi . TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir, sxs_attrt , tstct. DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE. DATA : field1(30). DATA : v_devclass LIKE tadir-devclass. PARAMETERS : p_tcode LIKE tstc-tcode, p_pgmna LIKE tstc-pgmna . DATA wa_tadir TYPE tadir. START-OF-SELECTION. IF NOT p_tcode IS INITIAL. SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode. ELSEIF NOT p_pgmna IS INITIAL. tstc-pgmna = p_pgmna. ENDIF. IF sy-subrc EQ 0. SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR' AND object = 'PROG' AND obj_name = tstc-pgmna. MOVE : tadir-devclass TO v_devclass. IF sy-subrc NE 0. SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna. IF trdir-subc EQ 'F'. SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna. SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname. SELECT SINGLE * FROM tadir
2008-09
Page 25 of 328
WHERE pgmid = 'R3TR' AND object = 'FUGR' AND obj_name EQ enlfdir-area. MOVE : tadir-devclass TO v_devclass. ENDIF. ENDIF. SELECT * FROM tadir INTO TABLE jtab WHERE pgmid = 'R3TR' AND object IN ('SMOD', 'SXSD') AND devclass = v_devclass. SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND tcode EQ p_tcode. FORMAT COLOR COL_POSITIVE INTENSIFIED OFF. WRITE:/(19) 'Transaction Code - ', 20(20) p_tcode, 45(50) tstct-ttext. SKIP. IF NOT jtab[] IS INITIAL. WRITE:/(105) sy-uline. FORMAT COLOR COL_HEADING INTENSIFIED ON.
Sorting the internal Table SORT jtab BY object. DATA : wf_txt(60) TYPE c, wf_smod TYPE i , wf_badi TYPE i , wf_object2(30) TYPE c. CLEAR : wf_smod, wf_badi , wf_object2.
Get the total SMOD. LOOP AT jtab INTO wa_tadir. AT FIRST. FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline, 2 'Enhancement/ Business Add-in', 41 sy-vline , 42 'Description', 105 sy-vline. WRITE:/(105) sy-uline. ENDAT. CLEAR wf_txt.
2008-09
Page 26 of 328
AT NEW object. IF wa_tadir-object = 'SMOD'. wf_object2 = 'Enhancement' . ELSEIF wa_tadir-object = 'SXSD'. wf_object2 = ' Business Add-in'. ENDIF. FORMAT COLOR COL_GROUP INTENSIFIED ON. WRITE:/1 sy-vline, 2 wf_object2, 105 sy-vline. ENDAT. CASE wa_tadir-object. WHEN 'SMOD'. wf_smod = wf_smod + 1. SELECT SINGLE modtext INTO wf_txt FROM modsapt WHERE sprsl = sy-langu AND name = wa_tadir-obj_name. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WHEN 'SXSD'. * For BADIs wf_badi = wf_badi + 1 . SELECT SINGLE text INTO wf_txt FROM sxs_attrt WHERE sprsl = sy-langu AND exit_name = wa_tadir-obj_name. FORMAT COLOR COL_NORMAL INTENSIFIED ON. ENDCASE. WRITE:/1 sy-vline, 2 wa_tadir-obj_name HOTSPOT ON, 41 sy-vline , 42 wf_txt, 105 sy-vline. AT END OF object. WRITE : /(105) sy-uline. ENDAT. ENDLOOP. WRITE:/(105) sy-uline. SKIP.
2008-09
Page 27 of 328
FORMAT COLOR COL_TOTAL INTENSIFIED ON. WRITE:/ 'No.of Exits:' , wf_smod. WRITE:/ 'No.of BADis:' , wf_badi. ELSE. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. WRITE:/(105) 'No userexits or BADis exist'. ENDIF. ELSE. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. WRITE:/(105) 'Transaction does not exist'. ENDIF. AT LINE-SELECTION. DATA : wf_object TYPE tadir-object. CLEAR wf_object.
GET CURSOR FIELD field1. CHECK field1(8) EQ 'WA_TADIR'. READ TABLE jtab WITH KEY obj_name = sy-lisel+1(20). MOVE jtab-object TO wf_object. CASE wf_object. WHEN 'SMOD'. SET PARAMETER ID 'MON' FIELD sy-lisel+1(10). CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN. WHEN 'SXSD'. SET PARAMETER ID 'EXN' FIELD sy-lisel+1(20). CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN. ENDCASE.
2.2.13
REPORT zimgcode_find . TYPES: BEGIN OF typ_param, param TYPE tstcp-param, END OF typ_param. DATA: tab_dd26s TYPE TABLE OF dd26s, rec_dd26s TYPE dd26s, tab_param TYPE TABLE OF typ_param, rec_param TYPE typ_param, tab_tstcp TYPE TABLE OF tstcp, rec_tstcp TYPE tstcp, tab_tstct TYPE TABLE OF tstct, rec_tstct TYPE tstct, rec_dd02t TYPE dd02t, tab_vclstruc TYPE TABLE OF vclstruc, rec_vclstruc TYPE vclstruc.
2008-09 Page 28 of 328
DATA: l_tcode LIKE tstct-tcode, l_tabname TYPE dd25l-roottab. PARAMETERS: p_root TYPE dd25l-roottab OBLIGATORY. AT LINE-SELECTION. GET CURSOR FIELD l_tcode. CHECK l_tcode EQ 'REC_TSTCT-TCODE'. CALL TRANSACTION sy-lisel+1(10). EXIT. AT SELECTION-SCREEN. SELECT SINGLE * FROM dd02t INTO rec_dd02t WHERE ddlanguage = sy-langu AND tabname = p_root. START-OF-SELECTION. PERFORM frm_get_maintanceview. PERFORM frm_get_tcode. PERFORM frm_output_tcode. *&-----------------------------------------------------------* *& Form FRM_GET_MAINTANCEVIEW *&-----------------------------------------------------------* * *------------------------------------------------------------* FORM frm_get_maintanceview. " SELECT * FROM dd26s INTO TABLE tab_dd26s WHERE tabname = p_root. SELECT * FROM dd26s APPENDING TABLE tab_dd26s WHERE viewname = p_root. " SELECT * FROM vclstruc INTO TABLE tab_vclstruc WHERE predobject = p_root.
VIEW
IF NOT tab_dd26s[] IS INITIAL. " SELECT * FROM vclstruc APPENDING TABLE tab_vclstruc FOR ALL ENTRIES IN tab_dd26s WHERE predobject = tab_dd26s-viewname. ENDIF. ENDFORM. " FRM_GET_MAINTANCEVIEW *&-----------------------------------------------------------* *& Form FRM_GET_TCODE *&-----------------------------------------------------------*
2008-09
Page 29 of 328
* *------------------------------------------------------------* FORM frm_get_tcode. CHECK NOT tab_dd26s[] IS INITIAL OR NOT tab_vclstruc[] IS INITIAL. LOOP AT tab_dd26s INTO rec_dd26s. CONCATENATE '%' rec_dd26s-viewname '%' INTO rec_param-param. CONDENSE rec_param-param NO-GAPS. APPEND rec_param TO tab_param. ENDLOOP. LOOP AT tab_vclstruc INTO rec_vclstruc. CONCATENATE '%' rec_vclstruc-vclname '%' INTO rec_param-param. CONDENSE rec_param-param NO-GAPS. APPEND rec_param TO tab_param. ENDLOOP. LOOP AT tab_param INTO rec_param. SELECT * FROM tstcp APPENDING TABLE tab_tstcp WHERE param LIKE rec_param-param. ENDLOOP. IF NOT tab_tstcp[] IS INITIAL. SELECT * FROM tstct INTO TABLE tab_tstct FOR ALL ENTRIES IN tab_tstcp WHERE sprsl = sy-langu AND tcode = tab_tstcp-tcode. ENDIF.
TCODE
ENDFORM. " FRM_GET_TCODE *&-----------------------------------------------------------* *& Form FRM_OUTPUT_TCODE *&-----------------------------------------------------------* * *------------------------------------------------------------* FORM frm_output_tcode. IF tab_tstct[] IS INITIAL. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. WRITE:/(95) 'Not found any tcode!'. EXIT. ELSE. FORMAT COLOR COL_POSITIVE INTENSIFIED OFF. WRITE:/(19) 'Table : ', 20(20) p_root, 45(50) rec_dd02t-ddtext. SKIP. IF NOT tab_tstct[] IS INITIAL.
2008-09
TCODE
Page 30 of 328
Listekopf WRITE:/(95) sy-uline. FORMAT COLOR COL_HEADING INTENSIFIED ON. WRITE:/1 sy-vline, 2 'T-code', 21 sy-vline , 22 'Description', 95 sy-vline. WRITE:/(95) sy-uline. LOOP AT tab_tstct INTO rec_tstct. READ TABLE tab_tstcp INTO rec_tstcp WITH KEY tcode = rec_tstct-tcode. IF rec_tstcp-param+0(6) = '/*SM34'. FORMAT COLOR COL_KEY INTENSIFIED OFF. ELSE. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. ENDIF. WRITE:/1 sy-vline, 2 rec_tstct-tcode HOTSPOT ON, 21 sy-vline , 22 rec_tstct-ttext, 95 sy-vline. ENDLOOP. WRITE:/(95) sy-uline. DESCRIBE TABLE tab_tstct. SKIP. FORMAT COLOR COL_TOTAL INTENSIFIED ON. WRITE:/ 'T-code founded:' , sy-tfill.
" FRM_OUTPUT_TCODE
2.2.14
statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko. IF g_init_once <> 'X'. g_init_once = 'X'. CALL FUNCTION 'Z_ENQUE_SLEEP' STARTING NEW TASK 'WAIT' PERFORMING when_finished ON END OF TASK. ENDIF.
WRITE:/ 'wait for 10 sec....'. AT USER-COMMAND. CASE ok_code. WHEN 'FCT_R'. SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh UP TO 10 ROWS FROM ekpo INTO TABLE it_ekko. WRITE:/ sy-uzeit. "Time LOOP AT it_ekko INTO wa_ekko. WRITE:/ wa_ekko-ebeln, wa_ekko-ebelp.
2008-09 Page 32 of 328
ENDLOOP. sy-lsind = 0. IF g_ref_from_timer = 'X'. CALL FUNCTION 'Z_ENQUE_SLEEP' STARTING NEW TASK 'INFO' PERFORMING when_finished ON END OF TASK. g_ref_from_timer = ''. ENDIF. ENDCASE. *---------------------------------------------------------------------* * FORM WHEN_FINISHED *
*---------------------------------------------------------------------* FORM when_finished USING taskname. RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'. g_ref_from_timer = 'X'.
* Trigger an event to run the at user-command SET USER-COMMAND 'FCT_R'. ok_code = 'FCT_R'. sy-ucomm = 'FCT_R'. ENDFORM. " WHEN_FINISHED
* *
EXPORTING SECONDS = 1.
ENDFUNCTION.
2.2.15
Tcode SMW0 ,upload Excel or Word template to SAP server Use Function download the template CALL FUNCTION 'DOWNLOAD_WEB_OBJECT' EXPORTING KEY = OBJDATA DESTINATION = L_DESTINATION.
2.2.16
2.2.16.1.1
ALV Group
What is ALV
3 ,,,.. ALV 3 ALV :, ALV, ALV. 2.2.16.1.2 ALV GRID CONTROL (ALV )
ALV GRID CONTROL ,ALV GRID CONTROL ,. ABAP , ALV (INSTANCE), ABAP .
2008-09
Page 34 of 328
2.2.16.1.3
ALV GRID , CL_GUI_ALV_GRID data ALV_GRID1 type ref to cl_gui_alv_grid. ALV GRID :
2.2.16.1.4 2.2.16.1.4.1
,, 1,2,.. 1
, : 'R': right justified 'L': left justified 'C': centered X' X', X', 0
26DO_SUM 27NO_SUM 28NO_OUT 29TECH 30OUTPUTLEN 31CONVEXIT 32SELTEXT 33TOOLTIP 34ROLLNAME 35DATATYPE 36INTTYPE 37INTLEN 38LOWERCASE 39REPTEXT 40HIER_LEVEL 41REPREP 42DOMNAME 43SP_GROUP 44HOTSPOT 45DFIELDNAME 46COL_ID 47F4AVAILABL 48AUTO_VALUE 49CHECKTABLE 50VALEXI 51WEB_FIELD 52HREF_HNDL 53STYLE 54STYLE2 55STYLE3 56STYLE4 57DRDN_HNDL 58DRDN_FIELD 59NO_MERGING 60H_FTYPE 61COL_OPT 62NO_INIT_CH 63DRDN_ALIAS 64REF_FIELD 65REF_TABLE 66TXT_FIELD 67ROUNDFIELD 68DECIMALS_O
ALV : ALV : ALV : ALV : ALV : ALV : ALV : ALV : F1 ABAP ABAP (C,D,N,...) / ALV : ALV : / ALV : ALV : ALV : ID ALV : ALV : ALV : ALV : ALV : ALV : ALV : 1 ALV : (,,. , ...) 1 1 ALV : ALV : ALV : ALV : ROUND ALV :
2008-09
X',,
X'.
, PUSHBUTTION
Page 36 of 328
69DECMLFIELD 70DD_OUTLEN 71DECIMALS 72COLTEXT 73SCRTEXT_L 74SCRTEXT_M 75SCRTEXT_S 76COLDDICTXT 77SELDDICTXT 78TIPDDICTXT 79EDIT 80TECH_COL 81TECH_FORM 82TECH_COMP 83HIER_CPOS 84H_COL_KEY 85H_SELECT 86DD_ROLL 87DRAGDROPID 88MAC 89INDX_FIELD 90INDX_CFIEL 91INDX_QFIEL 92INDX_IFIEL 93INDX_ROUND 94INDX_DECML 95GET_STYLE 96MARK
ALV : DECIMALS ALV : ALV : ALV : DDIC ALV : DDIC ALV : DDIC ALV : ALV : ALV : ALV : ALV : : / () ALV : & 1 1 1 .'X'
2.2.16.1.4.2
[ layout ]
Value range SPACE, 'X' SPACE, 'X' 70 SPACE, 'X' SPACE, 'X' SPACE, 'X' SPACE, 'X' SPACE, 'X' SPACE, 'X'
Page 37 of 328
SEL_MODE EXCP_CONDS EXCP_FNAME EXCP_LED EXCP_ROLLN CTAB_FNAME INFO_FNAME ZEBRA NO_TOTLINE NUMC_TOTAL TOTALS_BEF STYLEFNAME
SPACE, 'A', 'B', 'C', 'D' SPACE, 'X' 30 SPACE, 'X' SPACE, 'X' 30 30 SPACE, 'X' SPACE, 'X' SPACE, 'X' SPACE, 'X' 30
2.2.16.1.4.3
,,..
,,,. DATA ls_fcat TYPE lvc_s_fcat . DATA lt_fcat TYPE lvc_t_fcat . DATA ls_layout TYPE lvc_s_layo . CALL METHOD gr_alvgrid->get_frontend_fieldcatalog IMPORTING et_fieldcatalog = lt_fcat[] . LOOP AT lt_fcat INTO ls_fcat . IF ls_fcat-fieldname = 'PAYMENTSUM' . ls_fcat-no_out = space . MODIFY lt_fcat FROM ls_fcat . ENDIF . ENDLOOP . CALL METHOD gr_alvgrid->set_frontend_fieldcatalog EXPORTING it_fieldcatalog = lt_fcat[] . CALL METHOD gr_alvgrid->get_frontend_layout IMPORTING es_layout = ls_layout . ls_layout-grid_title = 'Flights (with Payment Sums)' . CALL METHOD gr_alvgrid->set_frontend_layout EXPORTING is_layout = ls_layout .
2008-09
Page 38 of 328
2.2.16.2.2
. LVC_T_SORT . set_table_for_first_display IT_SORT . FORM prepare_sort_table CHANGING pt_sort TYPE lvc_t_sort . DATA ls_sort TYPE lvc_s_sort . ls_sort-spos = '1' . ls_sort-fieldname = 'CARRID' . ls_sort-up = 'X' . "A to Z ls_sort-down = space . APPEND ls_sort TO pt_sort . ls_sort-spos = '2' . ls_sort-fieldname = 'SEATSOCC' . ls_sort-up = space . ls_sort-down = 'X' . "Z to A APPEND ls_sort TO pt_sort . ENDFORM. " prepare_sort_table 2 : 1. DUMP. 2.,,,"no_merging""X" . get_sort_criteria set_sort_criteria.
2.2.16.2.3
()
ALV ,."LVC_T_FILT" . RANGES ."SET_TABLE_FOR_FIRST_DISPLAY" "IT_FILTER" FORM prepare_filter_table CHANGING pt_filt TYPE lvc_t_filt . DATA ls_filt TYPE lvc_s_filt . ls_filt-fieldname = 'FLDATE' . ls_filt-sign = 'E' . ls_filt-option = 'BT' . ls_filt-low = '20030101' . ls_filt-high = '20031231' . APPEND ls_filt TO pt_filt . ENDFORM. " preparefiltertable "get_filter_criteria" "set_filter_criteria".
2.2.16.2.4
2008-09
Page 39 of 328
A.
"emphasize". 4 CHAR ,.: LS_FCAT-EMPHASIZE = 'C701'. , . LS_FCAT-KEY = 'X' ,.,KEY
B.
,,,., 4 CHAR ,. : DATA BEGIN OF gt_list OCCURS 0 . INCLUDE STRUCTURE SFLIGHT . DATA rowcolor(4) TYPE c . DATA END OF gt_list . ,ALV ,"INFO_FNAME", ALV,. ps_layout-info_fname = 'ROWCOLOR'. ,,,., ,,
C.
,, 2 . DEEP , ALV .. "LVC_T_SCOL". 3 :
2008-09
Page 40 of 328
FNAME , COLOR ,. ,. COLOR . NOKEYCOL .,.,. ,ALV "CTAB_FNAME",. DATA BEGIN OF gt_list OCCURS 0 . INCLUDE STRUCTURE SFLIGHT . DATA rowcolor(4) TYPE c . DATA cellcolors TYPE lvc_t_scol . DATA END OF gt_list . DATA ls_cellcolor TYPE lvc_s_scol . ... READ TABLE gt_list INDEX 5 . ls_cellcolor-fname = 'SEATSOCC' . ls_cellcolor-color-col = '7' . ls_cellcolor-color-int = '1' . APPEND ls_cellcolor TO gt_list-cellcolors . MODIFY gt_list INDEX 5 . : ,--->--->.
2.2.16.2.6
."LVC_T_HYPE" , INT4 , ALV,,.,WEB_FIELD . , CARRID,CONNID : , 2 : DATA BEGIN OF gt_list OCCURS 0 . INCLUDE STRUCTURE SFLIGHT . DATA rowcolor(4) TYPE c . DATA cellcolors TYPE lvc_t_scol . DATA carrid_handle TYPE int4 . DATA connid_handle TYPE int4 . DATA END OF gt_list . : ,.,,"LVC_T_HYPE". FORM prepare_hyperlinks_table CHANGING pt_hype TYPE lvc_t_hype . DATA ls_hype TYPE lvc_s_hype . ls_hype-handle = '1' . ls_hype-href = 'http://www.company.com/carrids/car1' . APPEND ls_hype TO pt_hype . ls_hype-handle = '2' . ls_hype-href = 'http://www.company.com/carrids/car1' . APPEND ls_hype TO pt_hype . ls_hype-handle = '3' . ls_hype-href = 'http://www.company.com/carrids/car1' . APPEND ls_hype TO pt_hype . ls_hype-handle = '4' . ls_hype-href = 'http://www.company.com/connids/con11' . APPEND ls_hype TO pt_hype . ls_hype-handle = '5' . ls_hype-href = 'http://www.company.com/connids/con12' APPEND ls_hype TO pt_hype .
2008-09
Page 41 of 328
.. .. ENDFORM . . FIELDCATLOG . CARRID field catalog Ls_fieldcat-web_field = CARRID_HANDLE. CONNID field catalog Ls_fieldcat-web_field = CONNID_HANDLE. "SET_TABLE_FOR_FIRST_DISPLAY" it_hyperlink :: LOOP AT gt_list. IF gt_list-carrid = XX. Gt_list-carrid_handle = 1. IF gt_list-connid = 01. Gt_list-connid_handle = 4. ENDIF. ENDIF. ENDLOOP.
2.2.16.2.7
,,, . ,,,"LVC_T_DROP". ALV ."SET_TABLE_FOR_FIRST_DISPLAY", "SET_DROP_DOWN_TABLE". ,"DRDN_HNDL".: ps_fcat-drdn_hndl = '1' . (, ),"DRDN_FIELD".: ps_fcat-drdn_field = 'PTYP_DD_HNDL' . : DATA BEGIN OF gt_list OCCURS 0 . INCLUDE STRUCTURE SFLIGHT . DATA rowcolor(4) TYPE c . DATA cellcolors TYPE lvc_t_scol . DATA carrid_handle TYPE int4 . DATA connid_handle TYPE int4 . DATA ptype_dd_hndl TYPE int4 . DATA END OF gt_list . : FORM prepare_drilldown_values. DATA lt_ddval TYPE lvc_t_drop . DATA ls_ddval TYPE lvc_s_drop . ls_ddval-handle = '1' . ls_ddval-value = 'JFK-12' . APPEND ls_ddval TO lt_ddval . ls_ddval-handle = '1' . ls_ddval-value = 'JSF-44' . APPEND ls_ddval TO lt_ddval . ls_ddval-handle = '1' . ls_ddval-value = 'KMDA-53' .
2008-09
Page 42 of 328
APPEND ls_ddval TO lt_ddval . ls_ddval-handle = '1' . ls_ddval-value = 'SS3O/N' . APPEND ls_ddval TO lt_ddval . CALL METHOD gr_alvgrid->set_drop_down_table EXPORTING it_drop_down = lt_ddval . ENDFORM. " prepare_drilldown_values , set_drop_down_table ALV.
2.2.16.2.8
,ALV GRID .. ALV GRID . ALV GRID , HTML HTML SAP GUI . : Event Print_end_of_list Print_top_of_list Print_top_of_page Print_end_of_page Subtotal_text ALV GRID Event Button_click Double_click Hotspot_click Application Query click on a push button in the ALV GRID control Query a double click on a cell of the ALV GRID Query a hotspot click on columns defined for this purpose in advance Collect information when elements of the ALV GRID Control are dragged Process information when elements of the ALV GRID Control are dropped Perform final actions after successful drag&drop Distinguish between options for drag&drop behavior HTML Application Define output text to be printed at the end of the entire list Define output text to be printed at begin of the entire list Define output text to be printed at begin of each page Define output text to be printed at the end of each page Define self-defined subtotal texts HTML
Ondrag
Ondrop
ondropComplete ondropGetFlavor
Event Before_user_command User_command Application Query self-defined and standard functions Query self-defined function HTML
2008-09 Page 43 of 328
(,) Event Tool bar Menu_button Context_menu_request Onf1 Application Change,delete or add gui elements on alv grid Define menus for menu buttons in the toolbar Change context menu Define self-defined f1 help HTML
,. CLAS lcl_event_handler DEFINITION. PUBLIC SECTION. METHODS: *-- ALV Handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive, *-- Handle_user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm. *-- Handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid IMPORTING e_row_id e_column_id es_row_no. *-- Handle_before_user_command FOR EVENT before_user_command OF cl_gui_alv_grid IMPORTING e_ucomm. *-- Handle_after_user_command FOR EVENT after_user_command OF cl_gui_alv_grid IMPORTING e_ucomm. *-- ALV , Handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed. *-- Handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid IMPORTING e_modified. *-- Handle_menu_button FOR EVENT menu_button OF cl_gui_alv_grid IMPORTING e_object e_ucomm. *--
2008-09
Page 44 of 328
Handle_button_click FOR EVENT button_click OF cl_gui_alv_grid IMPORTING e_objec e_ucomm. PRIVATE SECTION. ENDCLASS. , ALV : CLASS lcl_event_handler IMPLEMENTATION. *-- Handle toolbar METHOD handle_toolbar. PERFORM handle_toolbar USIGN e_object e_interactive. ENDMETHOD. *-- Handle hotspot click METHOD handle_hotspot_click. PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no. ENDMETHOD. *-- Handle double click METHOD handle_double_click. PERFORM handle_double_click USING e_row e_column es_row_no. ENDMETHOD. *-- Handle after user command METHOD handle _after_user_command. PERFORM handle_after_user_command USING e_object. ENDFORM. *-- Handle before user command METHOD handle_before_user_command. PERFORM handle_before_user_command. ENDMETHOD. *--Handle data changed METHOD handle_data_changed. PERFORM handle_data_changed USING er_data_changed. ENDMEHTOD. METHOD handle_data_changed_finished. PERFORM handle_data_chaged USING e_modified. ENDMETHOD. METHOD handle_menu_button. PERFORM handle_menu_button USING e_object e_ucomm. ENDMEHTOD. MEHTOD handle_button_click. PERFORM handle_button_click USING e_objcet e_ucomm. ENDMETHOD. ENDCALSS. , ALV GRID . DATA gr_event_handler TYPE REF TO lcl_event_handler . .. .. *--Creating an instance for the event handler CREATE OBJECT gr_event_handler . *--Registering handler methods to handle ALV Grid events SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_menu_button FOR gr_alvgrid .
2008-09
Page 45 of 328
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_button_click FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_before_user_command FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_context_menu_request FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_data_changed FOR gr_alvgrid . SET HANDLER gr_event_handler->handle_data_changed_finished FOR gr_alvgrid .
2.2.16.2.8.1
HotPost
,,"HOTSPOT""X", HOTSPOT_CLICK. HOTSPOT_CLICK ,"E_ROW_ID", 2 : LVC_S_COL "E_COLUMN_ID", E_COLUMN_ID-FIELDNAME . LVC_S_ROID "ES_ROW_NO", ES_ROW_NO-ROW_ID ,. : FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row I_column_id TYPE lvc_s_col Is_row_no TYPE lvc_s_roid. READ TABLE gt_list INDEX is_row_no-rowid. IF sy-subrc = 0 AND i_column_id-fieldname = SEATSOCC. CALL SCREEN 200. ENDIF. ENDFORM. SEATSOCC, 200. 2.2.16.2.8.2 Double click
, 3 ..
:
FORM handle_double_click USING i_row TYPE lvc_s_row I_column TYPE lvc_s_col Is_row_no TYPE lvc_s_rowid. READ TABLE gt_list INDEX is_row_no-row_id. IF sy-subrc = 0 AND i_column-fieldname = SEATSOCC. CALL SCREEN 200. ENDIF. ENDFORM. SEATSOCC 200. 2.2.16.2.8.3 User-defined button and command
Page 46 of 328
DATA: ls_toolbar TYPE stb_button. CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO i_object->mt_toolbar. CLEAR ls_toolbar. MOVE 'PER' TO ls_toolbar-function. MOVE icon_display_text TO ls_toolbar-icon. MOVE 'Passenger Info'(201) TO ls_toolbar-quickinfo. MOVE 'Passenger Info'(201) TO ls_toolbar-text. MOVE ' ' TO ls_toolbar-disabled. APPEND ls_toolbar TO i_object->mt_toolbar. CLEAR ls_toolbar. MOVE 'EXCH' TO ls_toolbar-function. MOVE 2 TO ls_toolbar-butn_type. MOVE icon_calculation TO ls_toolbar-icon. MOVE 'Payment in other Curencies'(202) TO ls_toolbar-quickinfo. MOVE ' ' TO ls_toolbar-text. MOVE ' ' TO ls_toolbar-disapbled. APPEND ls_toolbar TO i_object->mt_toolbar. ENDFORM. :
Field FUNCTION BUTN_TYPE Description : Button(normal) Menu and default button Menu Radio button Checkbox Menu entry ICON TEXT QUICKINFO DISABLED () () ()
. 1 2, , menu_button :
FORM handle_menu_button USING i_object TYPE REF TO cl_ctmenu I_ucomm TYPE syucomm.. CASE i_ucomm. WHEN EXCH. CALL METHOD i_object->add_function EXPORTING Fcode = EU
2008-09
Page 47 of 328
Text = Euro. CALL METHOD i_object->add_function EXPORTING Fcode = TRL Text = Turkish Lira. ENDCASE. ENDFORM. , USER_COMMAND . FORM handle_user_command USING i_ucomm TYPE sy-ucomm. DATA lt_selected_rows TYPE lvc_t_rowid. DATA ls_selected_row TYPE lvc_s_roid. CALL METHOD gr_alvgrid->get_selected_rows IMPORTING Et_row_no = lt_selected_rows. READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1. If sy-subrc ne 0. MESSAGE S000(su) WITH 'Select a row'(203). ENDIF. CASE i_ucomm. WHEN 'CAR'. READ TABLE gt_list INDEX ls_selected_row-row_id. IF sy-subrc = 0. CALL FUNCTION 'ZDISPLAY_CARRIER_INFO' EXPORTING carrid = gt_list-carrid EXCEPTIONS carrier_not_found = 1 Oters = 2. ENDIF. WHEN 'EU'. READ TABLE gt_list INDEX ls_selected_row-row_id. IF sy-subrc = 0. CALL FUNCTION 'ZPOPUP_CONV_CURR_ADD_DISPLAY' EXPORTING monun = 'EU' Quant = gt_list-paymentsum. ENDIF. ENDCASE. ENDFORM.
get_selected_rows . EXCH 2 ,. ALV , ALV set_toolbar_interactive .
2.2.16.2.8.4
FORM handle_before_user_command USING i_ucomm TYPE syucomm . CASE e_ucomm . WHEN '&INFO' .
2008-09
Page 48 of 328
CALL FUNCTION 'ZSFLIGHT_PROG_INFO' . CALL METHOD gr_alvgrid->set_user_command EXPORTING i_ucomm = space. ENDCASE . ENDFORM . 2.2.16.2.8.5
(style , style CL_GUI_ALV_GRID , MC_STYLE4_LINK,MC_STYLE4_LINK_NO,MC_STYLE_BUTTON,MC_STYLE_DISABLED,....),/, F4,,,......
2.2.16.2.8.5.1
PUSHBUTTON
,"LVC_T_STYL". : DATA: BEGIN OF gt_list OCCURS 0. INCLUDE STRUCTURE sflight. DATA rowcolor(4) TYPE c. DATA cellcolors TYPE lvc_t_scol. DATA carrid_handle TYPE int4. DATA connid_handle TYPE int4. DATA cellstyles TYPE lvc_t_styl. DATA END OF gt_list. : 7 SEATSMAX . DATA ls_style TYPE lvc_s_styl. READ TABLE gt_list INDEX 7. Ls_style-fieldname = 'SEATSMAX'. Ls_style-style = cl_gui_alv_grid=>mc_style_button. APPEND ls_style TO gt_list-cellstyles. MODIFY gt_list INDEX 7. STYLE ,: gs_layout-stylefname = 'CELLSTYLES'.
, 2 .
2.2.16.2.8.5.2
, SAP . ,, A,, B,. , EDIT "X".,ALV ,, ,.,. 5.1 ,,"LVC_T_STYL". style CL_GUI_ALV_GRID=>MC_STYLE_ENABLED CL_GUI_ALV_GRID=>MC_STYLE_DISABLED. .CL_GUI_ALV_GRID=>MC_STYLE_ENABLED , CL_GUI_ALV_GRID=>MC_STYLE_DISABLED .: FORM adjust_edittables USING pt_list LIKE gt_list[]. DATA ls_listrow LIKE LINE OF pt_list.
2008-09
Page 49 of 328
DATA ls_stylerow TYPE lvc_s_styl. DATA lt_styletab TYPE lvc_t_styl. LOOP AT pt_list INTO ls_listrow. IF ls_listrow-carrid = 'XY'. Ls_stylerow-fieldname = 'SEATSMAX'. Ls_stylerow-style = cl_alv_grid=>mc_style_disabled. APPEND ls_stylerow TO lt_styletab. ENDIF. IF ls_listrow-connid = '02'. Ls_stylerow-fieldname = 'PLANETYPE' Ls_stylerow-style = cl_alv_grid=>mc_style_enabled. APPEND ls_Pstylerow TO lt_styletab. ENDIF. INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles. MODIFY pt_list FROM ls_listrow. ENDLOOP. ENDFORM. ALV STYLE . gs_layout-stylefname = 'CELLSTYLES'. , STYLE . set_ready_for_input i_ready_for_input = 1 ALV ALV i_ready_for_input 0 2.2.16.2.8.6
alv ALV Alv grid :data_changed data_changed_finished. REGISTER_EDIT_EVENT ,.2 : 1.: i_event_id = cl_gui_alv_grid=>mc_event_enter 2.: i_event_id = cl_gui_alv_grid=>mc_event_modifies ,. ALV ,DATA_CHANGED CL_ALV_CHANGED_DATA_PROTOCOL ER_DATA_CHANGED ALV.. CL_ALV_CHANGED_DATA_PROTOCOL : Get_cell_value Modify_cell Add_protocol_entry Protocol_is_visible Refresh_protocol : MT_MOD_CELLS Contains address of modified cells with rowed and
2008-09 Page 50 of 328
field name MT_MOD_ROWS MT_GOOD_CELLS MT_DELETED_ROWS MT_INSERTED_ROWS Contain modified rows Its type is genric Contain cells have proper values Contain rows deleted from the list Contain rows deleted from the list
,.
: FORM handle_data_changed USING ir_data_changed TYPE REF TO cl_alv_changed_data_protocol. DATA: ls_mod_cell TYPE lvc_s_modi, Lv_value TYPE lvc_value. SORT ir_data_changed->mt_mod_cells BY row_id. LOOP AT ir_data_changed->mt_mod_cells INTO ls_mod_cell WHERE fieldname = 'SEATSMAX'. CALL METHOD ir_data_changed->get_cell_value EXPORTING i_row_id = ls_mod_cell-row_id I_fieldname = 'CARRID' IMPORTING e_value = lv_value. IF lv_value = 'THY' AND ls_mod_cell-value > '500'. CALL METHOD ir_data_changed->add_protocol_entry EXPORTING I_msgid = 'SU' I_msgno = '000' I_msgty = 'E' I_msgv1 = 'This number can not exceed 500 for ' I_msgv2 = lv_value I_msgv3 = 'The value is et to ''500''' I_fieldname = ls_mod_cell-fieldname I_row_id = ls_mod_cell-rowid. CALL METHOD ir_data_changed->modify_cell EXPORTING i_row_id = ls_mod_cell-row_id I_fieldname = ls_mod_cell-fieldname I_value = '500'. ENDIF. ENDLOOP. ENDFORM.
2.2.16.2.9 2.2.16.2.9.1
(ALV) Upload Logo for REUSE_ALV_COMMENTARY_WRITE For those who wish to upload and use a picture in your ALV ABAP reports. Steps for uploading Logo :-: . Goto the transaction OAER . Enter the class name as 'PICTURES' . Enter the class type as 'OT'
2008-09
Page 51 of 328
. Enter the object key as the name of the logo you wish to give . Execute . Then in the new screen select Standard doc. types in bottom window. Click on the Screen icon. Now, it will ask for the file path where you have to upload the logo . Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE
2008-09
Page 52 of 328
2.2.16.2.9.2
2.2.16.2.9.3
.doc
2.2.16.2.9.4
.doc
2.2.16.2.9.5
.doc
2.2.16.2.9.6
.do c
2008-09
Page 53 of 328
2.2.16.2.9.7
ALV
ALV.doc
2.2.16.2.9.8
ALV .doc
2.2.16.2.9.9
ALV .doc
2.2.16.2.9.10
.doc
2.2.16.3.2
ALV
PBO : PROCESS BEFORE OUTPUT . MODULE display_alv . DISPLAY_ALV MODULE ,: MODULE display_alv OUTPUT . PERFORM display_alv . ENDMODULE . FORM DISPLAY_ALV , ALV ,,: IF WCL_ALV IS INITIAL . CREATE OBJECT: WCL_CONTAINER EXPORTING CONTAINER_NAME = 'ALV_CON'. CREATE OBJECT WCL_ALV EXPORTING I_PARENT = WCL_CONTAINER. *----- PERFORM prepare_field_catalog CHANGING gt_fieldcat . *----- PERFORM prepare_layout CHANGING gs_layout .
2008-09
Page 54 of 328
*----- ALV CALL METHOD gr_alvgrid->set_table_for_first_display EXPORTING * I_BUFFER_ACTIVE = * I_CONSISTENCY_CHECK = * I_STRUCTURE_NAME = * IS_VARIANT = * I_SAVE = * I_DEFAULT = 'X' is_layout = gs_layout * IS_PRINT = * IT_SPECIAL_GROUPS = * IT_TOOLBAR_EXCLUDING = * IT_HYPERLINK = CHANGING it_outtab = gt_list[] it_fieldcatalog = gt_fieldcat * IT_SORT = * IT_FILTER = EXCEPTIONS invalid_parameter_combination = 1 program_error = 2 too_many_lines = 3 OTHERS = 4 . ELSE . *---- ALV CALL METHOD gr_alvgrid->refresh_table_display * EXPORTING * IS_STABLE = * I_SOFT_REFRESH = EXCEPTIONS finished = 1 OTHERS = 2 . IF sy-subrc <> 0. *-- ENDIF. ENDIF . "set_table_for_first_display" I_BUFFER_ACTIVE ,,, ALV ., ALV ,'SFLIGHT'., , IT_FIELDCATALOG . : 'X' 'U' 'A' SPACE : 'X' , SPACE ,
2008-09 Page 55 of 328
I_STRUCTURE_NAME IS_VARIANT
I_SAVE
I_SOFT_REFRESH
2.2.16.3.3
Two way: 1. FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat . DATA ls_fcat type lvc_s_fcat . ls_fcat-fieldname = 'CARRID' . ls_fcat-inttype = 'C' . ls_fcat-outputlen = '3' . ls_fcat-coltext = 'Carrier ID' . ls_fcat-seltext = 'Carrier ID' . APPEND ls_fcat to pt_fieldcat . CLEAR ls_fcat . ls_fcat-fieldname = 'CONNID' . ls_fcat-ref_table = 'SFLIGHT' . ls_fcat-ref_table = 'CONNID' . ls_fcat-outputlen = '3' . ls_fcat-coltext = 'Connection ID' . ls_fcat-seltext = 'Connection ID' . APPEND ls_fcat to pt_fieldcat . ENDFORM . 2. FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat . DATA ls_fcat type lvc_s_fcat . CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'SFLIGHT' CHANGING ct_fieldcat = pt_fieldcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2 2008-09
Page 56 of 328
OTHERS = 3. IF sy-subrc <> 0. *--Exception handling ENDIF. LOOP AT pt_fieldcat INTO ls_fcat . CASE pt_fieldcat-fieldname . WHEN 'CARRID' . ls_fcat-outpulen = '10' . ls_fcat-coltext = 'Airline Carrier ID' . MODIFY pt_fieldcat FROM ls_fcat . WHEN 'PAYMENTSUM' . ls_fcat-no_out = 'X' . MODIFY pt_fieldcat FROM ls_fcat . ENDCASE . ENDLOOP . ENDFORM 2.2.16.3.4
FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo. ps_layout-zebra = 'X' . ps_layout-grid_title = 'Flights' . ps_layout-smalltitle = 'X' . ENDFORM. " prepare_layout 2.2.16.3.5
(,,)
ALV , UI_FUNCTIONS , set_table_for_first_display "IT_TOOLBAR_EXCLUDING". cl_gui_alv_grid , after_user_command . , layout no_toolbar "X". FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions . DATA ls_exclude TYPE ui_func. ls_exclude = cl_gui_alv_grid=>mc_fc_maximum . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_fc_minimum . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_fc_subtot . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_fc_sum . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_fc_average . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_mb_sum . APPEND ls_exclude TO pt_exclude. ls_exclude = cl_gui_alv_grid=>mc_mb_subtot . ENDFORM . , ALV DEMO ..
2.2.17
2.2.17.1.1
SAP Script
SAPscript
2008-09
Page 57 of 328
2.2.17.1.2 2.2.17.1.2.1
Forms:
SAP Forms SAP Forms SAP Forms Y Z SAP Forms SAP IMG Forms layout Form Form SAP Forms layout Forms item Forms SAPscript (Tools Word processing Standard text) Form Form Main Form Main SAP Form Forms Styles Form Styles
Forms Styles Forms Styles SAP Forms Styles Client 000 SAPscript client000 Forms Styles Forms Styles SAPscript client000 Forms Styles client000 SAP Forms Styles client000 Forms Styles YXXX ZXXX Language rules: SAPscript uses the following rules to manage versions of forms and styles in different languages: The in using whichSAPs a form or style is created is its "original language." You can translate a form or style into otherlanguage languages translation tools. If a language form or style is needed only in its data. original language and need be translated, then you can this in the attributes in the header The form or style then not does not appear in work lists in indicate the translation tools. In versions other than the original changes to a form or style are limited only to translation of texts. No changes to definitions andlanguage attributesversion, are permitted.
2008-09 Page 58 of 328
2.2.17.1.2.2
2.2.17.1.2.2.1
Header Data
Header Data page page Header Data Basic settings Header Data form Header Data
SAPscript Form form start page subsequent pages start page subsequent page subsequent SAPscript form main window.
2008-09
Page 59 of 328
SAPscript Paragraph()
Description
2008-09
Page 60 of 328
1 (Description) (Left margin, Right margin) (indent 1st line) (Space before, Space after) (Alignment) (Line spacing) (No blank lines) (Page protection) (Next paragraph same page) 2 Font // 3 Tabs in Paragraph Formats tabs pc editor ,,symbol tabs tabs CH () CM () MM() PT() TW(1/20 ) 4 Outline
2008-09
Page 61 of 328
2.2.17.1.2.2.3
Character formats and Attributes Standard Font Standard marker()BarcodeProtectedHiddenSuperscript Font Font
2.2.17.1.2.2.4 Windows
Windows Form Page Window Form window SAPscript window Form Main window Form Window Main Window Form MAIN Main Window SAPscript 1 2 pages 3 page window main window main window
page main window page window subsequent page SAPscript subsequent pages
header line totals main window (output area) page main window Main window TOP Area BOTTOM Area BODY AreaTOP Area BOTTOM Area BODY Area
2008-09
Page 62 of 328
Form SAPscript main windwo Form WRITE_FORM WRITE_FORM_LINES TYPE TYPE BODY
VAR Window
2008-09 Page 63 of 328