WRITE IDOC STATUS ...............................61 BDC PROCESSING & IDOC STATUS UPDATE 61 M AILING IN SAP......................................63 PROGRAM EXAMPLE – – R REPORT TO SHOW EDI STATUS STATU S 68 7.10.5 EXAMPLE UPLOAD FILE TO IDOC...............81 7.10.6 IDOC CREATION FROM INBOUND FILE ........88 7.10.7 LIST TRANSACTIONS ................................99 7.10.8 REPORT WITH JOINS AND MACROS .........101 7.10.9 GRAPHICAL POPUP PROGRESS DISPLAY 108 7.10.10 CHANGE IDOC STATUS TO ERROR STATUS AND SEND TO WORKFLOW WORKFLOW ....................................108 7.10.11 REPORT TO DOWNLOAD PROGRAMS ...115 7.10.12 DISPLAY TABLE IN HTML ......... ...................124 ..........124 7.10.13 TREE REPORTS .................................127 7.10.14 SHELL LIST REPORT OFF A TABLE - NAST 130 7.10.15 ALV REPORT ....................................135 7.10.16 SAP GENERATED REPORT \ DIALOG AM M 139 PROGR A 7.10.17 LIST OF TRANSACTIONS REPORT .........150 CHAPTER 8
8.1
BASIS ERRORS AND RESOLUTIONS 153
CANNOT CANNOT ACTIVATE ACTIVATE A TABLE --------------------- 153
CHAPTER 9
INDEX
155
6.1
SAP DEMO REPORTS REPORTS ---------------------------------------------- 38
6.2
TREE REPORTS ----------------------------------------------------------------- 38
6.3
AL V GRID CONTROL CONTROL ----------------------------------------------------- 48
6.3.1
ADDING CUSTOM BUTTONS ON ALV GRID CONTR CONT ROLS ......... .................. ................... ................... .................. ................... .............. ....48 48 6.3.2 HIGHLIGHT LINES ....................................52 6.3.3 FIRST LINE VISIBLE ..................................52 6.3.4 READ ONLY TEXT BOX ..............................52 6.3.5 ENTERING TEXT ......................................53 CHAPTER 7
IDOC PROGRAMMING
55
7.1
CREATING AN IDOC--------------------IDOC---------------------------------- 55
7.2
SENDING AN IDOC-----------------------------IDOC------------------------------ 55
7.3
CHANGING AN IDOC ----------------------------------------------------- 55
7.4
CHANGING CHANGING AN IDOC’S IDOC’S STATUS --------------------- 56
7.5
READING READING AN IDOC ----------------------------------------------------- 56
7.5.1
EXAMPLE – – O OPEN DOCUMENT FOR READ ..56
7.6
DISPLAYING DISPLA YING AN IDOC ------------------------------------------------- 57
7.7
IDOC TYPE POOL --------------------------------------------------------- 57
7.8
LA UNCHING UNCHING AN ERROR ERROR WORKFLOW WORKFLOW --- 57
7.9 RETURNING IDOCS IDOCS LINK ED TO DOCUMENTS ------------------------------------------------------------------------------------------- 59
7.9.1
* RETURN THE LIST OF IDOCS LINKED TO THE
DELIVERY 59
7.9.2 INVOICE
7.9.3 7.10
* RETURN THE LIST OF IDOCS LINKED TO THE 59 VERSION 4.6X .......... ................... ................... .................... ............ 59
WRITE IDOC STATUS ...............................61 BDC PROCESSING & IDOC STATUS UPDATE 61 M AILING IN SAP......................................63 PROGRAM EXAMPLE – – R REPORT TO SHOW EDI STATUS STATU S 68 7.10.5 EXAMPLE UPLOAD FILE TO IDOC...............81 7.10.6 IDOC CREATION FROM INBOUND FILE ........88 7.10.7 LIST TRANSACTIONS ................................99 7.10.8 REPORT WITH JOINS AND MACROS .........101 7.10.9 GRAPHICAL POPUP PROGRESS DISPLAY 108 7.10.10 CHANGE IDOC STATUS TO ERROR STATUS AND SEND TO WORKFLOW WORKFLOW ....................................108 7.10.11 REPORT TO DOWNLOAD PROGRAMS ...115 7.10.12 DISPLAY TABLE IN HTML ......... ...................124 ..........124 7.10.13 TREE REPORTS .................................127 7.10.14 SHELL LIST REPORT OFF A TABLE - NAST 130 7.10.15 ALV REPORT ....................................135 7.10.16 SAP GENERATED REPORT \ DIALOG AM M 139 PROGR A 7.10.17 LIST OF TRANSACTIONS REPORT .........150 CHAPTER 8
8.1
BASIS ERRORS AND RESOLUTIONS 153
CANNOT CANNOT ACTIVATE ACTIVATE A TABLE --------------------- 153
CHAPTER 9
INDEX
155
CHAPTER 1 USEFUL USEFUL TRANSA TRANSACTION CTIONS S IDoc Development class: SED.
1.1
EDI SPECIFIC TRANSA TRANSACTIONS CTIONS
VOE1
Translation between EDI categories and SD item categories
VOE2
Table EDSC view. Customer link to sales area detail.
VOE3
Table view EDPVW. Add partner types that will be transferred to the IDoc.
VOE4
Table view EDPAR. Link external partner number with our internal number.
OVAI
Create entries for each Vendor / Partner description combination. (Vendors must match sold-to Acct. Acct. at Cust., and Partner descriptions must match ship-to Partner descriptions.) This transaction updates table T661W. SAP uses this table to determine the schedule agreement sold-to sold-to partner.
1.1. 1.1.1 1 Schedulin Schedu ling g agreements OVA9
Create entries entries for each sold-to customer for which you will receive EDI schedule schedule releases. At implementation, the only field that needs to be maintained is "Check PO number," which causes SAP to make sure that the PO number sent on the release matches the PO number on the schedule agreement. This transaction updates table T663A. SAP will not post an EDI schedule release, if this record is missing.
OVAJ
If you would like SAP to post schedule requirements using discrete dates only, instead of weekly and/or monthly buckets, you can indicate the days of the week that you deliver to this this customer. SAP will divide the customer's quantity for a week or month evenly into the days of the week specified by the distribution function code. This code must be sent in the DELINS IDoc in field E1EDP16-ETVTF. E1EDP16-ETVTF.
1.2 NACE
MESSAGE CONTR CONTROL OL 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
VV21
Create output condition records for shipping. LAVA – WE (Partner function) - We must add each new p artner with VV21
VL71
Reissue output for deliveries
1.2.2 Invoice V/54
Maintain access sequence for billing documents
VV31
Create condition records for billing documents. (RD00 – RE Billing party)
VF31
Reissue output for billing documents
1.2.3 Order response V/30
Sales document output types (BA00)
V/48, V/32, V/43
Maintain access sequence for sales documents
VV11
Create condition records for sales documents. (BA00 – SP Sold to party)
1.3
IDOC A DMINISTRATION
WE09 / WE02
IDoc lists according to content. View IDocs via specific IDoc number or business application detail contained within the contents of a segment.
WE05
View IDocs
WE60
IDoc type documentation tool
WE20
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.
BD87
Reprocess IDocs in error or waiting for action. (Both inbound and outbound in 4.6. Use BD88 in prior versions)
1.4
IDOC DEVELOPMENT
BD55
Conversion rule user exit. Link conversion rule user exit to the different system \ partner combinations.
WE19
EDI test tool. Use to test inbound Function module changes.
WE31
Segment create
WE30
Create IDoc extension type
WE82
Link Release detail to Extension IDoc Type
WE57
Assign function module to logical message and IDoc type
1.5
REQUIREMENTS CODING
V/27
Create code to check requirements for output control. Used to check ZBA0 against BA00 output.
1.6
SALES
VA05
List of sales orders
VA02
Sales order change
VA32
Scheduling agreement change
VA42
Contract change
VA22
Quotation change
VF02
Change billing document
VL02N
Change delivery document
VF11
Cancel Billing document
VF04
Billing due list
VL04
Delivery due list
VKM3, VKM4
List of sales documents
VKM1
List of blocked SD documents
VKM5
List of deliveries
VL06G
List of outbound deliveries for goods issue
VL06P
List of outbound deliveries for picking
VL09
Cancel goods issue
VT02N
Change shipment
VT70
Output for shipments
1.7
GENERAL
The following section provides detail on other useful SAP areas. VL04
Delivery due list. Run the delivery due with your order number to create the del ivery.
LT03
Create Transfer Order. EG. Warehouse: 101 and enter. Picking background. Save
VL02N
Delivery change.
MD04
Material Requirements. Shows material requirements and releases against materials.
SE38 SM01
ABAP Editor. Used to modify ABAP programs. Transaction list. Lock transactions in the system. Also a good tool to see what transactions are available.
SHDB
Transaction recorder (BDC).
CMOD
User exit \ project tool. Coordinates your changes into projects for the purpose of activating all user exits for a particular project. A user exi t needs to be modified before it will work.
M_VMVAA PO -> SO View table VBFA (Doc Flow), VBUK (Hdr status), VBUP(Line status) BKPF (Accounting doc)
Table 1-A: Impo rtant SAP Tables
1.7.1.1 Basis TSTCT
Transaction list
1.7.1.2 Sales document additional VBPA
Sales document partner detail
VBUK
Header status
VBUP
Item status
VEDA
Contract data
1.7.1.3 Invoicing VBRL
Invoice list
VBRK
Header data
VBRP
Item data
1.7.1.4 Accounting BKPF
Header
BSEG
Line item
1.7.1.5 Scheduling agreements VBEH
Release history
VBEP
Current release detail
VBLB
Complete release information
1.7.1.6 Vendor master M_KREDA
Generated view
1.7.1.7 Customer master KNA1
General data
KNVV
Sales data
CHAPTER 2 USEFUL PROGRAMS 2.1
FUNCTION MODULES
2.1.1 USEREXIT_KOMKBV1_FILL. User exit to update communication structure at header level. In function module KOMKBV1_FILL called from SAPMV45A.
2.1.2 MASTER_IDOC_DISTRIBUTE 2.1.3 IDOC_STATUS_WRITE_TO_DATABASE 2.1.4 IDOC_TYPE_COMPLETE_READ Reads full IDoc structure and field documentation. Offsets, types, etc….. AB AP_DOCU_DOWNLOAD - Download ABAP documentation in HTML format. ARFC_GET_TID - will return the IP address of the terminal in hex. BAL_* - All function modules used for SAP's application logging can be found here. BP_EVENT_RAISE - Trigger an event from ABAP/4 program BP_JOBLOG_READ - Fetch job log executions CLOI_PUT_SIGN_IN_FRONT - Place the negative sign after a number. SAP default is place the negative sign after the number. CLPB_EXPORT - Export a text table to the clipboard (on presentation server) CLPB_IMPORT - Import a Text Table from the Clipboard (on presentation server) COMMIT_TEXT - To load long text into SAP CONVERSION_EXIT_ALPHA_INPUT - converts any number into a string fill with zeroes-right example: input = 123 output = 0000000000000...000000000000123
CONVERSION_EXIT_ALPHA_OUTPUT - converts any number with zeroes-right into a simple integer example: input = 00000000000123 output = 123
CONVERT_OTF - Convert SAP documents (SAPScript) to other types. example: CALL FUNCTI ON ' CONVERT_ OTF' EXPORTI NG FORMAT = ' PDF' I MPORTI NG BI N_FI LESI ZE = FI LE_LEN TABLES OTF = OTFDATA LI NES = PDFDATA EXCEPTI ONS ERR_ MAX_LI NEWI DTH = 1 ERR_ FORMAT = 2 ERR_ CONV_NOT_ POSSI BLE = 3 OTHERS = 4.
DATE_GET_WEEK - will return the week that a date is in. DATE_CHECK_PLAUSIBILITY - Check to see if a date is in a valid format for SAP. Works well when validating dates
being passed in from other systems. DOWNLOAD - download a file to the presentation server (PC)
DYNP_VALUES_READ - Read the values from a dynpro. This function can be used to read the values from a report's
selection screen too (Another example). DYNP_VALUES_UPDATE - Similar to DYNP_VALUES_READ, this function will allow the updating of fields on a dynpro. Very useful when you want to change a field based on the value entered for another field. ENQUE_SLEEP - Wait a specified period of time before continuing processing. ENQUEUE_ESFUNCTION - Lock an abap program so that it cannot be executed. Set the parameters as follows: RELID = 'ZZ' SRTF2 = 0 SRTF = (your report name) Please note that you should not use SY-REPID to pass your report name to the function. The value of SY-REPID will change as it is being passed to the function module, and will no longer hold the value of the calling report. EPS_GET_FILE_ATTRIBUTES - Pass in a filename and a path, and will return attributes for the fil e EPS_GET_DIRECTORY_LISTING - return a list of filenames from a local or network drive F4_DATE - displays a calendar in a popup window and allows user to choose a date, or it can be displayed read only. F4IF_SHLP_EXIT_EXAMPLE - documents the different reasons to use a search help exit, and shows how it is done. FILENAME_GET - popup to get a filename from a user, returns blank filename if user selects cancel FTP_CONNECT - Open a connection (and log in) to an FTP server FTP_COMMAND - Execute a command on the FTP server FTP_DISCONNECT - Close the connection (and log off) the FTP server FORMAT_MESSAGE - 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. GET_GLOBAL_SYMBOLS - Returns a list of all tables, select options, texts, etc for a program. Even includes the text definitions for the selection screen GET_INCLUDETAB - Returns a list of all INCLUDES in a program G_SET_GET_ALL_VALUES - 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. GUI_CREATE_DIRECTORY - Create a directory on the presentation server GUI_DELETE_FILE - Replaces WS_FILE_DELETE. Delete a file on the presentation server GUI_DOWNLOAD - Replaces WS_DOWNLOAD. Download table from the app server to presentation server GUI_EXEC - Replaces WS_EXECUTE. Start a File or Program Asynchronously with WinExec GUI_GET_DESKTOP_INFO - Replaces WS_QUERY. Delivers Information About the Desktop (client) GUI_REMOVE_DIRECTORY - Delete a directory on the presentation server GUI_RUN - Start a File or Program Asynchronously with ShellExecute GUI_UPLOAD - Replaces WS_UPLOAD. Upoad file from presentation server to the app server HELP_START - 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. HOLIDAY_GET - Provides a table of all the holidays based upon a Factory Calendar &/ Holiday Calendar. HR_DISPLAY_BASIC_LIST - 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. HR_GET_LEAVE_DATA - Get all leave information (includes leave entitlement, used holidays/paid out holidays) INIT_TEXT - To load long text into SAP K_WERKS_OF_BUKRS_FIND - Return a list of all plants for a given company code. LIST_TO_ASCII - convert an ABAP report (displayed on screen) from OTF to ASCII format LIST_FROM_MEMORY Retrieves the output of a report from memory when the report was executed using SUBMIT... EXPORTING LIST TO MEMORY. See also WRITE_LIST. MONTH_NAMES_GET - It returns all the month and names in repective language. MS_EXCEL_OLE_STANDARD_OLE - will build a file, and automatically start Excel OTF_CONVERT - wraps several other function modules. Will convert OTF to ASCII or PDF
CONVERT_OTFSPOOLJOB_2_PDF - converts a OTF spool to PDF (i.e. Sapscript document) CONVERT_ABAPSPOOLJOB_2_PDF - convert abap spool output to PDF POPUP_TO_CONFIRM_LOSS_OF_DATA - Create a dialog box in which you make a question whether the user wishes to
perform a processing step with loss of data. POPUP_TO_CONFIRM_STEP - Create a dialog box in which you make a question whether the user wishes to perform the step. POPUP_TO_CONFIRM_WITH_MESSAGE - Create a dialog box in which you inform the user about a specific decision point during an action. POPUP_TO_CONFIRM_WITH_VALUE - Create a dialog box in which you make a question whether the user wishes to perform a processing step with a particular object. POPUP_TO_DECIDE - Provide user with several choices as radio buttons POPUP_TO_DECIDE_WITH_MESSAGE - Create a dialog box in which you inform the user about a specific decision point via a diagnosis text. POPUP_TO_DISPLAY_TEXT - Create a dialog box in which you display a two-line message. POPUP_TO_SELECT_MONTH - Popup to choose a month POPUP_WITH_TABLE_DISPLAY - Provide a display of a table for user to select one, with the value of the table line returned when selected. PRICING - 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. PROFILE_GET - Read an Entry in an INI File on the frontend PROFILE_SET - Write an Entry in an INI File on the frontend READ_TEXT - To load long text into SAP REGISTRY_GET - Read an Entry from the Registry REGISTRY_SET - Set an entry in the Registry RFC_ABA P_INSTALL_A ND_RUN - 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. RH_GET_ACTIVE_WF_PLVAR - Return the active HR Plan RH_GET_DATE_DAYNAME - return the day based on the date provied RH_START_EXCEL_WITH_DATA -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! RH_STRUC_GET - Returns all related org info RP_CALC_DATE_IN_INTERVAL - Add/subtract years/months/days from a date RP_LAST_DAY_OF_MONTHS - Determine last day of month RPY_DYNPRO_READ - Read dynpro, including screen flow RPY_TRANSACTION_READ - Given a transaction, return the program and screen or given a program and screen, return the transactions that use the program and screen. RS_COVERPAGE_SELECTIONS - Returns an internal table that contains a formatted list of all the selection parameters entered for a report. Table is ready to print out. RS_REFRESH_FROM_SELECTOPTIONS - Get the current contents of selection screen RS_SEND_MAIL_FOR_SPOOLLIST - Send message from ABAP/4 program to SAPoffice. RS_VARIANT_CONTENTS - Returns the contents of the specified variant in a table. RZL_SLEEP - Hang the current application from 1 to 5 seconds. RZL_SUBMIT - Submit a remote report. RZL_READ_DIR_LOCAL - Read a directory on the Application Server RZL_READ_DIR - If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server
RZL_READ_FILE - 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. RZL_WRITE_FILE_LOCAL - Saves table to the presentation server (not PC). Does not use OPEN DATASET, so it does not suffer from authority checks ! SAPGUI_PROGRESS_INDICATOR - Display a progress bar on the SAP GUI, and give the user some idea of what is
happening SAVE_TEXT - To load long text into SAP SCROLLING_IN_TABLE -If you are coding a module pool and using a table-control, you can use this function
SCROLLING_IN_TABLE to handle any scrolling. (provided by Paul Kjaer) SD_DATETIME_DIFFERENCE - Give the difference in Days and Time for 2 dates SO_NEW_DOCUMENT_ATT_SEND_API1 - Send a document as part of an email. The documentation is better than normal for this function, so please read it. SO_SPLIT_FILE_AND_PATH - Split a fully pathed filename into a filename and a path. SO_SPOOL_READ - Fetch printer spool according to the spool number informed. SO_WIND_SPOOL_LIST - Browse printer spool numbers according to user informed. SX_OBJECT_CONVERT_OTF_PDF - Conversion From OTF to PDF (SAPScript conversion) SX_OBJECT_CONVERT_OTF_PRT - Conversion From OTF to Printer Format (SAPScript conversion) SX_OBJECT_CONVERT_OTF_RAW - Conversion From OTF to ASCII (SAPScript conversion) 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. SXPG_COMMAND_LIST_GET - Select a list of external OS command definitions. SXPG_COMMAND_DEFINITION_GET - Read the definition of a single external OS command from the R/3 System's database. SXPG_COMMAND_CHECK - Check whether the user is authorized to execute the specified command on the target host system with the specified arguments. SXPG_COMMAND_EXECUTE - 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. TERMINAL_ID_GET - Return the terminal id TH_DELETE_USER - Logoff a user. Similar results to using SM04. TH_ENVIRONMENT - Get the UNIX environment TH_POPUP - Display a popup system message on a specific users screen. TH_REMOTE_TRANSACTION - Run a transaction on a remote server. Optionally provide BDC data to be used in the transaction TH_USER_INFO - Give information about the current user (sessions, workstation logged in from, etc) TH_USER_LIST - Show which users are logged into an app server UNIT_CONVERSION_SIMPLE - convert weights from one UOM to another. UPLOAD - upload a file to the presentation server (PC) UPLOAD_FILES - Will load one or more files from app or presentation server WRITE_LIST -Useful for writing out the list contents that result from the function LIST_FROM_MEMORY. WS_DOWNLOAD - Save Internal Table as File on the Presentation Server WS_EXCEL - Start EXCEL on the PC WS_EXECUTE - execute a program on a windows PC WS_FILE_DELETE - Delete File at the Frontend WS_FILENAME_GET - Call File Selector WS_MSG - Create a dialog box in which you display an one-line message. WS_UPLOAD - Load Files from the Presentation Server to Internal ABAP Tables WS_VOLUME_GET - Get the label from a frontend device. WWW_LIST_TO_HTML - After running a report, call this function to convert the list output to HTML.
2.2
PROGRAMS
2.2.1 RHSOBJCH – Fixes PD Control Tables missing in t x SWU3 2.2.2 RV80HGEN Run this program to generate custom code in to standard SAP code when you have created your own conditions using transaction V/27.
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 d isappeared 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.
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 seeRKCTSEAR 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)
2.2.3 Scheduli ng of syst em maint enance j obs RSBTCDEL Clean the old background job records RSDBCREO Clean batch input session log RSPO0041 Removing old spooling objects RSSNAPDL Clean the old ABAP error dumps
3.2.1 Process on value request – F4 PROCESS ON VALUE-REQUEST. FIELD zpcr-source MODULE source_help. MODULE source_help INPUT. DATA: BEGIN OF ivalue_source OCCURS 0, source LIKE zsource-source, source_desc LIKE zsource-source_desc, END OF ivalue_source. DATA: BEGIN OF ivalue_category OCCURS 0, Data: w_progname LIKE sy-repid, w_scr_num LIKE sy-dynnr . DATA: return_values LIKE ddshretval OCCURS 0 WITH HEADER LINE. DATA: itab_dynpfields LIKE dynpread OCCURS 0 with header line, t_dynpfields LIKE dynpread. DATA: t_dyname LIKE d020s-prog, t_dynumb LIKE d020s-dnum. SELECT source source_desc FROM zsource INTO TABLE ivalue_source. IF sy-subrc = 0. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'SOURCE' dynpprog = w_progname dynpnr = w_scr_num dynprofield = 'ZPCR-SOURCE' value_org = 'S' TABLES value_tab = ivalue_source return_tab = return_values EXCEPTIONS parameter_error = 1 no_values_found = 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. ELSE . zpcr-source = return_values-fieldval. SELECT SINGLE source_desc INTO zsource-source_desc FROM zsource WHERE source = zpcr-source. ENDIF. ELSE. MESSAGE i999(b1) WITH 'No values in ZSOURCE table'. ENDIF. REFRESH itab_dynpfields. CLEAR: itab_dynpfields. t_dynpfields-fieldname = 'ZSOURCE-SOURCE_DESC'. APPEND t_dynpfields TO itab_dynpfields. t_dynumb = sy-dynnr. t_dyname = sy-repid.
* This function module must have the values added to * the internal table that you need t oread. CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING dyname = t_dyname dynumb = t_dynumb TABLES dynpfields = itab_dynpfields EXCEPTIONS invalid_abapworkarea = 1 invalid_dynprofield = 2 invalid_dynproname = 3 invalid_dynpronummer = 4 invalid_request = 5 no_fielddescription = 6 invalid_parameter = 7 undefind_error = 8 double_conversion = 9 stepl_not_found = 10 OTHERS = 11. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. LOOP AT itab_dynpfields. CASE itab_dynpfields-fieldname. WHEN 'ZSOURCE-SOURCE_DESC'. itab_dynpfields-fieldvalue = zsource-source_desc. MODIFY itab_dynpfields. ENDCASE. ENDLOOP. CALL FUNCTION 'DYNP_VALUES_UPDATE' EXPORTING dyname = t_dyname dynumb = t_dynumb TABLES dynpfields = itab_dynpfields EXCEPTIONS invalid_abapworkarea = 1 invalid_dynprofield = 2 invalid_dynproname = 3 invalid_dynpronummer = 4 invalid_request = 5 no_fielddescription = 6 undefind_error = 7 OTHERS = 8. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDMODULE.
3.3
" source_help
INPUT
REPORTS
3.3.1 Refreshing Data on report s DATA: LO_REPI D LI KE SY- REPI D, LO_SEL TAB LI KE RSPARAMS OCCURS 0 WI TH HEADER LI NE. LO_REPI D = SY- REPI D. CALL FUNCTI ON ' RS_REFRESH_FROM_ SELECTOPTI ONS' EXPORTI NG CURR_REPORT = LO_REPI D TABLES SELECTI ON_TABLE = LO_SELTAB
EXCEPTI ONS NOT_ FOUND =1 NO_REPORT =2 OTHERS =3 . I F SY- SUBRC <> 0. MESSAGE I D SY- MSGI D TYPE SY- MSGTY NUMBER SY- MSGNO WI TH SY- MSGV1 SY- MSGV2 SY- MSGV3 ENDI F. SUBMI T ( SY- REPI D) WI TH SELECTI ON- TABLE LO_SELTAB.
SY- MSGV4.
3.3.2 Tree Reports STEP ONE – ADD THESE LINES OF CODE IN THE DECLARATION AREA **** DECLARATION DATA: BEGI N OF i t ems OCCURS 100, i d t ype sy- t abi x, parent _i d t ype sy-t abi x, t ext ( 1000) , symbol , END OF i t ems, t abi x_s t ack LI KE sy- t abi x OCCURS 10 WI TH HEADER LI NE, i t ems_show LI KE i t ems OCCURS 100 WI TH HEADER LI NE. DATA: par ent _s t ack LI KE sy- t abi x OCCURS 10 WI TH HEADER LI NE, t _par ent LI KE sy- t abi x, cur rent LI KE sy- t abi x. I NCLUDE . I NCLUDE ZTREE_REPORT_I NCLUDES.
STEP TWO – ADD THESE LINES OF CODE TO POPULATE THE INTERNAL TABLE **** POPULATE DATA REFRESH par ent _st ack. cur r ent = 0. parent _st ack = 0. APPEND parent _st ack. LOOP AT i t ab_dat a. CASE i t ab_data- qual f . WHEN 1. “New par ent c ur r ent = c ur r ent + 1. PERFORM r ead_f r om_par ent _s t ack CHANGI NG t _par ent . parent _st ack = cur r ent . APPEND parent _st ack. PERFORM append_i t em USI NG cur r ent t_parent i t ab_xml _dat a. WHEN 2. “End of cur r ent l eg c ur r ent = c ur r ent + 1. PERFORM append_i t em USI NG cur r ent t_parent i t ab_xml _dat a. per f or m del et e_parent _st ack. WHEN 3. “Same l evel c ur r ent = c ur r ent + 1. PERFORM r ead_f r om_par ent _s t ack CHANGI NG t _par ent . PERFORM append_i t em USI NG cur r ent t_parent i t ab_xml _dat a. ENDCASE. ENDLOOP.
STEP THREE – ADD THESE LINES OF CODE TO PRINT THE REPORT LOOP AT i t ems WHERE par ent _i d = 0. MOVE- CORRESPONDI NG i t ems TO i t ems_ show. i t ems_show- symbol = ' +' . APPEND i t ems_ show. ENDLOOP. PERFORM pr i nt _t r ee TABLES i t ems_ show.
STEP FOUR – ADD THESE LINES OF CODE TO EXPAND \ COLLAPSE THE TREE * at line-selection - when the node is opened/closed or item double-clk AT LI NE- SELECTI ON. READ TABLE i t ems WI TH KEY par ent _i d = i t ems_s how- i d. "s ee ' hi de'
I F sy- subrc = 0. "i t em has chi l dren - expand or col l apse s y- l s i nd = 0. PERFORM expand_col l apse USI NG i t ems_ show- i d. PERFORM pr i nt _t r ee TABLES i t ems_ show. ELSE. "i t emhas NO chi l dr en - per f orm some acti on READ TABLE i t ems WI TH KEY i d = i t ems_ show- i d. WRI TE: ' Act i on per f ormed on i t em "' NO- GAP, i t ems- t ext NO- GAP, ' " , i d. ' , i t ems- i d. ENDI F.
STEP FIVE – ADD THIS INCLUDE CODE *----------------------------------------------------------------------* * INCLUDE ZTREE_REPORT_INCLUDES * *----------------------------------------------------------------------* * form append_item FORM append_i t em USI NG val ue(i d) val ue( par ent _i d) val ue(t ext ) . i t e ms - i d = i d. i t ems- par ent _i d = parent _i d. i t e ms - t ext = t e xt . APPEND i t ems. ENDFORM. " APPEND_I TEM * form read_from_stack FORM r ead_f r om_st ack CHANGI NG t abi x LI KE sy- t abi x. DESCRI BE TABLE t abi x_st ack. CHECK sy-t f i l l NE 0. READ TABLE t abi x_st ack I NDEX sy- t f i l l . t abi x = t abi x_ s t ac k. DELETE t abi x_stack I NDEX sy-t f i l l . ENDFORM. * form print tree FORM pr i nt _t r ee TABLES i t ems STRUCTURE i t ems. DATA: v_tabi x LI KE sy- t abi x, s t a r t _ t abi x LI KE sy- t a bi x, v_ l evel LI KE s y- t f i l l , v_of f set TYPE i , v_i d LI KE i t ems- i d, v_par ent _i d LI KE i t ems- parent _i d, v_parent _i d_f or_vl i ne LI KE i t ems- par ent _i d, v_pr ev_l evel TYPE i , v_ i t e ms _ count L I KE s y- t f i l l , v_vl i nes_str i ng( 200) . CHECK NOT i t ems[ ] I S I NI TI AL. SORT i t ems BY parent _i d i d. READ TABLE i t ems I NDEX 1. v_parent _i d = i t ems- par ent _i d. s t ar t _ t abi x = 1. REFRESH tabi x_st ack. DO. LOOP AT i t ems FROM st art _t abi x. v_tabi x = st ar t _t abi x = sy-t abi x. "r emember cur r ent i ndex v_ i d = i t e ms - i d. v_par ent _i d_f or_ vl i ne = i t ems- par ent _i d. * decrease level and exit loop if parent not the same as previous I F i t ems- parent _i d NE v_par ent _i d. PERFORM r ead_f r om_st ack CHANGI NG st art _t abi x. " l evel = NoOf Recs READ TABLE i t ems I NDEX st ar t _t abi x. v_parent _i d = i t ems- par ent _i d. ADD 1 TO st art _t abi x. "next l oop st ar t s fr om par ent i ndex + 1 * clear vline I F v_ l evel > 1. v_ of f s et = 2 + ( v _ l evel - 2 ) * 3 . I F v_ l evel = 1. v_ of f s et = 1. ENDI F. v_ vl i nes _s t r i ng+v_ of f s et = ' ' . ENDI F. EXI T. ENDI F. v_par ent _i d = i t ems- parent _i d. * write item FORMAT COLOR OFF . DESCRI BE TABLE t abi x_st ack LI NES v_l evel . "l evel i s no of St ackRecs WRI TE: / v_vl i nes_str i ng. v_ of f s et = v_ l evel * 3. I F v_l evel NE 0.
I F v_ pr e v_ l evel < v_ l evel . WRI TE: AT v_ of f s et ' | ' , / ' ' . WRI TE: / v_vl i nes_str i ng. ENDI F. v_ of f s et = v_ l evel * 3. WRI TE AT v_of f set ' | - - ' . ENDI F. v_ of f s et = v_ of f s et + 3. CASE i t ems- symbol . WHEN ' +' . WRI TE AT v_of f set sym_pl us_ f ol der AS SYMBOL COLOR 4 I NTENSI FI ED HOTSPOT. WHEN ' - ' . WRI TE AT v_of f set sym_mi nus_f ol der AS SYMBOL COLOR 4 I NTENSI FI ED HOTSPOT. WHEN OTHERS. FORMAT COLOR 5. ENDCASE. WRI TE: i t ems- t ext . v_ pr e v_ l evel = v_ l evel . HI DE: i t ems- i d. ADD 1 TO v_i t ems_ count . READ TABLE i t ems WI TH KEY par ent _i d = i t ems- i d. * increase level and exit loop if item has children I F sy- s ubr c = 0. s t ar t _ t abi x = s y- t a bi x. APPEND v_t abi x TO t abi x_st ack. "l evel i s no of r ecs i n st ack v_parent _i d = i t ems- par ent _i d. * set vline v_ t a bi x = v_ t a bi x + 1. READ TABLE i t ems I NDEX v_t abi x. v_ of f s et = 2 + ( v_ l evel - 1 ) * 3. I F v_ l evel > 0. I F i t ems- par ent _i d = v_par ent _i d_f or _vl i ne AND sy-subr c = 0. v_ vl i nes _ st r i ng+v_ of f s et = ' | ' . ELSE. v_ vl i nes _ st r i ng+v_ of f s et = ' ' . ENDI F. ENDI F. EXI T. ENDI F. * at last - decrease level AT LAST. * clear vline I F v_ l evel > 1. v_ of f s et = 2 + ( v _ l evel - 2 ) * 3 . I F v_ l evel = 1. v_ of f s et = 1. ENDI F. v_ vl i nes _s t r i ng+v_ of f s et = ' ' . ENDI F. " next l oop st ar t s f r om par ent i ndex, not parent i ndex + 1 " because of di f f erent parent s l evel wi l l decrease anyway PERFORM r ead_f r om_s t ack CHANGI NG st ar t _t abi x. APPEND st art _t abi x TO t abi x_st ack. "must r eturn i ndex to st ack ENDAT. ENDLOOP. DESCRI BE TABLE i t ems. I F st a r t _ t abi x > s y- t f i l l OR v_ i t e ms _c ount >= s y- t f i l l . EXI T. ENDI F. ENDDO. ENDFORM.
* form expand_collapse FORM expand_col l apse USI NG val ue( v_i d). DATA: v_no_ mor e_or phans, i t ems_ t emp LI KE i t ems OCCURS 100 WI TH HEADER LI NE. DELETE i t ems_s how WHERE parent _i d = v_i d. "t r y t o col l apse I F s y- s ubr c = 0. " s uc ces f u l l f i r s t c ol l aps e DO. "cascade col l apse - del et e ' or phans' t hat ar e l ef t REFRESH i t ems_ t emp. MOVE i t ems_ show[ ] TO i t ems_ t emp[ ] . SORT i t ems_ t emp BY i d. v_no_more_orphans = ' X' . LOOP AT i t ems_ show WHERE par ent _i d NE ' ' . READ TABLE i t ems_ t emp WI TH KEY i d = i t ems_ show- par ent _i d BI NARY SEARCH TRANSPORTI NG NO FI ELDS. I F sy- subrc NE 0. "no parent - i t ' s an orphan CLEAR v_no_mor e_or phans.
DELETE i t ems_ show. ENDI F. ENDLOOP. I F v_no_more_orphans = ' X' . EXI T. ENDI F. ENDDO. i t ems_show- symbol = ' +' . MODI FY i t ems_ show TRANSPORTI NG symbol WHERE i d = v_ i d. ELSE. "unsuccessf ul l col l apse - expand i t ems_show- symbol = ' - ' . MODI FY i t ems_ show TRANSPORTI NG symbol WHERE i d = v_ i d. LOOP AT i t ems WHERE par ent _i d = v_i d. " show chi l dr en APPEND i t ems TO i t ems_ show. ENDLOOP. LOOP AT i t ems_ show WHERE par ent _i d = v_i d. " check gr andchi l dren READ TABLE i t ems WI TH KEY par ent _i d = i t ems_ show- i d. I F sy- s ubr c = 0. i t ems_show- symbol = ' +' . ELSE. i t ems_show- symbol = ' ' . ENDI F. MODI FY i t ems_ show. ENDLOOP. ENDI F. ENDFORM.
* form read_from_parent_stack FORM r ead_f r om_parent_ st ack CHANGI NG t abi x LI KE sy- t abi x. DESCRI BE TABLE parent _s t ack. CHECK sy-t f i l l NE 0. READ TABLE parent _st ack I NDEX sy- t f i l l . t abi x = parent _stack. * DELETE tabix_stack INDEX sy-tfill. ENDFORM. *& Form delete_parent_stack *&---------------------------------------------------------------------* f or m del et e_parent _stack. DESCRI BE TABLE parent _s t ack. CHECK sy-t f i l l NE 0. DELETE parent _st ack I NDEX sy-t f i l l . endfor m. " del ete_par ent _st ack
3.3.3 Initializing date ranges on selection-options sel ect i on- screen begi n of bl ock g1 wi t h f r ame t i t l e text - 000. sel ect - opt i ons: s_docdat f or vbak- erdat . "Document dat e sel ect i on- screen end of bl ock g1. * I ni t i al i z at i on * *----------------------------------------------------------------------* i ni t i al i z at i on. * Defaul t dat es to dsel scr een move ' I ' t o s_docdat- si gn. move ' BT' t o s_docdat - opt i on. move sy- dat um t o s_docdat - hi gh. subt r act 7 f r om sy- datum. move sy- dat um t o s_docdat - l ow. append s_ docdat.
SELECT-OPTIONS T1 FOR MBEW-MATNR MEMORY ID MAT.
3.3.4 Report headings t op- of - page. per f or m t op. f or m t o p. ul i ne. wr i t e: / sy-vline no-gap, (79) text-001 color col_heading intensified,
80 sy- vl i ne, / sy- vl i ne no- gap, ( 79) t ext - 002 col or col _headi ng i nt ensi f i ed of f , 80 sy- vl i ne, / sy- vl i ne no- gap, ( 79) t ext - 003 col or col _headi ng i nt ensi f i ed of f , 80 sy- vl i ne.
ul i ne. endf or m.
3.3.5 Popup selection – Get Filename * See pr ogr am RSSPO410 f or exampl es of t hi s FM DATA: r et urncode LI KE sy- subr c, f i l es t r i ng TYPE s t r i ng. DATA: BEGI N OF f i el ds OCCURS 2. I NCLUDE STRUCTURE s val . DATA: END OF f i el ds. CLEAR f i el ds. f i el ds-t abname f i el ds- f i el dname f i el ds - v al ue f i el ds- f i el d_ at t r APPEND f i el ds.
= = = =
' ' ' '
RLGRAP' . FI LENAME' . C: \ TEST. XL S' . 00' .
CALL FUNCTI ON ' POPUP_ GET_ VALUES' EXPORTI NG POPUP_TI TLE = TEXT- 026 I MPORTI NG RETURNCODE = RETURNCODE TABLES FI EL DS = f i el ds EXCEPTI ONS ERROR_I N_F I ELDS = 1 OTHERS = 2. CHECK RETURNCODE EQ SPACE.
f i l es t r i ng = f i el ds - v al ue.
3.3.6 Checkbox es in reports To put a delete button on the screen (Fcode = DELETE) with a checkbox on each line. at user - command. cas e sy- ucomm. when ' DELETE' . do counter t i mes. read l i ne sy- i ndex. if sy-lisel(1) = 'X'.
“Holds line content and sy-lisel(1) will be X when checked
sel ect si ngl e * f rom …… endi f . enddo. per f or m wr i t e_ r e por t . s y- l s i nd = 0. endcase. f or m wr i t e_ r e por t . sel ect * f rom …. write: / pick as checkbox,
…… hi de: ……. endsel ect . count er = sy-dbcnt + 7. endf or m. " WRI TE_REPORT
“Cat er f or header l i nes
s t ar t - of - s el ec t i on. s et pf - s t a t us ' STD' . per f or m wr i t e_ r e por t .
3.3.7 Lis t Boxes on Selection Screens Here is a short example of using list boxes on selection screens: PROGRAM zt est . TYPE- POOLS: vr m. DATA: name TYPE vr m_i d, l i st TYPE vr m_val ues, val ue LI KE LI NE OF l i st . PARAMETERS: ps_ par m( 10) AS LI STBOX VI SI BLE LENGTH 10. AT SELECTI ON- SCREEN OUTPUT. name = ' PS_PARM' . val ue- key = ' 1' . val ue- t ext = ' Li ne 1' . APPEND val ue TO l i st. val ue- key = ' 2' . val ue- t ext = ' Li ne 2' . APPEND val ue TO l i st. CALL FUNCTI ON ' VRM_SET_VALUES' EXPORTI NG i d = name val ues = l i st . START- OF- SELECTI ON.
WRI TE: / ' Par ameter : ' , ps_par m.
3.3.8 At line selection DATA:
FI ELD_NAME(30) , T_I DOC LI KE EDI DC- DOCNUM.
"Check f or l i ne sel ecti on on f i el d " St or e I Doc number f or l i ne sel ect n
* - - - EVENT : AT LI NE SELECTI ON - - AT LI NE- SELECTI ON. * Ret ur n the f i el d t hat t he user cl i cked on GET CURSOR FI ELD FI ELD_ NAME. CASE FI ELD_NAME. * Cl i cked on I nvoi ce number WHEN ' I TAB_SO- I NVOI C_ NO' . SET PARAMETER I D ' VF' FI ELD I TAB_ SO- I NVOI C_NO. CALL TRANSACTI ON ' VF03' AND SKI P FI RST SCREEN. " Vi ew I nvoi ce * Cl i cked on del i ver y number WHEN ' I TAB_SO- DELI VERY' . SET PARAMETER I D ' VL' FI ELD I TAB_ SO- DELI VERY. CALL TRANSACTI ON ' VL03' AND SKI P FI RST SCREEN. " Vi ew del i ver y * Cl i cked on Sal es Or der number WHEN ' I TAB_SO- VBELN' . SET PARAMETER I D ' AUN' FI ELD I TAB_SO- VBELN. CALL TRANSACTI ON ' VA03' AND SKI P FI RST SCREEN. " Vi ew Sal es Or der * I doc # c l i c ked WHEN ' I TAB_SO- DOCNUM' . I F I TAB_SO- DOCNUM <> ' ' . MOVE I TAB_SO- DOCNUM TO T_I DOC. CALL FUNCTI ON ' EDI _DOCUMENT_DATA_DI SPLAY' " Di spl ay I doc EXPORTI NG DOCNUM = T_I DOC TREE_DI SPLAY = ' Y' EXCEPTI ONS NO_DATA_RECORD_ FOUND = 1 OTHERS = 2. I F SY- SUBRC <> 0. MESSAGE I 999(B1) WI TH ’ Cl i ck on I Doc. ’ . ENDI F. ELSE. MESSAGE I 999(B1) WI TH ’ Cl i ck on I Doc. ’ . ENDI F. ENDCASE.
3.3.9 Tabstri ps on a selection screen *&---------------------------------------------------------------------* *& Report ZTABSTRIP * *& Author: Kevin Wilson * *& HTTP://www.sapgenie.com - Portal for SAP consultants * *&---------------------------------------------------------------------* REPORT ztabstrip LINE-SIZE 120 NO STANDARD PAGE HEADING. TABLES: mara, lfa1, ekpo. *---------------------------------------------------------------------* * selection screen * *---------------------------------------------------------------------* * Define screen 101 as subscreen SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t00. SELECT-OPTIONS matnr FOR mara-matnr. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN END OF SCREEN 101. * Define screen 102 as subscreen SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02. SELECT-OPTIONS: kunnr FOR lfa1-kunnr. SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN END OF SCREEN 102. * Define screen 103 as subscreen SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN. SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
PARAMETERS werks LIKE ekpo-werks. SELECTION-SCREEN END OF BLOCK b3. SELECTION-SCREEN END OF SCREEN 103. * Define tab screen SELECTION-SCREEN BEGIN OF TABBED BLOCK t1 FOR 20 LINES. SELECTION-SCREEN TAB (10) name1 USER-COMMAND ucomm1 DEFAULT SCREEN 101. SELECTION-SCREEN TAB (20) name2 USER-COMMAND ucomm2 DEFAULT SCREEN 102. SELECTION-SCREEN TAB (30) name3 USER-COMMAND ucomm3 DEFAULT SCREEN 103. SELECTION-SCREEN END OF BLOCK t1. INITIALIZATION. name1 = text-n01. name2 = text-n02. name3 = text-n03.
3.3.10
"Material "Vendor "Plant
Dynamic selection screens
*--- SELECTION OPTIONS --------------------------------------SELECTI ON- SCREEN BEGI N OF BLOCK SO WI TH FRAME TI TLE TEXT- 001. SELECT- OPTI ONS: S_VBELN FOR VBAK- VBELN, " Sal es or der number S_VBELND FOR LI KP- VBELN, " Del i ver y number S_VBELNI FOR VBRK- VBELN, " I nvoi ce number S_ VBELNP FOR VBKD- BSTKD. " PO number SELECTI ON- SCREEN END OF BLOCK SO.
*--- EVENT AT SCREEN OUTPUT ------------------------------AT SELECTI ON- SCREEN OUTPUT. CASE SY- TCODE. WHEN ' ZEDI 6' . LOOP AT SCREEN. CASE SCREEN- GROUP4. WHEN ' 001' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 002' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 003' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 004' . SCREEN- ACTI VE = MODI FY SCREEN. ENDCASE. ENDLOOP. WHEN ' ZEDI 6D' . LOOP AT SCREEN. CASE SCREEN- GROUP4. WHEN ' 001' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 002' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 003' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 004' . SCREEN- ACTI VE = MODI FY SCREEN. ENDCASE. ENDLOOP. WHEN ' ZEDI 6I ' . LOOP AT SCREEN. CASE SCREEN- GROUP4. WHEN ' 001' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 002' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 003' .
' 1' .
"Sal es order sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"Del i ver y sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"I nvoi ce sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
" PO Sel ect "1=Act i ve, 0=Don' t di spl ay
"Del i ver y sel ect
' 0' .
"Sal es order sel ect "1=Act i ve, 0=Don' t di spl ay
' 1' .
"Del i ver y sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"I nvoi ce sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
" PO Sel ect "1=Act i ve, 0=Don' t di spl ay
"I nvoi ce sel ect
' 0' .
"Sal es order sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"Del i ver y sel ect "1=Act i ve, 0=Don' t di spl ay "I nvoi ce sel ect
SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 004' . SCREEN- ACTI VE = MODI FY SCREEN. ENDCASE. ENDLOOP. WHEN ' ZEDI 6P' . LOOP AT SCREEN. CASE SCREEN- GROUP4. WHEN ' 001' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 002' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 003' . SCREEN- ACTI VE = MODI FY SCREEN. WHEN ' 004' . SCREEN- ACTI VE = MODI FY SCREEN. ENDCASE. ENDLOOP. ENDCASE.
3.4
' 1' .
"1=Act i ve, 0=Don' t di spl ay
' 0' .
" PO Sel ect "1=Act i ve, 0=Don' t di spl ay
" PO sel ect
' 0' .
"Sal es order sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"Del i ver y sel ect "1=Act i ve, 0=Don' t di spl ay
' 0' .
"I nvoi ce sel ect "1=Act i ve, 0=Don' t di spl ay
' 1' .
" PO Sel ect "1=Act i ve, 0=Don' t di spl ay
FILE PROCESSING
3.4.1 Downloading to Excel REPORT ztablexls. ******************************************************************** * Developer : S.Srini. * Location : Chennai, * : Tamil Nadu, * : India. * Date : 3/10/2001. ******************************************************************** * TESTED - MS EXCEL 97 * NOT RECOMMENDED FOR LENGTHY OUTPUT AND LARGE DATA TABLE BROWSING ******************************************************************** TABLES: USR03,DD02L. DATA: ZX030L LIKE X030L. DATA BEGIN OF ZDFIES OCCURS 0. INCLUDE STRUCTURE DFIES. DATA END OF ZDFIES. DATA: BEGIN OF FLDITAB OCCURS 0, FLDNAME(11) TYPE C, END OF FLDITAB. DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE. DATA TNAME LIKE DD02L-TABNAME. SELECT * FROM USR03 INTO TABLE ITABUSR03. TNAME = 'USR03'. PERFORM GETFIELEDS. PERFORM SHOW123. ******************************************** FORM GETFIELEDS. CALL FUNCTION 'GET_FIELDTAB' EXPORTING LANGU = SY-LANGU ONLY = SPACE TABNAME = TNAME WITHTEXT = 'X' IMPORTING HEADER = ZX030L TABLES FIELDTAB = ZDFIES
EXCEPTIONS INTERNAL_ERROR = 01 NO_TEXTS_FOUND = 02 TABLE_HAS_NO_FIELDS = 03 TABLE_NOT_ACTIV = 04. CASE SY-SUBRC. WHEN 0. LOOP AT ZDFIES. FLDITAB-FLDNAME = ZDFIES-FIELDNAME. APPEND FLDITAB. ENDLOOP. WHEN OTHERS. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO with SY-SUBRC. ENDCASE. ENDFORM. *********************************** FORM SHOW123. CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT' EXPORTING FILE_NAME = 'C:\USR03.XLS' DATA_SHEET_NAME = 'USER LIST' TABLES DATA_TAB = ITABUSR03 FIELDNAMES = FLDITAB EXCEPTIONS FILE_NOT_EXIST =1 FILENAME_EXPECTED =2 COMMUNICATION_ERROR =3 OLE_OBJECT_METHOD_ERROR = 4 OLE_OBJECT_PROPERTY_ERROR = 5 INVALID_FILENAME =6 INVALID_PIVOT_FIELDS =7 DOWNLOAD_PROBLEM =8 OTHERS = 9. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM.
3.4.2 FTP a file to another s erver Here is an example of how to FTP a file from the Application server to a remote server using standard SAP functions. %&%& RDI RZKBTST32 ZKBTST32 1S 19990728 19990728 731H 001EX 1999072815590400000000000000 %&%& REPOZKBTST32 REPORT ZKBTST32 LI NE- SI ZE 132. *----------------------------------------------------------------------* Test SAP FTP f unct i ons *----------------------------------------------------------------------DATA: BEGI N OF MTAB_ DATA OCCURS 0, LI NE(132) TYPE C, END OF MTAB_ DATA. DATA: MC_PASSWORD( 20) TYPE C, MI _ KEY TYPE I VALUE 26101957, MI _ PWD_LEN TYPE I , MI _ HANDLE TYPE I . START- OF- SELECTI ON. MC_ PASSWORD = ' pass wor d' . DESCRI BE FI ELD MC_PASSWORD LENGTH MI _PWD_LEN.
*- - FTP_CONNECT r equi r es an encr ypted passwor d t o wor k CALL ' AB_ RFC_X_SCRAMBLE_STRI NG' I D ' SOURCE' FI ELD MC_PASSWORD I D ' KEY' FI ELD MI _KEY I D ' SCR' FI ELD ' X' I D ' DESTI NATI ON' FI ELD MC_PASSWORD I D ' DSTLEN' FI ELD MI _PWD_ LEN. CALL FUNCTI ON ' FTP_ CONNECT' EXPORTI NG USER = ' useri d' PASSWORD = MC_PASSWORD HOST = ' ser vername' RFC_DESTI NATI ON = ' SAPFTP' I MPORTI NG HANDLE = MI _HANDLE EXCEPTI ONS NOT_ CONNECTED = 1 OTHERS = 2. CHECK SY- SUBRC = 0. CALL FUNCTI ON ' FTP_COMMAND' EXPORTI NG HANDLE = MI _HANDLE COMMAND = ' di r ' TABLES DATA = MTAB_ DATA EXCEPTI ONS TCPI P_ERROR = 1 COMMAND_ERROR = 2 DATA_ERROR = 3 OTHERS = 4. I F SY- SUBRC = 0. LOOP AT MTAB_DATA. WRI TE: / MTAB_ DATA. ENDLOOP. ELSE. * do some err or checki ng. ENDI F. CALL FUNCTI ON ' FTP_ DI SCONNECT' EXPORTI NG HANDLE = MI _HANDLE EXCEPTI ONS OTHERS = 1. %&%& TEXPZKBTST32 R FTP f r om SAP {{{ %&%& HEADZKBTST32 00000 00000000000000 0000000000000000000000 0 %&%& DOKLZKBTST32
3.4.3 DATASET 3.4.3.1 Example 1 * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m SENDTO_UNI X * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * FORM SENDTO_UNI X. * open data set t o t r ansf er ext r act dat a OPEN DATASET Z_ FI LE_ NAME FOR OUTPUT I N TEXT MODE. I F SY- SUBRC NE 0. * Fi l e coul d not be opened f or wr i t i ng WRI TE: / TEXT- 006. LI _WRI TE_ERROR = 1. EXI T. ENDI F. LOOP AT I T_PAYR. TRANSFER I T_PAYR TO Z_ FI LE_ NAME. ENDLOOP. * cl ose dat aset CLOSE DATASET Z_FI LE_ NAME.
3.4.3.2 Example 2 OPEN DATASET OUTFI LE FOR OUTPUT I N TEXT MODE. * i f t he t i mestamped f i l e cannot be created, do not pr ocess t he * i nput f i l e, because t he i nput f i l e i s del et ed af t er processi ng, * and t her e woul d be no r ecor d of t he dat a. i f not s y- s ubr c i s i ni t i al . *' ERROR openi ng f i l e & f or out put ' c l os e dat as et i nf i l e. message i 033 wi t h out f i l e. cont i nue. "process next vendor ' s f i l e endi f . do. r ead dat aset i nf i l e i nt o i zss7b20. case sy-subr c. when 0. t r ansf er i zss7b20 t o out f i l e. i f i z s s7b20- dat a code = ' T' . " t r a i l er r ec per f or m pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor' s f i l e endi f . check i zss7b20- dat acode = ' D' . "dat a r ec move- corr espondi ng uty_vendor s t o i e020. move- corr espondi ng i zss7b20 t o i e020. when 4. " EOF perf orm pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor ' s f i l e when ot her s. * ERROR r eadi ng dat aset & on & message w015 wi t h i nf i l e sy- dat um. exi t . " di s cont i nue f i l e r e ads endcase. enddo. c l os e dat a set : i nf i l e, out f i l e. del et e dat a s et i nf i l e.
3.4.4 WS_DOWNLOAD *** I nter nal t abl e t o be downl oaded dat a: begi n of z_sal es occur s 10000, kunnr l i ke kna1- kunnr , name1 l i ke kna1- name1, end of z_ sal es. dat a: begi n of t _col names occurs 10, name( 15) , end of t _col names.
" Cust omer number " Name " Col umn names f or downl oad
sel ect i on- screen begi n of bl ock g2 wi t h f r ame t i t l e text - 001. par ameter s: p_pri nt r adi obut t on group l 1, “Vi ew p_down r adi obut t on gr oup l 1, “Downl oad p_ f i l e l i ke r l gr a p- f i l ename def aul t ' C: \ ' . sel ect i on- screen end of bl ock g2. *----------------------------------------------------------------------* * Sel ecti on Scr een processi ng * *----------------------------------------------------------------------* at sel ecti on- screen on p_f i l e. * I f downl oad i s checked, but no f i l e name i s ent ered, err or i f p_down eq ' X' and p_f i l e eq space. mess age e000 wi t h ' Pl ease ent er f i l e name for downl oad. ' . endi f . *** Popul ate I t abs f or downl oad * Col umn names move ' Sol d- t o' t o t _col names- name. append t _c ol names. move ' Name' t o t _ col names- name. append t _c ol names. * Dat a move vbak- kunnr t o zsal es- kunnr . move kna1- name1 t o zsal es- name1. append zsal es.
* Cal l f unct i on modul e to downl oad f i l e cal l f unct i on ' WS_DOWNLOAD' export i ng f i l ename = p_ f i l e f i l et y pe = ' DAT' * col _ sel ect = ' X' t abl es data_tab = z_sal es f i el dnames = t _col names * EXCEPTI ONS * FI LE_OPEN_ ERROR =1 * FI LE_WRI TE_ERROR =2 * I NVALI D_FI LESI ZE =3 * I NVALI D_TABLE_WI DTH =4 * I NVALI D_TYPE =5 * NO_BATCH =6 * UNKNOWN_ERROR =7 * GUI _ REFUSE_FI LETRANSFER = 8 * OTHERS =9 . i f s y- s ubr c <> 0. message i d sy- msgi d t ype sy- msgt y number sy- msgno wi t h sy- msgv1 sy- msgv2 sy- msgv3 sy- msgv4. endi f .
3.4.5 GUI_DOWNLOAD with POPUP filename request DATA: f i l estr i ng
TYPE str i ng.
DATA: BEGI N OF f i el ds OCCURS 2. I NCLUDE STRUCTURE s val . DATA: END OF f i el ds. CLEAR f i el ds. f i el ds-t abname f i el ds- f i el dname f i el ds - val ue f i el ds- f i el d_ at t r APPEND f i el ds.
= = = =
' RLGRAP' . ' FI LENAME' . p_ f i l e. ' 00' .
CALL FUNCTI ON ' POPUP_GET_ VALUES' EXPORTI NG popup_t i t l e = t ext - 003 I MPORTI NG r eturncode = r etur ncode TABLES f i el ds = f i el ds EXCEPTI ONS er r or _ i n_ f i el ds = 1 OTHERS = 2. CHECK r et ur ncode EQ space. f i l es t r i ng = f i el ds - val ue. CALL FUNCTI ON ' GUI _ DOWNLOAD' EXPORTI NG f i l ename wr i t e _ f i el d_ s epar a t or TABLES dat a_tab EXCEPTI ONS f i l e_ wr i t e _er r or no_bat ch gui _ r e f u se_ f i l et r ans f e r i nval i d_ t y pe no_aut hor i t y unknown_err or header_not_al l owed separat or_not_al l owed f i l es i z e_ not _ al l owed header_t oo_l ong dp_err or _cr eat e dp_err or_send dp_err or _wr i t e unknown_dp_er r or access_ deni ed dp_out _of _memor y di s k_ f u l l
= f i l es t r i ng =',' = i t ab_dat a =1 =2 =3 =4 =5 =6 =7 =8 =9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17
dp_t i meout = 18 f i l e_not _f ound = 19 dat apr ovi der_except i on = 20 c ont r o l _ f l us h_ er r or = 21 OTHERS = 22. I F sy- subrc <> 0. MESSAGE s999(b1) WI TH ' Fi l e ' f i l estr i ng ' NOT cr eat ed! ' . ELSE. MESSAGE s999(b1) WI TH ' Fi l e ' f i l estr i ng ' Cr e at e d s uc ces s f ul l y! ' . ENDI F. " Check on downl oad succes s
3.5
MACROS
See section 7.10.8 for an example. DEFINE : define add_comma. * add comma for selection criteria output string if offset > 0. &1_string_&2+offset(1) = ','. offset = offset + 2. endif. END-of-definition.
" add_comma
USAGE: add_ comma &1 &2. DEFINE : DEFINE create_string. * loop for inclusions loop at s_&1. offset = strlen( &1_string_&2 ). c_low = s_&1-low. c_high = s_&1-high. shift c_low left deleting leading '0'. shift c_high left deleting leading '0'. shift c_low left deleting leading space. shift c_high left deleting leading space. if '&1' = 'date'. concatenate c_low+4(2) '/' c_low+6(2) '/' c_low+2(2) into c_low. if not c_high is initial. concatenate c_high+4(2) '/' c_high+6(2) '/' c_high+2(2) into c_high. endif. endif. case s_&1-option. when 'EQ'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = c_low. when 'NE'. check s_&1-sign = '&3'. add_comma &1 &2. &1_string_&2+offset = c_low. when 'GT'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = 'Greater than'. offset = offset + 13. &1_string_&2+offset = c_low. when 'LE'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = 'Less than or equal to'. offset = offset + 22. &1_string_&2+offset = c_low. when 'LT'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = 'Less than'. offset = offset + 10. &1_string_&2+offset = c_low.
when 'BT'. check s_&1-sign = '&2'. add_comma &1 &2. concatenate &1_string_&2 c_low '-' c_high into &1_string_&2 separated by space. when 'NB'. check s_&1-sign = '&3'. add_comma &1 &2. concatenate &1_string_&2 c_low '-' c_high into &1_string_&2 separated by space. endcase. endloop. END-OF-DEFINITION. " create_string USAGE: creat e_str i ng dat e I E.
DEFINE : DEFINE WRITE_STRING. if ( &1_string_I is initial and &1_string_E is initial ). &1_string_I = 'All'. endif. if not &1_string_I is initial. write: /05 h_tag, 22 'include:', 31 &1_string_I. if not &1_string_E is initial. write: /22 'exclude:', 31 &1_string_E. endif. elseif not &1_string_E is initial. write: /05 h_tag, 22 'exclude:', 31 &1_string_E. endif. END-OF-DEFINITION. USAGE: write_string date.
3.6
" write_string
SELECT STATEMENTS
3.6.1 Joins See section 7.10.8 for an example. START-OF-SELECTION. * ASSUMPTION: All quantities are in sales units. Since quantities * are summed to the material group level, it is assumed that all * materials within a material group have the same sales unit of * measure. select a~kunag a~vbeln a~fkdat a~bukrs a~vbtyp b~matkl b~matnr b~arktx b~fkimg b~kzwi2 b~wavwr c~name1 d~kunn2 into corresponding fields of table replines from vbrk as a inner join vbrp as b on a~vbeln = b~vbeln inner join kna1 as c on a~kunag = c~kunnr left outer join knvp as d on a~kunag = d~kunnr and a~vkorg = d~vkorg and a~vtweg = d~vtweg and d~spart = '71' and d~parvw = 'CO' and d~parza = '000' where a~vkorg = '7100' and a~vbtyp in r_vtyp and a~fkdat in s_date and a~kunag in s_cust and b~matkl in s_mgrp and b~autyp in r_atyp. END-OF-SELECTION.
3.7
SAPSCRIPT
3.7.1 Changing the sub ject for email order confi rmations An output type ZEXT was created to send emails of order confirmations to a certain distribution list in PDF format. (See the SAP Exchange Connector Implementation Documentation for details on this setup.) The following code and config was implemented in order to change the email subject line.
Configuration for ZEXT (External order confirmation by email) Transaction: V/30 General Data: Access Seq: 0009 (SalesOrg./Cust./Order type), Access to Conditions CHECKED. Replacement of text s ymbo ls – Prog ram: ZEXT. Form ro utin e: TEXT_SYMBOL_REPLACE
Default Values: Transmission Medium: 5. Communication Strategy CS01. Mail and Titl es: &KUNNR&:Order & VBELN&
Processing Routines: Program: RVADOR01, Form Routine: ENTRY, Form: YPCC_ORDCONF_STD
Condition Record Using VV12 you need to add a condition record as applicable. Note that the Communication record must point to your ZMAIL output device and has the following entry as Text for Cover Page: &KUNNR&(&VBELN&)
Code for ZEXT subject definition REPORT zext. ************************************************************************ * Author: Kevin Wilson * Date: 01/07/2003 * Description: This program changes the title of the email for output * type ZEXT. Maintain output type ZEXT using V/30. * The mail title and texts tab has entry: * &KUNNR&:Order &VBELN& * The general tab has entry in Replacement of text * symbols: Program ZEXT. Form:TEXT_SYMBOL_REPLACE ************************************************************************ tables: kna1. FORM text_symbol_replace TABLES xtlines STRUCTURE tline USING xthead STRUCTURE thead snast STRUCTURE nast. data: t_vbeln(10) type c. DESCRIBE TABLE xtlines LINES CHECK sy-tabix GT 0.
sy-tabix.
LOOP AT xtlines. move snast-objky to t_vbeln. replace '&VBELN&' with t_vbeln into xtlines-tdline. select single name1 into kna1-name1 from kna1 where kunnr = snast-parnr. replace '&KUNNR&' with kna1-name1 into xtlines-tdline. condense xtlines-tdline. modify xtlines. ENDLOOP. ENDFORM.
3.8
GENERAL
3.8.1 Retrieving the email address of an SAP user call function 'SUSR_USER_ADDRESS_READ' exporting user_name = sy-uname
3.8.2 Executi ng a program ****************************************************************
FORM downl oadht ml . CALL FUNCTI ON ' WS_ DOWNLOAD' EXPORTI NG f i l ename = ' C: \ TABLEVI EW. HTM' TABLES data_t ab = ht ml vi ew. I F sy- subrc <> 0. MESSAGE I D sy- msgi d TYPE s y- msgt y NUMBER sy- msgno WI TH sy- msgv1 s y- msgv2 s y- msgv3 s y- msgv4. ENDI F. ENDFORM. ***************************************************************
FORM showht ml . CALL FUNCTI ON ' WS_EXECUTE' EXPORTI NG commandl i ne = ' c: \ t abl evi ew. ht m' pr ogr am = ' C: \ PROGRA~1\ I NTERN~1\ I EXPLORE. EXE' . I F sy- subrc <> 0. MESSAGE I D sy- msgi d TYPE s y- msgt y NUMBER sy- msgno WI TH sy- msgv1 s y- msgv2 s y- msgv3 s y- msgv4. ENDI F. ENDFORM. ************************************************************************
3.8.3 Changing \ Creating Requirements Use transaction V/27
3.8.4 Displaying Transaction Set parameter I D ‘ AUN’ f i el d vbak- vbel n. Cal l t ransacti on ‘ VA03’ and ski p fi r st screen.
3.8.5 GUI-Status
BACK
%EX
RW
PRI
%SC
%SC+
P- -
P-
P+
P++
3.8.6 Document Flow REPORT ZWSBDOCFLOW LI NE- SI ZE 170 LI NE- COUNT 65 MESSAGE- I D ZO NO STANDARD PAGE HEADI NG. TABLES: VBAK, VBCO6, LI KP, VBDPR. DATA: XVBFA LI KE VBFA OCCURS 1 WI TH HEADER LI NE. DATA: XLI KP LI KE LI KP OCCURS 1 WI TH HEADER LI NE. SELECT- OPTI ONS: VBELN FOR VBAK- VBELN DEFAULT ' 0000185996' TO ' 0000186003' . SELECT * FROM VBAK WHERE VBELN I N VBELN. MOVE- CORRESPONDI NG VBAK TO VBCO6. CLEAR XVBFA. REFRESH XVBFA. CLEAR XLI KP. REFRESH XLI KP. CALL FUNCTI ON ' RV_ ORDER_FLOW_ I NFORMATI ON' EXPORTI NG COMWA = VBCO6 TABLES VBFA_TAB = XVBFA. LOOP AT XVBFA WHERE ( VBTYP_N = ' J ' ) AND ( VBTYP_V = ' C' ) . MOVE: XVBFA- VBELN TO XLI KP- VBELN. COLLECT XLI KP. ENDLOOP. CHECK NOT XLI KP[ ] I S I NI TI AL. CLEAR VBDPR- TDNAME. " 70 char s WRI TE: / VBAK- VBELN. LOOP AT XLI KP. WRI TE: / 5 XLI KP- VBELN. SELECT SI NGLE * FROM LI KP WHERE VBELN EQ XLI KP- VBELN. CHECK SY- SUBRC I S I NI TI AL. WRI TE: ' f ound' . ENDLOOP. ENDSELECT.
3.8.7 Maint aining Traili ng spaces when down loading to PC Before calling DOWNLOAD or WS_DOWNLOAD, do a
per f orm SET_TRAI L_BLANKS(s apl grap) usi ng ' X'
To set the length of each record including your blanks add this code:
perf orm SET_FI XLEN( sapl grap) usi ng
' 0' ' 100'
3.8.8 Hidi ng ABAP Sourc e Code It is very easy to hide your source code in ABAP. Simply enter *@#@@[SAP] on the very first line of your program. This text should be the only text on the line. There is no easy way to get your source code back, so make sure you make a backup and save it to a local drive!
3.8.9 Where in IMG is a table configured •
Use SM31, enter the table name.
•
Click on Customizing.
•
Enter an IMG project, or click w/o proj button.
•
Click enter. Gives you IMG path(s) which lead to updating given table.
3.8.10
Editor Tips (*EJECT and *$*$)
•
•
*EJECT - If you put *EJECT at the start of a line, it will force a new page when you print your source code. This comes in real handy when you would like to have subroutines start at the top of a new page. *$*$* - By placing *$*$ at the beginning of a comment line will lock the line for editing. You are able to edit the line until you hit the enter key.
3.8.11
List of ways to transport variants
There are at least three ways that I know of that you can transport a variant for a program. •
•
•
When you first transport a program, all elements of a program are transported along with the source code. This includes any variants that have been created at this time After the first time a program has been transported, there are two ways to move a variant. The first method is to manually add an entry to the transport for the variant you want to move. The format of the entry is LIMU VARX xxxxxxxxName_of_the_variant where xxxxxxxx is the program name. The last method is the easiest, in that you do not have to remember any arcane codes. Go to the ABAP editor, and go to the variant screen. Under the Utilitles menu is Transport Variant. This allows you to choose the variants to transport, and the transport to put them in.
3.8.12
Checking for background processing
If you want to see if the user is running the program in the foreground: sy-subty = 4. “Call type for submit otherwise it is a background submit:
3.8.12.1 Example * Di spl ay t he GUI st atus i f r un i n f oregr ound other wi se don’ t i f s y- s ubt y = 4. set pf- status ' GH' . endi f .
CHAPTER 4 WORKFLOW PROGRAMS 4.1
VIEWING PARTICULAR USERS INBOX
REPORT z_view_workflow_inbox. DATA itab_list LIKE swkwlhead OCCURS 0 WITH HEADER LINE. DATA: field_name(30), "Check for line selection on field t_wi_id like SWWWIHEAD-WI_ID, t_uname like sy-uname. * 'Select User ID and execute to view inbox' SELECTION-SCREEN COMMENT 5(50) text-001 MODIF ID sc1. * 'User ID Selection' SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002. PARAMETERS: p_uname LIKE USR02-BNAME DEFAULT sy-uname OBLIGATORY. SELECTION-SCREEN END OF BLOCK b1. * Sort Criteria SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-003. PARAMETERS: p_sort1 RADIOBUTTON GROUP sor1, p_sort2 RADIOBUTTON GROUP sor1, p_sort3 RADIOBUTTON GROUP sor1, p_sort4 RADIOBUTTON GROUP sor1, p_sort5 RADIOBUTTON GROUP sor1, p_sort6 RADIOBUTTON GROUP sor1. SELECTION-SCREEN END OF BLOCK b2. *----------------------------------------------------------------------* * Initialization *----------------------------------------------------------------------* INITIALIZATION. PERFORM update_sel_screen_attributes. TOP-OF-PAGE. FORMAT COLOR COL_HEADING. WRITE 'Woritem ID'. WRITE AT 15 'Description'. WRITE AT 135 'Date'. WRITE AT 146 'Time'. WRITE AT 155 'Parent ID'. WRITE AT 168 'Task'. WRITE AT 183 'Status'. FORMAT COLOR OFF. *----------------------------------------------------------------------* * Start of Selection *----------------------------------------------------------------------* START-OF-SELECTION. REFRESH itab_list. t_uname = p_uname. CALL FUNCTION 'SWK_LOCAL_INBOX_GET' EXPORTING user_id = t_uname user_langu = 'E' TABLES wi_list = itab_list. READ TABLE itab_list INDEX 1. IF sy-subrc = 0. IF p_sort1 = 'X'. SORT itab_list BY wi_id. ELSEIF p_sort2 = 'X'. SORT itab_list BY wi_text. ELSEIF p_sort3 = 'X'. SORT itab_list BY wi_cd wi_ct. ELSEIF p_sort4 = 'X'. SORT itab_list BY wi_chckwi.
ELSEIF SORT ELSEIF SORT ENDIF. ENDIF.
p_sort5 = itab_list p_sort6 = itab_list
'X'. BY wi_rh_task. 'X'. BY wi_stat.
LOOP AT itab_list. WRITE: / itab_list-wi_id, itab_list-wi_text, itab_list-wi_cd, itab_list-wi_ct, itab_list-wi_chckwi, itab_list-wi_rh_task, itab_list-wi_stat. HIDE itab_list-wi_id. HIDE itab_list-wi_rh_task. ENDLOOP. IF sy-subrc <> 0. MESSAGE i999(b1) WITH 'No Workflow items found in the inbox of ' p_uname. ELSE. WRITE: / '***', sy-tfill, 'entries ***'. ENDIF. END-OF-SELECTION. AT LINE-SELECTION. * Return the field that the user clicked on GET CURSOR FIELD field_name. CASE field_name. WHEN 'ITAB_LIST-WI_ID'. IF itab_list-wi_id IS INITIAL. MESSAGE i999(b1) WITH 'Please double click a line on the report!'. ELSE. t_wi_id = itab_list-wi_id. CALL FUNCTION 'SWL_WI_DISPLAY' EXPORTING wi_id = t_wi_id extended_display ='X' EXCEPTIONS read_failed = 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. ENDIF. WHEN 'ITAB_LIST-WI_RH_TASK'. IF itab_list-wi_rh_task IS INITIAL. MESSAGE i999(b1) WITH 'Please double click a line on the report!'. ELSE. CALL FUNCTION 'SWL_WI_DISPLAY_TASK' EXPORTING wi_id = itab_list-wi_id. CLEAR itab_list-wi_rh_task. ENDIF. WHEN OTHERS. MESSAGE i999(b1) WITH 'Field not selectable!'. ENDCASE. CLEAR: itab_list-wi_id, itab_list-wi_rh_task. *&---------------------------------------------------------------------* *& Form update_sel_screen update_sel_screen_attributes _attributes *&---------------------------------------------------------------------* FORM update_sel_screen_attributes. LOOP AT SCREEN. IF screen-group1 = 'SC1'. screen-intensified = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " update_sel_scr een_attributes
CHAPTER 5 ALV GRID CONTROL 5.1
TOP-OF-PAGE
Take a look at this alv-sample-code. It defines the event TOP-OF-PAGE in which you can print anything you want, including SO_...-low to SO_...-high, which you can insert at *()* REPORT ZALV_SAMPLE. * NO STANDARD PAGE HEADING * LINE-COUNT 58 * LINE-SIZE 220. TYPE-POOLS: SLIS. "for 'REUSE_ALV...list&grids' *----------------------------------------------------------------------* * TABLES * *----------------------------------------------------------------------* TABLES: KNA1. "General Data in Customer Master . *----------------------------------------------------------------------* * Internal data * *----------------------------------------------------------------------* DATA: BEGIN OF LT_ALVTABLE OCCURS 0, KUNNR LIKE KNA1-KUNNR, NAME1 LIKE KNA1-NAME1, NAME2 LIKE KNA1-NAME2, STRAS LIKE KNA1-STRAS, PSTLZ LIKE KNA1-PSTLZ, ORT01 LIKE KNA1-ORT01, UMSA1 LIKE KNA1-UMSA1, KTOKD LIKE KNA1-KTOKD, END OF LT_ALVTABLE. * data-statements that are DATA: GT_XEVENTS TYPE DATA: XS_EVENT TYPE DATA: REPID TYPE DATA: ZTA_PRINT TYPE DATA: LO_LAYOUT TYPE DATA: LO_ITABNAME TYPE DATA: LS_VARIANT TYPE
necessary for the use of the ALV-grid SLIS_T_EVENT. SLIS_ALV_EVENT. SY-REPID. SLIS_T_FIELDCAT_ALV WITH HEADER LINE. SLIS_LAYOUT_ALV. SLIS_TABNAME. DISVARIANT.
*----------------------------------------------------------------------* * Initialization * *----------------------------------------------------------------------* INITIALIZATION. *----------------------------------------------------------------------* * Parameters and select-options * *----------------------------------------------------------------------* SELECT-OPTIONS SO_KUNNR FOR KNA1-KUNNR DEFAULT '2000' TO '2300'. SELECT-OPTIONS SO_NAME FOR KNA1-NAME1. PARAMETERS: PA_PSTCD AS CHECKBOX DEFAULT 'X'. PARAMETERS: PA_VAR AS CHECKBOX DEFAULT 'X'. *----------------------------------------------------------------------* * Start of main program * *----------------------------------------------------------------------* START-OF-SELECTION. PERFORM SELECT_RECORDS. PERFORM PRINT_ALVLIST. END-OF-SELECTION. *&---------------------------------------------------------------------* *& Form select_records *&---------------------------------------------------------------------* FORM SELECT_RECORDS. SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF LT_ALVTABLE WHERE KUNNR IN SO_KUNNR AND NAME1 IN SO_NAME. APPEND LT_ALVTABLE. ENDSELECT. ENDFORM. " select_records *&--------------------------------------------------------------------* *& Form print_alvlist *&--------------------------------------------------------------------* FORM PRINT_ALVLIST. REPID = SY-REPID. LO_ITABNAME = 'LT_ALVTABLE'. * Fill the PERFORM PERFORM PERFORM PERFORM
"NB: ONLY USE CAPITALS HERE!
variables of the ALV-grid. SET_LAYOUT USING LO_LAYOUT. "Change layout-settings SET_EVENTS USING GT_XEVENTS."Set the events (top-page etc) FILL_STRUCTURE. "Read the structure of the itab MODIFY_STRUCTURE. "Modify itab's field-properties
* Sort the table SORT LT_ALVTABLE BY KUNNR. * Present the table using the ALV-grid. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = REPID IT_FIELDCAT = ZTA_PRINT[] IS_LAYOUT = LO_LAYOUT IT_EVENTS = GT_XEVENTS I_SAVE = 'A' IS_VARIANT = LS_VARIANT TABLES T_OUTTAB = LT_ALVTABLE. ENDFORM. " print_alvlist *&---------------------------------------------------------------------* *& Form SET_LAYOUT *&---------------------------------------------------------------------* FORM SET_LAYOUT USING PA_LAYOUT TYPE SLIS_LAYOUT_ALV. * Minimize the columnwidth PA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. * Give the table a striped pattern PA_LAYOUT-ZEBRA = 'X'. * Set the text of the line with totals PA_LAYOUT-TOTALS_TEXT = 'Total:'. * Set the text of the line with subtotals PA_LAYOUT-SUBTOTALS_TEXT = 'Subtotal:'. * Set the variant, as requested via the checkbox IF PA_VAR = 'X'. LS_VARIANT-VARIANT = '/ZLAYOUT'. ELSE. CLEAR LS_VARIANT-VARIANT. ENDIF. ENDFORM. " SET_LAYOUT *&-------------------------------------------------------------------*& Form Set_events *&-------------------------------------------------------------------* Appends the values of the events to the events-variable that is * used by REUSE_ALV_LIST_DISPLAY *&-------------------------------------------------------------------FORM SET_EVENTS USING PA_EVENTS TYPE SLIS_T_EVENT. XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST. XS_EVENT-FORM = 'XTOP_OF_LIST'.
APPEND XS_EVENT TO PA_EVENTS. XS_EVENT-NAME = SLIS_EV_END_OF_LIST. XS_EVENT-FORM = 'XEND_OF_LIST'. APPEND XS_EVENT TO PA_EVENTS. XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE. XS_EVENT-FORM = 'XTOP_OF_PAGE'. APPEND XS_EVENT TO PA_EVENTS. XS_EVENT-NAME = SLIS_EV_END_OF_PAGE. XS_EVENT-FORM = 'XEND_OF_PAGE'. APPEND XS_EVENT TO PA_EVENTS. ENDFORM. *&--------------------------------------------------------------------* *& Form XTOP_OF_LIST *&--------------------------------------------------------------------* FORM XTOP_OF_LIST. DATA LO_DATE(8). CONCATENATE SY-DATUM+6(2) '.' SY-DATUM+4(2) '.' SY-DATUM+2(2) INTO LO_DATE. WRITE: AT 1 'Report:'(T01), 20 'Reportname'(T02). WRITE: AT 50 'Date:'(T03), LO_DATE. NEW-LINE. WRITE: AT 1 'Abap-name report: '(T04), SY-REPID. WRITE: AT 50 'Page:'(T05), SY-CPAGE. ENDFORM. "xtop_of_list *&--------------------------------------------------------------------* *& Form XEND_OF_LIST *&--------------------------------------------------------------------* FORM XEND_OF_LIST. WRITE: 'Footer of the list'(002). ENDFORM. "xend_of_list *&---------------------------------------------------------------------* *& Form XTOP_OF_PAGE *&---------------------------------------------------------------------* FORM XTOP_OF_PAGE. WRITE:/ 'Top of the page.'(003). *()*Here your selection-criteria can be printed ENDFORM. "xtop-of-page *&---------------------------------------------------------------------* *& Form XEND_OF_PAGE *&---------------------------------------------------------------------* FORM XEND_OF_PAGE. WRITE:/ 'End of the page.'(004). ENDFORM. "xtop-of-page *&---------------------------------------------------------------------* *& Form FILL_STRUCTURE *&---------------------------------------------------------------------* FORM FILL_STRUCTURE. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = REPID I_INTERNAL_TABNAME = LO_ITABNAME I_INCLNAME = 'ZALV_SAMPLE' CHANGING CT_FIELDCAT = ZTA_PRINT[]. ENDFORM. " FILL_STRUCTURE *&--------------------------------------------------------------------* *& Form MODIFY_STRUCTURE *&--------------------------------------------------------------------* * Set the fieldproperties to your wishes *&--------------------------------------------------------------------* FORM MODIFY_STRUCTURE. LOOP AT ZTA_PRINT. CLEAR ZTA_PRINT-KEY. CASE ZTA_PRINT-FIELDNAME. WHEN 'KUNNR'. "Klantnummer ZTA_PRINT-COL_POS = 0. ZTA_PRINT-SELTEXT_S = 'Cstm'(H01). ZTA_PRINT-SELTEXT_M = 'Customer'(H01). ZTA_PRINT-SELTEXT_L = 'Customer is king'(H01). WHEN 'NAME1'. "Name1 ZTA_PRINT-COL_POS = 1. WHEN 'NAME2'. "Name 2 (now set to invisible) ZTA_PRINT-COL_POS = 2. ZTA_PRINT-NO_OUT = 'X'. WHEN 'STRAS'. "Month ZTA_PRINT-COL_POS = 3. WHEN 'PSTLZ'. "Postcode ZTA_PRINT-COL_POS = 4. IF PA_PSTCD = ''. ZTA_PRINT-NO_OUT = 'X'. ELSE. CLEAR ZTA_PRINT-NO_OUT. ENDIF. WHEN 'ORT01'. "Stad ZTA_PRINT-COL_POS = 5. WHEN 'UMSA1'. "Annual sales ZTA_PRINT-COL_POS = 6. WHEN 'KTOKD'. " ZTA_PRINT-COL_POS = 7. * when others. "set all other fields to invisible * zta_print-no_out = 'X'. ENDCASE. MODIFY ZTA_PRINT. ENDLOOP. ENDFORM. " modify_structure
CHAPTER 6 OBJECT PROGRAMMING 6.1
SAP DEMO REPORTS
Go to SE80 -> Environment –> Reuse Library
6.2
TREE REPORTS
CLA SS DEFINITION CLASS lcl_application DEFINITION. PUBLIC SECTION. METHODS: handle_node_double_click FOR EVENT node_double_click OF cl_gui_list_tree IMPORTING node_key, handle_expand_no_children FOR EVENT expand_no_children OF cl_gui_list_tree IMPORTING node_key, handle_item_double_click FOR EVENT item_double_click OF cl_gui_list_tree IMPORTING node_key item_name, handle_button_click FOR EVENT button_click OF cl_gui_list_tree IMPORTING node_key item_name, handle_link_click FOR EVENT link_click OF cl_gui_list_tree IMPORTING node_key item_name, handle_checkbox_change FOR EVENT checkbox_change OF cl_gui_list_tree IMPORTING node_key item_name checked. ENDCLASS.
CLASS IMPLEMENTATION CLASS lcl_application IMPLEMENTATION. METHOD handle_node_double_click. " this method handles the node double click event of the tree " control instance " show the key of the double clicked node in a dynpro field READ TABLE itab_data WITH KEY node_key = node_key INTO wa_data. * You now have the data to do anything you wish * …. ENDMETHOD. METHOD handle_item_double_click. " this method handles the item double click event of the tree " control instance. You have variables node_key and item_name " show the key of the node and the name of the item " of the double clicked item in a dynpro field READ TABLE itab_data WITH KEY node_key = node_key INTO wa_data. * You now have the data to do anything you wish * …. ENDMETHOD. METHOD handle_link_click. " this method handles the link click event of the tree " control instance
" show the key of the node and the name of the item " of the clicked link in a dynpro field g_node_key = node_key. g_item_name = item_name. ENDMETHOD. METHOD handle_button_click. " this method handles the button click event of the tree " control instance " show the key of the node and the name of the item " of the clicked button in a dynpro field g_node_key = node_key. g_item_name = item_name. ENDMETHOD. METHOD handle_checkbox_change. " this method handles the checkbox_change event of the tree " control instance " show the key of the node and the name of the item " of the clicked checkbox in a dynpro field g_node_key = node_key. g_item_name = item_name. ENDMETHOD.
METHOD handle_expand_no_children. DATA: node_table TYPE treev_ntab, node TYPE treev_node, item_table TYPE item_table_type, item TYPE mtreeitm. * show the key of the expanded node in a dynpro field g_node_key = node_key. IF node_key = 'Child2'. * add the children for node with key 'Child2' * Node with key 'New3' CLEAR node. node-node_key = 'New3'. node-relatkey = 'Child2'. node-relatship = cl_gui_list_tree=>relat_last_child. APPEND node TO node_table. * Node with key 'New4' CLEAR node. node-node_key = 'New4'. node-relatkey = 'Child2'. node-relatship = cl_gui_list_tree=>relat_last_child. APPEND node TO node_table. * Items of node with key 'New3' CLEAR item. item-node_key = 'New3'. item-item_name = '1'. item-class = cl_gui_list_tree=>item_class_text. item-length = 11. item-usebgcolor = 'X'. " item-text = 'SAPTROX1'. APPEND item TO item_table. CLEAR item. item-node_key = 'New3'. item-item_name = '2'. item-class = cl_gui_list_tree=>item_class_text. item-alignment = cl_gui_list_tree=>align_auto.
"#EC NOTEXT
"#EC NOTEXT
"#EC NOTEXT
item-font = cl_gui_list_tree=>item_font_prop. item-text = 'Comment to SAPTROX1'. APPEND item TO item_table.
DATA DEFINITIONS * Type definitions types: begin of itab_type, folder type flag, node_key type mtreeitm, relatkey type tv_nodekey, type like qmel-QMART, qmnum like qmel-qmnum, qwrnum like qmel-qwrnum, end of itab_type. * Data Definitions data: okcode like sy-ucomm, itab_data type itab_type occurs 0, wa_data type itab_type. * Tree list definitions class lcl_application definition deferred. class cl_gui_cfw definition load. * CAUTION: MTREEITM is the name of the item structure which must * be defined by the programmer. DO NOT USE MTREEITM! types: item_table_type like standard table of mtreeitm with default key.
* Start of Selection *----------------------------------------------------------------------* START-OF-SELECTION. REFRESH: itab_data. PERFORM create_input_table TABLES itab_data. * create the application object * this object is needed to handle the ABAP Objects Events of Controls CREATE OBJECT g_application. CALL SCREEN 2000. "Tree Report END-OF-SELECTION.
SUBROUTINES *&---------------------------------------------------------------------* *& Form update_sel_screen_attributes *&---------------------------------------------------------------------* FORM update_sel_screen_attributes. LOOP AT SCREEN. IF screen-group1 = 'SC1'. screen-intensified = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDFORM. " update_sel_screen_attributes *&---------------------------------------------------------------------* *& Form create_and_init_tree *&---------------------------------------------------------------------* FORM create_and_init_tree. DATA: node_table TYPE treev_ntab, item_table TYPE item_table_type, events TYPE cntl_simple_events, event TYPE cntl_simple_event. * create a container for the tree control CREATE OBJECT g_custom_container EXPORTING " the container is linked to the custom control with the " name 'TREE_CONTAINER' on the dynpro container_name = 'TREE_CONTAINER' EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5. IF sy-subrc <> 0. MESSAGE a000(tree_control_msg). ENDIF.
* create a list tree control CREATE OBJECT g_tree EXPORTING parent = g_custom_container node_selection_mode = cl_gui_list_tree=>node_sel_mode_single item_selection = 'X' with_headers = ' ' EXCEPTIONS cntl_system_error = 1 create_error = 2 failed = 3 illegal_node_selection_mode = 4 lifetime_error = 5. IF sy-subrc <> 0.
MESSAGE a000(tree_control_msg). ENDIF. * define the events which will be passed to the backend " node double click event-eventid = cl_gui_list_tree=>eventid_node_double_click. event-appl_event = 'X'. " APPEND event TO events. " item double click event-eventid = cl_gui_list_tree=>eventid_item_double_click. event-appl_event = 'X'. APPEND event TO events. " expand no children event-eventid = cl_gui_list_tree=>eventid_expand_no_children. event-appl_event = 'X'. APPEND event TO events. " link click event-eventid = cl_gui_list_tree=>eventid_link_click. event-appl_event = 'X'. APPEND event TO events. " button click event-eventid = cl_gui_list_tree=>eventid_button_click. event-appl_event = 'X'. APPEND event TO events. " checkbox change event-eventid = cl_gui_list_tree=>eventid_checkbox_change. event-appl_event = 'X'. APPEND event TO events. CALL METHOD g_tree->set_registered_events EXPORTING events = events EXCEPTIONS cntl_error = 1 cntl_system_error = 2 illegal_event_combination = 3. IF sy-subrc <> 0. MESSAGE a000(tree_control_msg). ENDIF. * assign event handlers in the application class to each desired event SET HANDLER g_application->handle_node_double_click FOR g_tree. SET HANDLER g_application->handle_item_double_click FOR g_tree. SET HANDLER g_application->handle_expand_no_children FOR g_tree. SET HANDLER g_application->handle_link_click FOR g_tree. SET HANDLER g_application->handle_button_click FOR g_tree. SET HANDLER g_application->handle_checkbox_change FOR g_tree. * * * *
add some nodes to the tree control NOTE: the tree control does not store data at the backend. If an application wants to access tree data later, it must store the tree data itself. PERFORM build_node_and_item_table USING node_table item_table. CALL METHOD g_tree->add_nodes_and_items EXPORTING node_table = node_table item_table = item_table item_table_structure_name = 'MTREEITM' EXCEPTIONS failed = 1 cntl_system_error = 3
error_in_tables = 4 dp_error = 5 table_structure_name_not_found = 6. IF sy-subrc <> 0. MESSAGE a000(tree_control_msg). ENDIF. ENDFORM. " create_and_init_tree *&---------------------------------------------------------------------* *& Form build_node_and_item_table *&---------------------------------------------------------------------* FORM build_node_and_item_table USING node_table TYPE treev_ntab item_table TYPE item_table_type. DATA: node TYPE treev_node, item TYPE mtreeitm. * Build the node and item table. LOOP AT itab_data INTO wa_data. CLEAR node. node-node_key = wa_data-node_key. node-relatkey = wa_data-relatkey. node-isfolder = 'X'. IF wa_data-relatkey IS INITIAL. CLEAR: node-relatship, node-exp_image, node-expander. node-hidden = ' '. node-disabled = ' '. ELSE. node-relatship = cl_gui_list_tree=>relat_last_child. ENDIF. APPEND node TO node_table. * Update Items CLEAR item. item-node_key = wa_data-node_key. item-item_name = '1'. item-length = 4. item-class = cl_gui_list_tree=>item_class_text. " Text Item item-alignment = cl_gui_list_tree=>align_auto. item-font = cl_gui_list_tree=>item_font_prop. item-usebgcolor = 'X'. item-text = wa_data-type. APPEND item TO item_table. CLEAR item. item-node_key = wa_data-node_key. item-item_name = '2'. item-length = 20. item-class = cl_gui_list_tree=>item_class_text. " Text Item item-alignment = cl_gui_list_tree=>align_auto. item-font = cl_gui_list_tree=>item_font_prop. item-text = wa_data-qmnum. APPEND item TO item_table. ENDLOOP. ENDFORM. " build_node_and_item_table *&---------------------------------------------------------------------* *& Form create_input_table *&---------------------------------------------------------------------* FORM create_input_table TABLES p_itab_data LIKE itab_data. DATA: t_counter(4) TYPE n, t_parent(4) TYPE c,
t_parent1(4) TYPE c, t_qmnum LIKE qmel-qmnum, t_qmnum1 LIKE qmel-qmnum. t_counter = 1. CLEAR: t_parent, t_parent1. IF NOT s_ecr IS INITIAL. SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qmnum IN s_ecr AND qmart = 'C3'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. t_parent = t_counter. ADD 1 TO t_counter. * Check for ECNs attached to this ECR SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qwrnum = qmel-qmnum AND qmart = 'C4'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. t_parent1 = t_counter. ADD 1 TO t_counter. * Check for ECOs attached to this ECN SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qwrnum = qmel-qmnum AND qmart = 'C5'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent1. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. ADD 1 TO t_counter. ENDSELECT. CLEAR: t_parent1. ENDSELECT. CLEAR: t_parent. ENDSELECT. CLEAR: t_parent, t_parent1.
ENDIF. IF NOT s_ecn IS INITIAL. SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qmnum IN s_ecn AND qmart = 'C4'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent1. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. t_parent1 = t_counter. ADD 1 TO t_counter. t_qmnum = qmel-qmnum. * Is an ECR attached? IF NOT qmel-qwrnum IS INITIAL. SELECT SINGLE qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qmnum = qmel-qwrnum. IF sy-subrc = 0. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent1. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. ADD 1 TO t_counter. ENDIF. ENDIF. qmel-qmnum = t_qmnum. * Check for ECOs attached to this ECN SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qwrnum = qmel-qmnum AND qmart = 'C5'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent1. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. ADD 1 TO t_counter. ENDSELECT. CLEAR: t_parent1. ENDSELECT. CLEAR: t_parent, t_parent1. ENDIF. IF NOT s_eco IS INITIAL. SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum)
FROM qmel WHERE qmnum IN s_eco AND qmart = 'C5'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. t_parent = t_counter. ADD 1 TO t_counter. t_qmnum = qmel-qmnum. IF NOT qmel-qwrnum IS INITIAL. * Check for ECNs attached to this ECO SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qmnum = qmel-qwrnum AND qmart = 'C4'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. t_parent1 = t_counter. ADD 1 TO t_counter. t_qmnum1 = qmel-qmnum. IF NOT qmel-qwrnum IS INITIAL. * Check for ECRs attached to this ECN SELECT qmnum qmart qwrnum INTO (qmel-qmnum, qmel-qmart, qmel-qwrnum) FROM qmel WHERE qmnum = qmel-qwrnum AND qmart = 'C3'. CLEAR: wa_data. wa_data-folder = 'X'. wa_data-node_key = t_counter. wa_data-relatkey = t_parent1. wa_data-type = qmel-qmart. wa_data-qmnum = qmel-qmnum. wa_data-qwrnum = qmel-qwrnum. APPEND wa_data TO p_itab_data. ADD 1 TO t_counter. ENDSELECT. qmel-qmnum = t_qmnum1. CLEAR: t_parent1. ENDIF. ENDSELECT. qmel-qmnum = t_qmnum. CLEAR: t_parent1. ENDIF. ENDSELECT. CLEAR: t_parent, t_parent1. ENDIF.
ENDFORM.
" create_input_table
PBO Screen 2000 *&---------------------------------------------------------------------* *& Module STATUS_2000 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module STATUS_2000 output. SET PF-STATUS 'ZCM_2000'. SET TITLEBAR 'ZCM_2000'. endmodule. " STATUS_2000 OUTPUT *&---------------------------------------------------------------------* *& Module init_data_2000 OUTPUT *&---------------------------------------------------------------------* module init_data_2000 output. if g_tree is initial. " The Tree Control has not been created yet. " Create a Tree Control and insert nodes into it. perform create_and_init_tree. endif. endmodule.
" init_data_2000
OUTPUT
PAI Screen 2000 *&---------------------------------------------------------------------* *& Module USER_COMMAND_2000 INPUT *&---------------------------------------------------------------------* module user_command_2000 input. data: return_code type i. * CL_GUI_CFW=>DISPATCH must be called if events are registered * that trigger PAI * this method calls the event handler method of an event call method cl_gui_cfw=>dispatch importing return_code = return_code. if return_code <> cl_gui_cfw=>rc_noevent. " a control event occured => exit PAI clear okcode. exit. endif. case okcode. when 'RETURN'. " Finish program if not g_custom_container is initial. " destroy tree container (detroys contained tree control, too) call method g_custom_container->free exceptions cntl_system_error = 1 cntl_error = 2. if sy-subrc <> 0. message a000(TREE_CONTROL_MSG). endif. clear g_custom_container. clear g_tree. endif. leave to screen 0. endcase. clear okcode. endmodule.
SCREEN 2000
" USER_COMMAND_2000
INPUT
6.3
AL V GRID CONTROL
See Development Class SLIS for example programs including drag and drop functionality.
6.3.1 Adding custom butt ons on ALV grid controls DATA * Predefine a local class for event handling to allow the * declaration of a reference variable before the class is defined. CLASS lcl_event_receiver DEFINITION DEFERRED. DATA:
DATA:
custom_container1 TYPE REF TO cl_gui_custom_container, cont_on_main TYPE scrfname VALUE 'ALV_GRID', grid1 TYPE REF TO cl_gui_alv_grid, event_receiver TYPE REF TO lcl_event_receiver, okcode LIKE sy-ucomm. gt_fieldcat gt_fieldcat1 gs_layout gs_layout1 gs_layout2 gs_print gt_sort gt_sp_group gt_events gt_list_top_of_page
DATA:t_out TYPE TABLE OF zstruct, t_out_wa LIKE zstruct. **************************************************************** * LOCAL CLASSES: Definition **************************************************************** *=============================================================== * class lcl_event_receiver: local class to * define and handle own functions. * * Definition: * ~~~~~~~~~~~ CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION. METHODS: 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. PRIVATE SECTION. ENDCLASS. **************************************************************** * LOCAL CLASSES: Implementation **************************************************************** *=============================================================== * class lcl_event_receiver (Implementation) * * CLASS lcl_event_receiver IMPLEMENTATION. METHOD handle_toolbar. * § 2.In event handler method for event TOOLBAR: Append own functions * by using event parameter E_OBJECT. DATA: ls_toolbar TYPE stb_button. *.................................................................... * E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET. * This class has got one attribute, namly MT_TOOLBAR, which * is a table of type TTB_BUTTON. One line of this table is * defined by the Structure STB_BUTTON (see data deklaration above). * * A remark to the flag E_INTERACTIVE: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 'e_interactive' is set, if this event is raised due to * the call of 'set_toolbar_interactive' by the user. * You can distinguish this way if the event was raised * by yourself or by ALV * (e.g. in method 'refresh_table_display'). * An application of this feature is still unknown... :-) * append a separator to normal toolbar CLEAR ls_toolbar. MOVE 3 TO ls_toolbar-butn_type. APPEND ls_toolbar TO e_object->mt_toolbar. * append an icon to show booking table CLEAR ls_toolbar. MOVE 'COMMENT' TO ls_toolbar-function. MOVE icon_annotation TO ls_toolbar-icon.
MOVE 'Insert Comment'(001) TO ls_toolbar-quickinfo. MOVE 'Notes'(004) TO ls_toolbar-text. MOVE ' ' TO ls_toolbar-disabled. APPEND ls_toolbar TO e_object->mt_toolbar. MOVE 'MATNR' TO ls_toolbar-function. MOVE icon_material TO ls_toolbar-icon. MOVE 'View Material'(002) TO ls_toolbar-quickinfo. MOVE 'Material'(003) TO ls_toolbar-text. MOVE ' ' TO ls_toolbar-disabled. APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. *------------------------------------------------------------------METHOD handle_user_command. * § 3.In event handler method for event USER_COMMAND: Query your * function codes defined in step 2 and react accordingly. DATA: lt_rows TYPE lvc_t_row. CASE e_ucomm. WHEN 'COMMENT'. CALL METHOD grid1->get_selected_rows IMPORTING et_index_rows = lt_rows. CALL METHOD cl_gui_cfw=>flush. IF sy-subrc NE 0. * add your handling, for example CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = g_repid txt2 = sy-subrc txt1 = 'Error in Flush'(500). ELSE. PERFORM get_comment TABLES lt_rows. “Perform action ENDIF. WHEN 'MATNR'. CALL METHOD grid1->get_selected_rows IMPORTING et_index_rows = lt_rows. CALL METHOD cl_gui_cfw=>flush. IF sy-subrc NE 0. * add your handling, for example CALL FUNCTION 'POPUP_TO_INFORM' EXPORTING titel = g_repid txt2 = sy-subrc txt1 = 'Error in Flush'(500). ELSE. READ TABLE lt_rows INDEX 1. IF sy-subrc = 0. READ TABLE t_out INTO t_out_wa INDEX lt_rows-index. IF sy-subrc = 0. SET PARAMETER ID 'MAT' FIELD t_out_wa-matnr. CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. "View Material ELSE. MESSAGE i999(b1) WITH 'Entry not found!'. ENDIF. ELSE. MESSAGE i999(b1) WITH 'Please select a line first!'. ENDIF. ENDIF. ENDCASE. ENDMETHOD.
before output. STATUS_2000. init_data. create_container.
*&---------------------------------------------------------------------* *& Module create_container OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module create_container output. if custom_container1 is initial. * create a custom container control for our ALV Control create object custom_container1 exporting container_name = cont_on_main exceptions cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5. if sy-subrc ne 0. * add your handling, for example call function 'POPUP_TO_INFORM' exporting titel = g_repid txt2 = sy-subrc txt1 = 'The control could not be created'(001). endif. * create an instance of alv control create object grid1 exporting i_parent = custom_container1. * allow to select single lines - Multilines = A gs_layout1-sel_mode = 'B'. t_out[] = t_out_mat[]. gt_fieldcat1[] = gt_fieldcat[]. gs_layout2-report = sy-repid. * * * * * * * *
IS_VARIANT, I_SAVE and I_DEFAULT are used for maintaining variants for the users. The setting 'U' allows a user to create their own variant and save it. The setting 'X' enables the ZBOM report to fire up the report with the default setting for that user. IS_VARIANT just needs to contain the report name. ZSTRUCT needs to be a structure or table in the data dictionary. The data elements are used for the column headings of your table control. T_OUT is your table for data. call method grid1->set_table_for_first_display exporting i_structure_name = 'ZSTRUCT' is_variant = gs_layout2 i_save = 'U' "User may save variant i_default = 'X' "Load variant automatically is_layout = gs_layout1 changing it_outtab = t_out.
* ->Create Object to receive events and link them to handler methods. * When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called. * create object event_receiver. set handler event_receiver->handle_user_command for grid1. set handler event_receiver->handle_toolbar for grid1. * § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR. call method grid1->set_toolbar_interactive. endif. call method cl_gui_control=>set_focus exporting control = grid1. endmodule.
" create_container
OUTPUT
6.3.2 Highlight lines * Highlight lines declarations types: begin of highlight_line, from type i, to type i, end of highlight_line. data: itab_highlight type table of highlight_line, wa_highlight type highlight_line. data: t_true type i value 1. * Highlight the name line loop at itab_highlight into wa_highlight. call method editor2->highlight_lines exporting from_line = wa_highlight-from highlight_mode = t_true to_line = wa_highlight-to exceptions has_no_effect = 1 error_cntl_call_method = 2 invalid_parameter = 3 others = 4 . if sy-subrc <> 0. message i003 with 'EDITOR2' 'highlight_lines' sy-subrc. endif. endloop.
6.3.3 First line visible * Sets the top line of the table as the first visible line * otherwise only the last line is displayed and you need to * scroll up to see the other comments. call method editor2->set_first_visible_line exporting line = 1 exceptions error_cntl_call_method = 1 others = 2. if sy-subrc <> 0. message i003 with 'EDITOR2' 'set_first_visible_line' sy-subrc. endif.
6.3.4 Read only t ext box * Set the history area as read only call method editor2->set_readonly_mode exporting readonly_mode = t_true exceptions error_cntl_call_method = 1 others = 2. if sy-subrc <> 0. message i003 with 'EDITOR2' 'set_readonly_mode' sy-subrc. endif.
6.3.5 Entering text PBO if editor1 is initial * create control container create object textedit_custom_container1 exporting container_name = 'TEXTEDITOR1' exceptions cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5. if sy-subrc ne 0. * add your handling endif.
* *
create calls constructor, which initializes, creats and links a TextEdit Control create object editor1 exporting parent = textedit_custom_container1 wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position wordwrap_position = line_length wordwrap_to_linebreak_mode = cl_gui_textedit=>true exceptions others = 1.
endif.
“End of EDITOR1 is initial
SELECT * FROM znotes INTO CORRESPONDING FIELDS OF wa_mytable where qmnum = zpcr-qmnum. append wa_mytable to mytable1. ENDSELECT. CALL METHOD editor1->set_selected_text_as_r3table EXPORTING table = mytable1 EXCEPTIONS error_dp = 1 error_dp_create = 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.
PAI on SAVE refresh: mytable1. CALL METHOD editor1->get_text_as_r3table IMPORTING table = mytable1 EXCEPTIONS OTHERS = 1.
DATA constants: line_length type i value 52. *** Variables data: editor1 type ref to cl_gui_textedit, * reference to custom container: necessary to bind TextEdit Control textedit_custom_container1 type ref to cl_gui_custom_container. * define table type for data exchange types: begin of mytable_line, line(line_length) type c,
end of mytable_line. * table to exchange text types: mytable type standard table of mytable_line initial size 0. data: mytable1 type mytable, wa_mytable type mytable_line. Screen
Box with custom control texteditor1 in it.
CHAPTER 7 IDOC PROGRAMMING 7.1
CREATING AN IDOC
* Cr Cr ea eatt i ng r eco ecorr ds cl ear ear e1ed e1edp2 p20. 0. i docd ocdata- seg segnam= ' E1EDP20' . e1ed e1edp p2020- edatu edatu = i e020 e020-- sched sched_de _dell i v_date. v_date. e1ed e1edp2 p200- wmeng eng = i e020 e020-- sched_qt sched_qt y. i docdataocdata- sdat sdat a = e1ed e1edp2 p20 0. i docdataocdata- t abn abnam= i docd docdataata- segna segnam m. seg seg_nu _num = seg seg_num _num + 1. i docda docdatt a- segnu segnum m = seg_nu seg_num m. shi shi f t i docda cdat a- seg segnum l ef t del et i ng l eadi ng spa space. ce. appe append nd i docda docdatt a. cl ear i docda cdat a. * On Once I Doc detai l i s created
CALL CALL F UNCTI ON ' I NBOUND_ I DOC_PRO C_P ROCESS' TAB TABLES I DOC_ CONTROL = i edi dc I DOC_ DATA = i docdat a. commi t wor k.
7.2
SENDING AN IDOC
CALL CALL FUN FUNCTI CTI ON ' MASTER ASTER__ I DOC_DI C_DI STRI STRI BUTE' BUTE' EXPORTI EXPORTI NG mast ast er_i doc_co oc_con nt r ol obj obj _t ype ype TABLES TABLES communi uni cati on_i on_i doc_con doc_contt r ol master _i doc_data oc_data EXCEPTI EXCEPTI ONS er r or _ i n_ i doc _ co cont r ol er ror_wr ror_wr i t i ng_i doc_status er ror_i n_i doc_da c_dat a sendi sendi ng_l ng_l ogi ogi cal _syst em_unkn _unknow own OTHER THERS S
= s_zor s_zor dr sp_ed sp_edii dc = ' BUS2032 2032'' = i t ab_zor ab_zor dr sp_ed sp_edii dc = i t ab_zor ab_zor dr sp_ed sp_edii dd =1 =2 =3 =4 = 5.
I F sysy- sub subrc <> 0. r eturn_cod eturn_code = 2. WRI TE: TE: / 1 ' ZORDRSP I Doc not not c r eated' . MESSAGE I D sy - ms gi d TYPE s y- msgt y NUMBER sy - ms gno WI TH sy- msgv1 s y- msgv2 s y- msgv3 s y- msgv4. ELSE. ELSE. WRI TE: / 1 ' I Doc: ' , i t ab_zordrsp_ed _zordrsp_edii dc- docnu cnum, ' creat creat ed' . HI DE i t ab_zor ab_zor drsp_edi dc- docnu docnum m. ENDI F.
7.3
CHANGING AN IDOC
CALL CALL FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ OPEN_ PEN_ FOR_ED FOR_EDII T' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dc- docnum I MPORTI PORTI NG I DOC_ CONTRO TROL = I EDI EDI DC TABLES TABLES I DOC_DA _DATA = i docdat docdat a EXCEPTI EXCEPTI ONS DOCUM CUMENT_FOR ENT_ FOREI EI GN_ LOCK = 01 DOCUM CUMENT_ ENT_ NOT_ EXI ST = 02 DOCUM CUMENT_ ENT_ NUMBER_ BER_ I NVALI D = 03 ERROR_M R_ MESSAGE = 04 OTHER THERS S = 05. CALL CALL FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ STATUS_ STATUS_ SET' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dcdc - DOCNUM I DOC_STATU _STATUS S = edi edi _ds
I MPORTI PORTI NG I DOC_ CONTRO TROL EXCEPTI EXCEPTI ONS DOCUM CUMENT_ ENT_ NUMBER_ BER_ I NVALI D OTHER THER_FI _FI ELDS_I ELDS_I NVALI VALI D STATU STATUS_I S_I NVALI D OTHERS THERS .
= i edi dc =1 =2 =3 =4
CALL CALL F UNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ CLOSE_ CLOSE_ED EDII T' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dcdc - DOCNU CNUM.
7.4
CHANGING AN IDOC IDOC’S ’S STATUS
CALL CALL FUNCTI FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ OPEN_FO PEN_F OR_PRO R_P ROCESS' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dc- docnum I MPORTI PORTI NG I DOC_ CONTRO TROL = I EDI EDI DC EXCEPTI EXCEPTI ONS DOCUM CUMENT_FOR ENT_ FOREI EI GN_ LOCK = 01 DOCUM CUMENT_ ENT_ NOT_ EXI ST = 02 DOCUM CUMENT_ ENT_ NUMBER_ BER_ I NVALI D = 03 ERROR_M R_ MESSAGE = 04 OTHER THERS S = 05. CALL CALL FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ STATUS_ STATUS_ SET' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dcdc - DOCNUM I DOC_STATU _STATUS S = edi edi _ds I MPORTI PORTI NG I DOC_ CONTRO TROL = i edi dc EXCEPTI EXCEPTI ONS DOCUM CUMENT_ ENT_ NUMBER_ BER_ I NVALI D =1 OTHER THER_FI _FI ELDS_I ELDS_I NVALI VALI D =2 STATU STATUS_I S_I NVALI D =3 OTHERS THERS =4 . CALL CALL FUNCTI FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ CLOSE_ CLOSE_ PROCESS' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dcdc - DOCNU CNUM.
7.5
READING AN IDOC
CALL CALL FUNCTI ON ' I DOC_READ C_READ_ COMPLETELY' PLETEL Y' EXPORTI EXPORTI NG document _ number = p_docnum I MPORTI PORTI NG i doc_con c_cont r ol = s_ordch s_ordchg g_edi _edi dc TABLES TABLES i nt _edi _edi dd = i t ab_ordc ab_ordch hg_edi _edi dd EXCEPTI EXCEPTI ONS docum document ent _not_ exi exi st = 1 docum document ent _number ber _i nval nval i d = 2 OTHER THERS S = 3.
7.5. 7.5.1 1 Exampl e – Open document docu ment f or r ead ead
CALL CALL FUNCTI FUNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ OPEN_FO PEN_F OR_READ' R_READ' EXPORTI EXPORTI NG DOCUM CUMENT_ ENT_ NUMBER = i edi dc- docnum I MPORTI PORTI NG I DOC_ CONTRO TROL = I EDI EDI DC EXCEPTI EXCEPTI ONS DOCUM CUMENT_FOR ENT_ FOREI EI GN_ LOCK = 01 DOCUM CUMENT_ ENT_ NOT_ EXI ST = 02 DOCUM CUMENT_ ENT_ NUMBER_ BER_ I NVALI D = 03 ERROR_M R_ MESSAGE = 04 OTHER THERS S = 05. cal l f unct unct i on ' EDI _SEG _SEGMENTS_G TS_GET ET_ALL' _ALL' expo exporr t i ng docum document ent _number ber = i edi edi dc- docnu docnum m t abl es i doc_con c_cont ai ners = dat a_rec
excep except i ons ons docum document ent _number ber _i nval nval i d = 1 end_of end_of _document ent =2 ot her s = 3. i f not s yy- s ub ubr c i s i ni t i al . CALL CALL FU F UNCTI ON ' EDI EDI _ DOCUM CUMENT_ ENT_ CLOSE_ CLOSE_ READ READ' EXPORTI EXPORTI NG DOCUMENT_ ENT_ NUMBER = i edi dc- docnum I MPORTI PORTI NG I DOC_ CONTRO TROL = i edi dc
7.6
DISPLA DISP LA YING AN IDOC
CALL CALL FUN FUNCTI CTI ON ' EDI EDI _ DOCUMENT_ ENT_ DATA_ ATA_ DI SPLAY' " Di spl ay I doc EXPORTI EXPORTI NG docnu cnum = t _i doc t r ee_ di di s pl pl ay = ' Y' EXCEPTI EXCEPTI ONS no_data_r o_data_r ecor ecor d_f oun ound = 1 OTHER THERS S = 2.
7.7
IDOC TYPE POOL
TYPE-POOLS: * general idoc type pool TIDOC.
7.8
LA UNCH UNCHING ING AN ERROR WORKFLOW
* i ncl ude ude f or workf l ow programmi ng I NCLUDE CLUDE TN01>. PER PERFOR FORM anal anal yzi ng_eve ng_event_ nt_ cr eat eat e TABLES TABLES t _coupl _coupl e_t o_pr o_pr ocess ocess USI NG l _commi t _count _count er i nbsyn sync. i f s y- s ub ubr c i s i ni t i al . MESSESS- MSGI D = ' ZS7' S7' . MESSESS- MSGTY = ' E' . MESS- MSGN SGNO = i _ msgno. MESS- MSGV1 SGV1 = i _ msgv1. MESS- MSGV2 SGV2 = i _ msgv2. CALL CALL FUNCTI FUNCTI ON ' I DOC_ERROR_WORKFLOW RKFLOW_ START' EXPORTI EXPORTI NG DOCNUM =0 EVEN EVENTC TCO ODE = ' EDI EDI M' MESS = mess STATUSM STATUSMESS = mess es s EXCEPTI EXCEPTI ONS NO_ ENTR ENTRY_ Y_ I N_ TEDE5 TEDE5 =1 ERRO ERROR_I N_ START_ START_ WORKFLOW RKFLOW =2 OTHER THERS S = 3. COM COMMI T WORK. endi f . " l i nk c r ea eat e d FOR FORM anal anal yzi ng_eve ng_event_ nt_ cr eat eat e TABLES TABLES t _c oupl oupl e_t o_pr ocess_i n STR STRUCTUR TURE edi edi i nbou nbound nd USI NG commi t _count _count er_ i n LI KE edi edi gl odat odat a- comcount count st art _r ecf b_synch _synchrr on_i n LI KE edi gl odata- i nbsync. sync. * l oc al al var i abl es DATA: ATA: * i nst ance t hat i s creat creat ed l _obj _obj ect TYP TYPE swc_ob c_obj ect , * obj ect key, key, e. g I Doc num number ber l _obj _obj ect _key _key LI KE swot obj i d- obj key, key, * i d of wf even eventt l _even _eventt _i d LI KE swed swedu umevi evi d-evti d, * st at us recor recor d f or case case of er r or l _st atus_recor atus_recor d TYP TYPE t i doc_st oc_st at us_r eco ecor d_ext _ext , * f l ag i ndi cat cat i ng whet her sub subscri bed task i s st ar t ed syn synchr chr onousl y
l _st art _r ecf b_synchr on LI KE swef l ags- syncf l ag VALUE ' ' , * i doc number ( needed because of t ype checki ng) l _i doc_number LI KE edi dc- docnum. * l ocal const ant s CONSTANTS: * obj ect t ype ' I DOC' c_obj ect _t ype LI KE swet ypecou- obj t ype VALUE ' I DOCI NVOI C' , * name of event t o be cr eated c_ i dc_ evt LI KE swet ypecou- event VALUE ' I NPUTERROROCCURREDMM' . i f t _ c oupl e_ t o_ pr oc es s_ i n[ ] i s i ni t i al . COMMI T WORK. CALL FUNCTI ON ' DEQUEUE_ALL' . CLEAR commi t _c ount er _i n. exi t . endi f . * cast l _start _r ecf b_synchr on = start _r ecf b_synchron_i n. * decl ar ati on of cont ai ner swc_cont ai ner l _t _ev_cont ai ner . * i ni t i al i z e c ont a i ner swc_cl ear _cont ai ner l _t _ev_cont ai ner . * dequeue al l i docs at t he same t i me LOOP AT t _coupl e_t o_process_i n. * cast l _i doc_number = t _coupl e_to_pr ocess_i n( 16) . CALL FUNCTI ON ' EDI _DOCUMENT_ DEQUEUE_ LATER' EXPORTI NG docnum = l _i doc_number EXCEPTI ONS OTHERS = 0. ENDLOOP. * get f i r st i doc number i n t abl e i n or der t o cr eat e an obj ect READ TABLE t _coupl e_t o_pr ocess_ i n I NDEX 1. * set obj ect key i n var i abl e of cor r ect t ype ( cast i ng) l _obj ect_key = t _coupl e_t o_pr ocess_i n( 16) . * cr eate an obj ect , i . e. an I Doc swc_creat e_obj ect l _obj ect c_obj ect _t ype l _obj ect _key. * f i l l c ont a i ner : wor k i t e m obj ec t i d ( i doc ) swc_set _el ement l _t _ev_cont ai ner "EC * c_el ement _wi _obj _i d "EC * l _obj ect. "EC * * f i l l cont ai ner : Number Pl usEvent code ( t abl e of coupl es) swc_set _t abl e l _t _ev_cont ai ner c_el ement _no_pl us_i nfo t _coupl e_t o_process_i n. * f i r e event t hat wi l l t r i gger t he i doc i nbound pr ocessi ng CALL FUNCTI ON ' SWE_EVENT_CREATE' EXPORTI NG obj t ype = c_obj ect _t ype obj key = l _obj ect_key event = c_i dc_evt * CREATOR =' ' * START_WI TH_DELAY =' ' st ar t _r ecf b_synchr on = l _st ar t _r ecf b_synchr on I MPORTI NG event _i d = l _event _i d TABLES event _cont ai ner = l _t _ev_cont ai ner EXCEPTI ONS obj t ype_not_ f ound =1 OTHERS = 2. IF ( sy- subrc <> 0 ) * event was not cr eat ed => err or handl i ng for t hi s i doc (EDI M) OR ( l _event _i d = 0 ) . * st op processi ng, no commi t MESSAGE I D ' E0' TYPE ' A' NUMBER ' 374'
WI TH
l _st at us_r ecor d- docnum c_i dc_evt RAI SI NG event _cr eat e_f ai l ed.
ELSE. * do commi t and r eset count er * t he commi t wi l l get t he i docs t o t he dat abase and at t he same t i me * act i vat e t he event t hat was created COMMI T WORK. * dequeue al l unprocessed I Docs to avoi d l og- overf l ow CALL FUNCTI ON ' DEQUEUE_ALL' . CLEAR commi t _c ount er _i n. * r eset t abl e of i docs that need t o be pr ocessed CLEAR t_ coupl e_t o_pr ocess_i n. REFRESH t _coupl e_t o_process_i n. ENDI F. ENDFORM.
7.9
" ANALYZI NG_EVENT_ CREATE
RETURNING IDOCS LINKED TO DOCUMENTS
7.9.1 * Return the list of IDocs li nked to the delivery CALL FUNCTI ON ' EDI _ GET_L I NKED_ I DOCS' EXPORTI NG OBJ TYPE = ' LI KP' OBJ KEY = I TAB_SO- O856NO TABLES LI NKED_I DOCS = I TAB_L I NKED_I DOCS EXCEPTI ONS OBJ ECT_NOT_ FOUND =1 NO_ I DOCS_L I NKED =2 OBJ ECT_TYPE_ UNKNOWN = 3 I NTERNAL_ERROR =4 OTHERS = 5. I F SY- SUBRC = 0. CLEAR: T_ VBELN_DOCNUM, T_ 824_ DOCNUM. CLEAR: T_VBELN_DATE, T_824_DATE.
7.9.2 * Return the list of IDocs li nked to the invoice CALL FUNCTI ON ' EDI _ GET_L I NKED_ I DOCS' EXPORTI NG OBJ TYPE = ' VBRK' OBJ KEY = I TAB_SO- O810NO TABLES LI NKED_I DOCS = I TAB_L I NKED_I DOCS EXCEPTI ONS OBJ ECT_NOT_ FOUND =1 NO_ I DOCS_L I NKED =2 OBJ ECT_TYPE_ UNKNOWN = 3 I NTERNAL_ERROR =4 OTHERS = 5.
7.9.3 Version 4.6X DATA: DATA:
t_roles LIKE relroles OCCURS 5 WITH HEADER LINE. t_object LIKE borident.
7.9.3.1 R/3 note no. 317864 I n Rel ease 4. 6, t he I Doc base does not use t he Wor kf l ow cont ai ner wi t h t ype C t o save l i nks but t he syst em was changed t o t he gener i c obj ect ser vi ces.
Thi s not e descr i bes i n whi ch r el at i ons t he obj ect s i n t he I Doc pr ocessi ng ar e saved. Thi s know- how i s a pr er equi si t e i n or der t o ef f ect i vel y f i nd a speci al obj ect whose l i nk was saved dur i ng t he I Doc pr ocessi ng. Al l r el at i onshi ps t ypes def i ned i n t he SAP Syst em can be f ound i n t abl e VRBRELTYP. From t he I Doc base, t he f ol l owi ng essent i al r el at i onshi ps have been def i ned: I DC0 - Appl i cat i on document and out bound I Doc ar e r el at ed I DC1 - I nbound I Doc and appl i cat i on document ar e r el at ed I DC3 - I nbound I Doc and i t s ori gi nal I Doc ar e rel at ed (whi l e edi t i ng) I DC4 - I nbound I Doc and out bound I Doc of t he sendi ng syst em are r el at ed ( f or R/ 3 R/ 3 l i nk) I DC7 - Out bound I Doc and i t s ori gi nal I Doc ar e r el at ed ( whi l e edi t i ng) I DC8 - I nbound I Doc and t r ansact i on I D ( of t RFC) are r el at ed I DCA - Out bound I Doc and t r ansact i on I D ( of t RFC) are r el at ed I n or der t o r ead r el at i onshi ps use SREL_GET_NEXT_RELATI ONS. General l y, you need t o t r ansf er t he BOR obj ect ( t r i pl e: obj ect key, obj ect t ype an l ogi cal system) f or whi ch you want t o r ead t he r el at i onshi ps t o thi s f unct i on modul e. I n or der t o f i nd a speci al l i nk you shoul d know i n whi ch r el at i onshi p t he l i nk was saved and whet her t he BOR obj ect was saved i nt o r ol e A or i nt o r ol e B. For i ndi vi dual r el at i onshi p t ypes you can f i nd t hi s i nf or mat i on al so i n t abl e VRBRELTYP. For t he rel at i onshi p types descr i bed above, t he obj ect named f i r st i s al ways i n r ol e A and t he second obj ect i s al ways i n r ol e B. Exampl e: Sear chi ng t he out bound I Doc of t he sendi ng syst em f or an i nbound I Doc whi ch was gener at ed vi a an R/ 3 - R/ 3 communi cat i on. The exampl e sour ce code r epr esent s t he c or r ec t i on. The i nt er nal t abl e wi l l t hen cont ai n an ent r y f r om whi ch you can r ead t he f ol l owi ng i nf or mat i on: The f i el ds OBJ KEY_A, OBJ TYPE_A and LOGSYS_A cont ai n al l t r ansf er r ed val ues of t he obj ect f or whose l i nk you are sear chi ng - t hi s obj ect occur s i n r ol e A. The f i el d RELTYPE cont ai ns t he val ue ' I DC4' - si nce we onl y sear ched f or t hi s. The f i el ds OBJ KEY_B, OBJ TYPE_B and LOGSYS_B cont ai n al l val ues of t he sear ched l i nked obj ect - t hi s sear ched obj ect occur s i n r ol e B. That i s: t he f i el d OBJ KEY_B cont ai ns t he I Doc number of t he sendi ng sys t em, t he f i el d OBJ TYPE_B shoul d cont ai n t he val ue ' I DOC' and t he f i el d LOGSYS_B shoul d cont ai n t he sendi ng l ogi cal syst em. Example
* f i nd t he out bound- I Doc of t he sendi ng syst em f or an i nbound- I Doc, * whi ch was cr eat ed dur i ng R/ 3 - R/ 3 - communi cat i on r e por t t es t . dat a: obj ect1 l i ke bor i dent . dat a: begi n of l i nks occur s 0. i ncl ude st r uctur e rel gr aphl k. dat a: end of l i nks. obj ect 1- obj key = ' 0000000000004711' . " I DOC- Nummer of t he i nbound- I Doc obj ect 1- obj t ype = ' I DOC' . obj ect 1- l ogsys = ' TTTCLNT999' . " << own l ogi cal syst em CALL FUNCTI ON ' SREL_ GET_NEXT_RELATI ONS'
* * * * * * *
EXPORTI NG OBJ ECT ROLETYPE RELATI ONTYPE MAX_HOPS I NCL_ APPLRELS EXCL_ ROLES EXCL_ RELATI ONS TABLES LI NKS ROLES APPLLI NKS EXCEPTI ONS
= = = = = = =
obj ect 1 ' I DC4' 1 ' '
= l i nks = =
OTHERS * * * * * * * *
= 4.
i n t abl e l i nks we can f i nd one ent r y wi t h f ol l owi ng i nf ormat i i n f i el ds OBJ KEY_A, OBJ TYPE_A und LOGSYS_A ar e al l val ues of obj ect 1 - t o t hi s obj ect we l ooked f or t he speci al l i nk obj ect 1 appears i n r ol e A i n f i el d RELTYPE i s t he val ue ' I DC4' - we l ooked onl y f or t hi i n f i el ds OBJ KEY_B, OBJ TYPE_B and LOGSYS_B ar e al l val ues of l i nked obj ect - t hi s l i nked obj ect appear s i n r ol e B t hi s means: i n f i el d OBJ KEY_B i s t he I Doc- number of t he sendi
ons:
s ki nd t he ng Page 4
* s yst em, i n f i el d OBJ TYPE_B shoul d be ' I DOC' and i n LOGSYS_B i s t he * name of t he sendi ng l ogi cal syst em.
7.10 EXAMPLES
7.10.1
Write Idoc Status
FORM write_idoc_status USING p_statxt p_stapa1 p_stapa2 p_stapa3 p_stapa4 p_stamno p_stamid CHANGING t_status. TABLES: t100. CONDENSE CONDENSE CONDENSE CONDENSE
p_stapa1 p_stapa2 p_stapa3 p_stapa4
NO-GAPS. NO-GAPS. NO-GAPS. NO-GAPS.
IF p_statxt IS INITIAL. SELECT SINGLE text FROM t100 INTO t_status WHERE sprsl = 'EN' AND arbgb = p_stamid AND msgnr = p_stamno. ELSE. MOVE p_statxt TO t_status. ENDIF. IF t_status t_status t_status t_status
CS CS CS CS
'&1' OR '&2' OR '&3' OR '&4'.
REPLACE '&1' WITH p_stapa1 REPLACE '&2' WITH p_stapa2 REPLACE '&3' WITH p_stapa3 REPLACE '&4' WITH p_stapa4 CONDENSE t_status.
INTO INTO INTO INTO
t_status. t_status. t_status. t_status.
ELSE. REPLACE '&' WITH p_stapa1 REPLACE '&' WITH p_stapa2 REPLACE '&' WITH p_stapa3 REPLACE '&' WITH p_stapa4 CONDENSE t_status.
INTO INTO INTO INTO
t_status. t_status. t_status. t_status.
ENDIF. ENDFORM.
7.10.2
" WRITE_IDOC_STATUS
BDC Processi ng & Idoc status update
********************************************************************** * - - - - Dat a def i ni t i on - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DATA: BEGI N OF BDCDATA OCCURS 5. I NCLUDE STRUCTURE BDCDATA. DATA: END OF BDCDATA. DATA: C_TCODE LI KE BKPF- TCODE VALUE ' FB01' . DATA BEGI N OF MESSTAB OCCURS 10. I NCLUDE STRUCTURE BDCMSGCOLL. DATA END OF MESSTAB.
*************************************************** ******************* * - - - - Cal l t r ansact i on - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FORM Mai n_Pr ogr am REFRESH BDCDATA. PERFORM APPEND_BDC USI NG ' SAPMF05A' ' 0100' ' ' ' '. PERFORM APPEND_BDC USI NG ' ' ' ' ' BKPF- BLDAT' ' 09031998' . PERFORM APPEND_BDC USI NG ' ' ' ' ' BDC_OKCODE' ' / 00' . PERFORM APPEND_BDC USI NG ' SAPMF05A' ' 0300' ' ' ' '. PERFORM APPEND_BDC USI NG ' ' ' ' ' BSEG- WRBTR' ' *' . PERFORM APPEND_ BDC USI NG ' ' ' ' ' BDC_ OKCODE' ' BU' . CALL TRANSACTI ON ' FB01' USI NG BDCDATA MODE ' N' UPDATE ' S' . PERFORM UPDATE_I DOC_STATUS. ENDFORM. *************************************************** ******************* * - - - Cal l t r ansact i on wi t h er r or s t o BDC - - - - - - - - - - - - - - - - - - - - - - - - - - - - REFRESH MESSTAB. CALL TRANSACTI ON C_TCODE USI NG BDCDATA MODE ' N' UPDATE ' S' MESSAGES I NTO MESSTAB. RETURN_ CODE = SY- SUBRC. I F RETURN_CODE = 0. LOOP AT MESSTAB. I F MESSTAB- MSGTYP = ' E' . RETURN_CODE = MESSTAB- MSGNR. SY- MSGI D = ' B1' . SY- MSGNO = 999. SY- MSGV1 = ' Err or: Check BDC' . ENDI F. ENDLOOP. ENDI F. *- - - Here we check t he ret ur n code, i f t here was an er r or, we put t he * t r ansacti on i n a BDC sessi on f or t he user to r evi ew and corr ect. I F RETURN_CODE NE 0. CALL FUNCTI ON ' BDC_OPEN_ GROUP' EXPORTI NG CLI ENT = SY- MANDT GROUP = ' ZKJ W' USER = SY- UNAME KEEP = ' X' . CALL FUNCTI ON ' BDC_I NSERT' EXPORTI NG TCODE = C_ TCODE TABLES DYNPROTAB = BDCDATA. CALL FUNCTI ON ' BDC_CLOSE_ GROUP' EXCEPTI ONS NOT_ OPEN =1 QUEUE_ERROR = 2 OTHERS = 3. ENDI F. *************************************************** ******************* * - - - Append BDCDATA i nt er nal t abl e - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FORM APPEND_BDC USI NG VALUE( P_ PROG) VALUE( P_ SCREEN) VALUE( P_ NAM) VALUE( P_VAL) . CLEAR BDCDATA. I F P_ PROG NE SPACE. BDCDATA- PROGRAM BDCDATA- DYNPRO BDCDATA- DYNBEGI N BDCDATA- FNAM BDCDATA- FVAL ELSE. BDCDATA- FNAM BDCDATA- FVAL ENDI F. APPEND BDCDATA.
ENDFORM. * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m UPDATE_I DOC_STATUS * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * text *----------------------------------------------------------------------* * - - > p1 t e xt * <- - p2 t ext *----------------------------------------------------------------------* FORM UPDATE_I DOC_STATUS. * - - - Now we check t he CALL TRANSACTI ON r et ur n code and set I DOC st at us CLEAR I DOC_STATUS. I F RETURN_CODE = 0. WORKFLOW_RESULT = ' 0' . I DOC_STATUS- DOCNUM = I DOC_CONTRL- DOCNUM. I DOC_STATUS- STATUS = ' 53' . I DOC_STATUS- UNAME = SY- UNAME. I DOC_STATUS- REPI D = SY- REPI D. I DOC_ STATUS- MSGTY = SY- MSGTY. I DOC_ STATUS- MSGI D = SY- MSGI D. I DOC_STATUS- MSGNO = SY- MSGNO. I DOC_STATUS- MSGV1 = SY- MSGV1. I DOC_STATUS- MSGV2 = SY- MSGV2. I DOC_STATUS- MSGV3 = SY- MSGV3. I DOC_STATUS- MSGV4 = SY- MSGV4. RETURN_VARI ABLES- WF_PARAM = ' Pr ocessed_I DOCs' . RETURN_ VARI ABLES- DOC_NUMBER = I DOC_CONTRL- DOCNUM. APPEND RETURN_VARI ABLES. ELSE. WORKFLOW_RESULT = ' 99999' . I DOC_STATUS- DOCNUM = I DOC_CONTRL- DOCNUM. I DOC_STATUS- STATUS = ' 51' . I DOC_STATUS- UNAME = SY- UNAME. I DOC_STATUS- REPI D = SY- REPI D. I DOC_ STATUS- MSGTY = SY- MSGTY. I DOC_ STATUS- MSGI D = SY- MSGI D. I DOC_STATUS- MSGNO = SY- MSGNO. I DOC_STATUS- MSGV1 = SY- MSGV1. I DOC_STATUS- MSGV2 = SY- MSGV2. I DOC_STATUS- MSGV3 = SY- MSGV3. I DOC_STATUS- MSGV4 = SY- MSGV4. RETURN_VARI ABLES- WF_PARAM = ' Err or _I DOCs' . RETURN_ VARI ABLES- DOC_NUMBER = I DOC_CONTRL- DOCNUM. APPEND RETURN_VARI ABLES. ENDI F. APPEND I DOC_STATUS. ENDFORM. " UPDATE_I DOC_STATUS
7.10.3
Mailing in SAP
7.10.3.1 Z_IDOC_INPUT_ALEAUD Code FUNCTI ON Z_I DOC_I NPUT_ ALEAUD. *"---------------------------------------------------------------------* " * " L oc al i nt e r f ac e: *" I MPORTI NG *" VALUE( I NPUT_METHOD) LI KE BDWFAP_PAR- I NPUTMETHD *" VALUE( MASS_PROCESSI NG) LI KE BDWFAP_ PAR- MASS_PROC *" EXPORTI NG *" VALUE( WORKFLOW_RESULT) LI KE BDWF_ PARAM- RESULT *" VALUE( APPLI CATI ON_ VARI ABLE) LI KE BDWF_ PARAM- APPL_VAR *" VALUE( I N_UPDATE_TASK) LI KE BDWFAP_PAR- UPDATETASK *" VALUE( CALL_TRANSACTI ON_DONE) LI KE BDWFAP_PAR- CALLTRANS *" TABLES *" I DOC_CONTRL STRUCTURE EDI DC *" I DOC_DATA STRUCTURE EDI DD *" I DOC_STATUS STRUCTURE BDI DOCSTAT *" RETURN_VARI ABLES STRUCTURE BDWFRETVAR *" SERI ALI ZATI ON_I NFO STRUCTURE BDI _ SER *" EXCEPTI ONS *" WRONG_ FUNCTI ON_ CALLED *"---------------------------------------------------------------------DATA: T_ I DOC_CONTROL LI KE EDI DC OCCURS 0 WI TH HEADER LI NE, T_I DOC_DATA LI KE EDI DD OCCURS 0 WI TH HEADER LI NE,
T_ ALE_ ERR LI KE ALE_ ERR_ MESSAGE OCCURS 0 WI TH HEADER LI NE, X_OBJ CONT LI KE SOLI OCCURS 0 WI TH HEADER LI NE, X_OBJ HEAD LI KE SOLI OCCURS 0 WI TH HEADER LI NE, RAW_HEAD LI KE SORH OCCURS 0 WI TH HEADER LI NE, X_RECEI VERS LI KE SOOS1 OCCURS 0 WI TH HEADER LI NE. DATA: W_E1ADHDR LI KE E1ADHDR, W_E1STATE LI KE E1STATE, W_E1PRTOB LI KE E1PRTOB, X_OBJ ECT_HD_ CHANGE LI KE SOOD1, RECEI VI NG_SYSTEM LI KE EDI DC- SNDPRN, SENDI NG_SYSTEM LI KE EDI DC- RCVPRN, H_TEXT LI KE SOOD1- OBJ DES, FOLDER_NAME LI KE SOS06- S_FOLNAM, SUBRC LI KE SY- SUBRC, GLOBAL_ SUBRC LI KE SY- SUBRC, X_OBJ ECT_TYPE LI KE SOOD- OBJ TP. T_I DOC_ CONTROL[ ] = I DOC_CONTRL[ ] . T_I DOC_ DATA[ ] = I DOC_DATA[ ] . READ TABLE T_ I DOC_CONTROL I NDEX 1. RECEI VI NG_SYSTEM = T_I DOC_ CONTROL- SNDPRN. SENDI NG_SYSTEM = T_I DOC_CONTROL- RCVPRN. GLOBAL_ SUBRC = 0. LOOP AT T_ I DOC_DATA. CASE T_I DOC_DATA- SEGNAM. WHEN ' E1ADHDR' . I F ZTAUD- MESTYP <> SPACE AND NOT T_ALE_ERR[ ] I S I NI TI AL. * send SAP mai l CLEAR SUBRC. PERFORM SEND_SAP_MAI L TABLES T_ALE_ ERR USI NG RECEI VI NG_SYSTEM SENDI NG_ SYSTEM ZTAUD SUBRC. I F SUBRC <> 0. GLOBAL_ SUBRC = SUBRC. I DOC_STATUS- DOCNUM = T_ I DOC_CONTROL- DOCNUM. I DOC_STATUS- STATUS = ' 51' . I DOC_STATUS- MSGTY = ' E' . I DOC_STATUS- MSGI D = ' B1' . I DOC_ STATUS- MSGNO = ' 999' . I DOC_ STATUS- MSGV1 = TEXT- 013. I DOC_STATUS- MSGV2 = ZTAUD- MESTYP. I DOC_ STATUS- MSGV3 = ' SO_ OBJ ECT_SEND RC =' . I DOC_STATUS- MSGV4 = SUBRC. APPEND I DOC_STATUS. ENDI F. CLEAR T_ALE_ ERR. REFRESH T_ ALE_ERR. ENDI F. W_E1ADHDR = T_ I DOC_DATA- SDATA. CLEAR ZTAUD. SELECT SI NGLE * FROM ZTAUD WHERE MESTYP = W_ E1ADHDR- MESTYP. WHEN ' E1STATE' . I F ZTAUD- MESTYP = SPACE. CONTI NUE. ELSE. W_E1STATE = T_I DOC_DATA- SDATA. CLEAR T_ALE_ ERR. IF W_E1STATE- STATUS = ' 51' OR W_E1STATE- STATUS = ' 56' OR W_E1STATE- STATUS = ' 61' OR W_E1STATE- STATUS = ' 63' OR W_E1STATE- STATUS = ' 65' OR W_E1STATE- STATUS = ' 60' . T_ALE_ERR- STATUS = W_ E1STATE- STATUS. T_ALE_ERR- DOCNUMSND = W_ E1STATE- DOCNUM. ENDI F. ENDI F. WHEN ' E1PRTOB' .
I F ZTAUD- MESTYP = SPACE. CONTI NUE. ELSE. I F T_ALE_ERR- STATUS = SPACE. CONTI NUE. ELSE. W_ E1PRTOB = T_ I DOC_DATA- SDATA. T_ALE_ERR- DOCNUMRCV = W_ E1PRTOB- DOCNUM. APPEND T_ ALE_ERR. CLEAR T_ALE_ERR. ENDI F. ENDI F. ENDCASE. ENDLOOP. I F ZTAUD- MESTYP <> SPACE AND NOT T_ALE_ERR[ ] I S I NI TI AL. send SAP mai l CLEAR SUBRC. PERFORM SEND_ SAP_MAI L TABLES T_ALE_ ERR USI NG RECEI VI NG_SYSTEM SENDI NG_SYSTEM ZTAUD SUBRC. I F SUBRC <> 0. GLOBAL_ SUBRC = SUBRC. I DOC_STATUS- DOCNUM = T_ I DOC_CONTROL- DOCNUM. I DOC_STATUS- STATUS = ' 51' . I DOC_STATUS- MSGTY = ' E' . I DOC_STATUS- MSGI D = ' B1' . I DOC_ STATUS- MSGNO = ' 999' . I DOC_ STATUS- MSGV1 = TEXT- 013. I DOC_STATUS- MSGV2 = ZTAUD- MESTYP. I DOC_ STATUS- MSGV3 = ' SO_OBJ ECT_SEND RC =' . I DOC_STATUS- MSGV4 = SUBRC. APPEND I DOC_STATUS. ENDI F. CLEAR T_ALE_ERR. REFRESH T_ ALE_ERR. ENDI F. *
I F GLOBAL_ SUBRC <> 0. WORKFLOW_RESULT = 99999. RETURN_ VARI ABLES- DOC_NUMBER = T_ I DOC_CONTROL- DOCNUM. RETURN_VARI ABLES- WF_PARAM = ' Err or _I DOCs' . APPEND RETURN_VARI ABLES. ELSE. WORKFLOW_RESULT = 0. CLEAR I DOC_STATUS. I DOC_STATUS- DOCNUM = T_ I DOC_CONTROL- DOCNUM. I DOC_STATUS- STATUS = ' 53' . I DOC_STATUS- MSGTY = ' E' . I DOC_STATUS- MSGI D = ' B1' . I DOC_ STATUS- MSGNO = ' 999' . I DOC_ STATUS- MSGV1 = TEXT- 014. APPEND I DOC_STATUS. CLEAR RETURN_ VARI ABLES. RETURN_VARI ABLES- WF_PARAM = ' Pr ocessed_I DOCs' . RETURN_ VARI ABLES- DOC_NUMBER = T_ I DOC_CONTROL- DOCNUM. APPEND RETURN_VARI ABLES. ENDI F. ENDFUNCTI ON.
DATA: T_ ALE_ ERR_WA LI KE ALE_ ERR_MESSAGE OCCURS 0 WI TH HEADER LI NE, X_OBJ CONT LI KE SOLI OCCURS 0 WI TH HEADER LI NE, * x_obj head l i ke sol i occur s 0 wi t h header l i ne, X_RECEI VERS LI KE SOOS1 OCCURS 0 WI TH HEADER LI NE. DATA: X_OBJ ECT_HD_ CHANGE H_TEXT LI KE H_STATUS LI KE X_OBJ ECT_TYPE LI KE
LI KE SOOD1, SOLI - LI NE, EDI DC- STATUS, SOOD- OBJ TP.
MOVE ' RAW' TO X_OBJ ECT_TYPE. H_TEXT = TEXT- 002. REPLACE ' &' WI TH ZTAUD- MESTYP I NTO H_ TEXT. REPLACE ' &' WI TH RECEI VI NG_SYSTEM I NTO H_TEXT. CONDENSE H_TEXT. MOVE: SY- LANGU TO X_OBJ ECT_HD_CHANGE- OBJ LA, TEXT- 001 TO X_ OBJ ECT_HD_CHANGE- OBJ SRT, TEXT- 001 TO X_ OBJ ECT_HD_CHANGE- OBJ NAM, H_TEXT TO X_OBJ ECT_HD_CHANGE- OBJ DES, ' F' TO X_OBJ ECT_HD_CHANGE- OBJ SNS. * * * * *
" Funct i onal
cl ear x_obj head. r ef r esh x_obj head. move 6 t o r aw_head- r awsi z. move r aw_ head t o x_obj head. append x_obj head. REFRESH X_OBJ CONT. CLEAR X_OBJ CONT. MOVE H_ TEXT TO X_OBJ CONT. APPEND X_OBJ CONT. CLEAR X_OBJ CONT. APPEND X_OBJ CONT. SORT T_ALE_ERR. LOOP AT T_ ALE_ERR. I F H_ STATUS <> T_ALE_ERR- STATUS. I F H_STATUS <> SPACE. PERFORM ERROR_REPORT TABLES X_OBJ CONT T_ALE_ ERR_WA USI NG H_STATUS RECEI VI NG_SYSTEM SENDI NG_ SYSTEM. CLEAR T_ALE_ ERR_WA. REFRESH T_ ALE_ ERR_WA. ENDI F. H_STATUS = T_ALE_ ERR- STATUS. ENDI F. T_ALE_ERR_ WA = T_ALE_ERR. APPEND T_ ALE_ ERR_WA. ENDLOOP. I F SY- SUBRC = 0. PERFORM ERROR_REPORT TABLES X_OBJ CONT T_ALE_ERR_ WA USI NG H_STATUS RECEI VI NG_ SYSTEM SENDI NG_SYSTEM. CLEAR T_ ALE_ERR_ WA. REFRESH T_ ALE_ ERR_ WA. ENDI F. CLEAR X_RECEI VERS. REFRESH X_RECEI VERS. MOVE ZTAUD- DLI NAM TO X_RECEI VERS- RECNAM. " Di st r i but i on l i st MOVE ' X' TO X_RECEI VERS- SNDEX. MOVE ' C' TO X_RECEI VERS- RECESC. APPEND X_RECEI VERS. CLEAR: SY- MSGI D. CALL FUNCTI ON ' SO_ OBJ ECT_SEND'
*
EXPORTI NG OBJ ECT_HD_ CHANGE OBJ ECT_TYPE TABLES OBJ CONT obj head RECEI VERS EXCEPTI ONS ACTI VE_USER_NOT_EXI ST COMMUNI CATI ON_FAI LURE COMPONENT_ NOT_ AVAI LABLE FOLDER_NOT_EXI ST FOLDER_NO_ AUTHORI ZATI ON FORWARDER_NOT_ EXI ST NOTE_NOT_EXI ST OBJ ECT_NOT_EXI ST OBJ ECT_NOT_SENT OBJ ECT_NO_ AUTHORI ZATI ON OBJ ECT_TYPE_NOT_EXI ST OPERATI ON_ NO_ AUTHORI ZATI ON OWNER_NOT_ EXI ST PARAMETER_ ERROR SUBSTI TUTE_NOT_ACTI VE SUBSTI TUTE_NOT_DEFI NED SYSTEM_FAI LURE TOO_MUCH_RECEI VERS USER_ NOT_EXI ST X_ERROR OTHERS
CLEAR X_OBJ CONT. APPEND X_OBJ CONT. CLEAR H_TEXT. CASE H_ STATUS. WHEN ' 51' . H_TEXT = TEXT- 004. WHEN ' 56' . H_TEXT = TEXT- 005. WHEN ' 61' . H_TEXT = TEXT- 006. WHEN ' 63' . H_TEXT = TEXT- 007. WHEN ' 65' . H_TEXT = TEXT- 008. WHEN ' 60' . H_TEXT = TEXT- 009. WHEN OTHERS. H_TEXT = H_ STATUS. ENDCASE. CLEAR X_OBJ CONT. X_OBJ CONT = H_TEXT. APPEND X_OBJ CONT. DESCRI BE TABLE T_ ALE_ERR_WA LI NES H_LI NES. H_TEXT = TEXT- 010. REPLACE ' &' WI TH H_LI NES I NTO H_TEXT.
X_OBJ CONT = H_TEXT. APPEND X_OBJ CONT. H_TEXT = TEXT- 011. REPLACE ' &' WI TH RECEI VI NG_SYSTEM I NTO H_TEXT. REPLACE ' &' WI TH SENDI NG_SYSTEM I NTO H_TEXT. X_OBJ CONT = H_TEXT. APPEND X_OBJ CONT. LOOP AT T_ALE_ ERR_ WA. H_TEXT = TEXT- 012. REPLACE ' &' WI TH T_ ALE_ ERR_ WA- DOCNUMRCV I NTO H_TEXT. REPLACE ' &' WI TH T_ ALE_ ERR_ WA- DOCNUMSND I NTO H_TEXT. X_OBJ CONT = H_TEXT. APPEND X_OBJ CONT. ENDLOOP. ENDFORM.
7.10.4
" ERROR_REPORT
Program example – Report to show EDI status
Includes: ZFORMS * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * & Repor t Z_REPORT_ZTABLE * * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Aut hor : Kevi n Wi l son Dat e: 15t h Sept ember , 2000 * Det ai l : Thi s pr ogr aml oops through t he sal es or der tabl e, t aki ng * r el evant data and st ori ng i t i n t he ZTABLE t abl e. The * ZTABLE t abl e st ores t he st atus of an order i n t he EDI * process. * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * REPORT Z_REPORT_ZTABLE LI NE- SI ZE 160. * - - - TABLE DEFI NI TI ONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TABLES: VBAK, VBAP, VBFA, VBPA, ZTABLE, EDI DC, EDI DD, EDI D4, Z1824HD. * - - - I NTERNAL TABLE DEFI NI TI ONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * I TAB_SO_EXTRA st ores t he key of I TAB_SO as wel l as addi t i onal f i el ds * t hat may be r equi r ed down t he l i ne. eg. Mat eri al number and bi l l i ng * bl ock. TYPES: BEGI N OF I TAB_SO_EXTRA_TYPE, VBELN LI KE VBAK- VBELN, " Sal es Or der # BSTNK LI KE VBAK- BSTNK, " PO # POSNR LI KE VBAP- POSNR, " Sal es Or der Li ne # FAKSP LI KE VBAP-FAKSP, "Li ne I t emBi l l i ng bl ock MATNR LI KE VBAP- MATNR, " Mat er i al number END OF I TAB_SO_EXTRA_TYPE. * Cr eat e an i nter nal t abl e to st ore t he i nvoi ce number s * of t hose i nvoi ces t hat do not have I NVOI C I docs at t ached t o t hem. * i . e. The ZD01 out put was not cr eat ed f or some r eason. TYPES: BEGI N OF TI TAB_ TYPE, O810 LI KE ZTABLE- O810NO, END OF TI TAB_ TYPE. * I nt ernal t abl e def i ni t i ons cont ai ni ng t he dat a ent r i es f or ZTABLE DATA: I TAB_ SO LI KE ZTABLE OCCURS 20000 WI TH HEADER LI NE, I TAB_ SO_EXTRA TYPE I TAB_ SO_ EXTRA_TYPE OCCURS 20000 WI TH HEADER LI NE. * I nt ernal t abl e def i ni t i ons cont ai ni ng i nvoi ce number s t hat need to be * s aved i n or der t o generat e t he ZD01 out put . DATA: TI TAB TYPE TI TAB_TYPE OCCURS 100 WI TH HEADER LI NE. * Col umn names r equi r ed f or f i l e downl oad. DATA: BEGI N OF T_ COLNAMES OCCURS 10, NAME( 15) , " Col umn names f or downl oad END OF T_ COLNAMES. * - - - DATA DEFI NI TI ONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DATA: E1EDP26 TYPE E1EDP26, E1EDP01 TYPE E1EDP01, " Li ne i t em segment T_POSNR LI KE VBAP- POSNR, " Li ne i t em number I NVOI CE_FLAG( 1), "I s t here an i nvoi ce? Y/ N DELI VERY_FLAG( 1) , "I s t here a del i ver y? Y/ N FI ELD_NAME( 30) , "Check f or l i ne sel ecti on on f i el d
T_I DOC LI KE EDI DC- DOCNUM, " St or e I Doc number f or l i ne sel ect n T_STAT LI KE ZTABLE- I 824856STAT. " Tempor ar y 824 st at us * - - - CONSTANT DEFI NI TI ONS - - - FOR CO. A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CONSTANTS: C_SPART_12 LI KE VBAK- SPART VALUE ' 12' , " Di vi si on 12 C_AUART_ZEDI LI KE VBAK- AUART VALUE ' ZEDI ' . " Doc t ype ZEDI * - - - SELECTI ON OPTI ONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SELECTI ON- SCREEN BEGI N OF BLOCK SO WI TH FRAME TI TLE TEXT- 001. SELECT- OPTI ONS: S_VBELN FOR VBAK- VBELN, " Sal es or der number S_ERDAT FOR VBAK- ERDAT, " Sal es or der dat e S_KUNNR FOR VBPA- KUNNR. " Shi p t o par t ner SELECTI ON- SCREEN END OF BLOCK SO. SELECTI ON- SCREEN BEGI N OF BLOCK UP WI TH FRAME TI TLE TEXT- 002. PARAMETERS: P_ UPD_Y RADI OBUTTON GROUP UPD, " Updat e t abl e P_ UPD_N RADI OBUTTON GROUP UPD. " Don' t updat e t abl e SELECTI ON- SCREEN END OF BLOCK UP. SELECTI ON- SCREEN BEGI N OF BLOCK G2 WI TH FRAME TI TLE TEXT- 011. PARAMETERS: P_ VI EW RADI OBUTTON GROUP L1, " Vi ew P_ DOWN RADI OBUTTON GROUP L1, " Downl oad P_FI LE LI KE RLGRAP- FI LENAME DEFAULT ' C: \ ZTABLE. XLS' . SELECTI ON- SCREEN END OF BLOCK G2. AT SELECTI ON- SCREEN ON P_FI LE. * I f downl oad i s checked, but no f i l e name i s ent ered, err or I F P_ DOWN EQ ' X' AND P_FI LE EQ SPACE. MESSAGE E999( B1) WI TH TEXT- 014. ENDI F. * - - - I NCLUDES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I NCLUDE Z_FORMS. * - - - I NI TI ALI ZATI ON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I NI TI ALI ZATI ON. REFRESH: I TAB_SO, I TAB_ SO_ EXTRA, TI TAB. CLEAR: I TAB_SO, I TAB_ SO_ EXTRA, TI TAB. * - - - SELECTI ON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - START- OF- SELECTI ON. I F P_UPD_Y EQ ' X' . " Updat e ZTABLE t abl e SELECT VBELN ERDAT BSTNK FROM VBAK I NTO ( VBAK- VBELN, VBAK- ERDAT, VBAK- BSTNK) WHERE VBELN I N S_VBELN AND ERDAT I N S_ ERDAT AND SPART = C_SPART_ 12 AND AUART = C_AUART_ ZEDI . * Popul at e the i nt er nal t abl e wi t h the r el evant data PERFORM UPDATE_I TAB_SO USI NG VBAK- VBELN VBAK- ERDAT VBAK- BSTNK. ENDSELECT. "Loop t hrough sel ect ed orders f or updat i ng i t ab I F SY- SUBRC NE 0. MESSAGE I 999( B1) WI TH TEXT- 003. " No sal es or der s f ound i n range ELSE. * Per f or m an updat e on t he dat abase t abl e ZTABLE usi ng I TAB_SO PERFORM UPDATE_ZTABLE TABLES I TAB_SO. * Pr i nt I TAB_SO and I TAB_SO_EXTRA cont ent s t o t he scr een f i l t eri ng out * cust omers not sel ected vi a the sel ect i on scr een PERFORM PRI NT_I TAB TABLES I TAB_SO I TAB_SO_EXTRA. ENDI F. "sy- subr c check on sal es order sel ecti on ELSE. " The user has r equest ed t o vi ew t he t abl e and not do updat e REFRESH: I TAB_SO_EXTRA, I TAB_ SO. CLEAR: I TAB_SO_EXTRA, I TAB_ SO. SELECT * I NTO WHERE VBELN DATUM I F SY- SUBRC =
TABLE I TAB_SO FROM ZTABLE I N S_VBELN AND I N S_ERDAT. 0.
LOO LOOP AT I TAB_ TAB_ SO. SO. * We nee need d t o see i f t he or der der we have have i s a CO CO. A or der der . A CO. A or der der * i s un uni quel y i dent ent i f i ed wi t h Di vi si on = 12 and Or der t ype ype = ZEDI SELECT SI NGLE SPART AU AUART ART FROM FROM VBAK VBAK I NTO ( VBAK VBAK-- SPART, SPART, VBAK VBAK-- AUAR AUART) T) WHERE ERE VBELN VBELN = I TAB_ TAB_ SOSO- VBELN. VBELN. I F SYSY- SUBRC = 0. * Check heck f or CO. A or or der der I F VBAK VBAK-- SPA SPART RT = C_ SPA SPAR RT_ 12 AN AND VBAK VBAK-- AUAR AUART T = C_AUAR C_AUART_ T_ ZED ZEDI . T_ POSN POSNR R = I TAB_ TAB_ SOSO- POSN POSNR R DI V 10. SELECT SEL ECT MATNR FAKSP FRO F ROM VBAP I NTO ( I TAB_ TAB_ SO_ SO_ EXTR EXTRAA- MATN ATNR, I TAB_ TAB_ SO_ SO_ EXTR EXTRAA- FAKSP) FAKSP) WHERE VBELN VBELN = I TAB_SO- VBELN AN AND POSN POSNR R = T_ POSN POSNR. R. I TAB TAB_SO_ _SO_ EXTR EXTRA A- VBELN = I TAB TAB_SO_SO- VBELN. ELN. I TAB_ TAB_ SO_ SO_ EXTR EXTRAA- POSN POSNR R = I TAB_ TAB_ SOSO- POSN POSNR R. I TAB TAB_SO_ _SO_ EXTR EXTRA A- BSTNK = I TAB TAB_SO_SO- BSTKD STKD. APPEND I TAB_ TAB_ SO_ SO_ EXTRA. EXTRA. END ENDSELEC SELECT. T. " Updat pdat e ext r a det det ai l s END ENDI F. " Check f or CO. A or der s wi t h DI V=12 & Or d Type= Type=ZEDI EDI END ENDI F. " SySy- subrc check on l ookup ookup f or DI DI V and and Or d Type Type ENDLOO LOOP. "I TAB TAB_SO i nter nal nal t abl abl e l oop oop * Pr i nt I TAB TAB_SO and and I TAB TAB_SO_EX _SO_EXTR TRA A cont cont ent ent s * cust omers not sel ected vi vi a the sel sel ect ect i on PERFO PERFOR RM PRI PRI NT_I TAB TAB TABLES TABLES I TAB_SO TAB_SO I TAB_SO TAB_SO_EXTRA _EXTRA. ELSE. ELSE. "No "No MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 005. 005. " No ENDI F. ENDI F.
t o t he scr een een f i l t eri ng out out scr een een
ent ent r i es were f ound ound i n I TAB TAB_SO ent ent r i es i n I TAB TAB_SO! _SO!
* Loop Loop thr oug ough the i nt ernal ernal t abl abl e set set up t o st ore t he i nvoi voi ce nu number ber s * of t hose hose i nvoi nvoi ces t hat hat do not not have have I NVOI C I docs docs at t ached ached t o t hem hem. PERFO PERFOR RM SAVE SAVE__ BI LLI NG_ DOC TABLES TABLES TI TAB. TAB. END END- OF- SELECTI SELECTI ON. * - - - EVEN EVENT : AT LI NE SELE SELEC CTI ON - - AT LI NE- SELEC SELECTI TI ON. * Re Ret ur n the f i el d t hat t he use userr cl i cked cked on GET CURSO CURSOR FI ELD FI ELD_ ELD_ NAME. CASE CASE FI ELD_ ELD_ NAME. * Cl i cked on message f r om 824 824 WHEN ' I TAB_SO TAB_SO- I 82481 824810N 0NO OTE' OR ' I TAB_SO TAB_SO- I 82485 824856N 6NO OTE' . I F T_I DOC <> ' ' . I F T_ T_ ST STAT = ' R' . * Re Ret ur n the f ul l detai l of t he er er r or usi ng repo repor t Z_LI ST_I DOC_824 _824 SUBM SUBMI T Z_ Z_ LI ST_ I DOC_824 WI TH I _ DOCN = T_ I DOC AND AND RETU RETURN RN. ELSE. ELSE. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 013. 013. " I Doc not r ej ect ed ENDI F. ELSE ELSE.. MESSAG ESSAGE I 999( B1) B1) WI TH TEXTTEXT- 012. " No I Doc ENDI F. * Cl i cked on I nvoi nvoi ce num number ber WHEN ' I TAB_SO TAB_SO-- O810NO' . I F I TAB TAB_SO_SO- O810N 810NO <> ' ' . SET PAR PARAM AMETER I D ' VF' FI ELD I TAB_ TAB_ SOSO- O810NO. CALL TRAN TRANSAC SACTI ON ' VF03' AND SKI SKI P FI RST SCR SCREEN. " Vi ew I nvoi ce ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 008. 008. " Cl i ck on i nvoi nvoi ce ENDI F. * Cl i cked on del del i ver ver y num number ber WHEN ' I TAB_SO TAB_SO-- O856NO' . I F I TAB TAB_SO_SO- O856N 856NO <> ' ' . SET PAR PARAM AMETER I D ' VL' FI ELD I TAB_ TAB_ SOSO- O856NO. CALL TRAN TRANSAC SACTI ON ' VL03' AND SKI SKI P FI RST SC SCREEN. " Vi ew del i ver y ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 010. 010. " Cl i ck on Del Del i very ENDI F. * Cl i cked on Sal Sal es Or Or der der num number ber WHEN ' I TAB_SO TAB_SO- VBELN BELN'' . SET PARAM PARAMETER I D ' AUN AUN' FI ELD I TAB_SO TAB_SO-- VBELN VBELN.. CALL TRAN TRANSAC SACTI ON ' VA03' VA03' AND SKI P FI RST RST SCR SCREEN. EEN. " Vi ew Sal es Or Or der * DES DESA ADV I doc doc # cl i cked
WHEN ' I TAB_SO- O856DO 856DOCNU CNUM' . I F I TAB TAB_SO_SO- O856D 856DOCNUM <> ' ' . MOVE I TAB_SO- O856DO 856DOCNU CNUM TO T_ I DOC. CALL CALL FUN FUNCTI CTI ON ' EDI EDI _ DOCUMENT_ ENT_ DATA_ ATA_ DI SPLAY' " Dsi pl ay I doc EXPORTI EXPORTI NG DOCNUM = T_ I DOC TREE_D TREE_DII SPLAY = ' Y' EXCEPTI EXCEPTI ONS NO_ DATA_RECO ATA_ RECORD_ RD_ FOUN FOUND = 1 OTHER THERS S = 2. I F SYSY- SUB SUBRC <> 0. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. * I NVOI C I doc # cl i cked cked WHEN ' I TAB_SO- O810DO 810DOCNU CNUM' . I F I TAB TAB_SO_SO- O810D 810DOCNUM <> ' ' . MOVE I TAB_SO- O810DO 810DOCNU CNUM TO T_ I DOC. CALL CALL FUN FUNCTI CTI ON ' EDI EDI _ DOCUMENT_ ENT_ DATA_ ATA_ DI SPLAY' " Di spl ay an I Doc. EXPORTI EXPORTI NG DOCNUM = T_ I DOC TREE_D TREE_DII SPLAY = ' Y' EXCEPTI EXCEPTI ONS NO_ DATA_RECO ATA_ RECORD_ RD_ FOUN FOUND = 1 OTHER THERS S = 2. I F SYSY- SUB SUBRC <> 0. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. * ZAPPA ZAPPAD DV810 810 I Doc # cl i cked WHEN ' I TAB_ TAB_ SOSO- I 824810DOCNUM' . I F I TAB TAB_SO_SO- I 8248 824810 10D DOCNUM <> ' ' . MOVE I TAB_ TAB_ SOSO- I 824810DOCNUM TO T_ I DOC. CALL CALL FUN FUNCTI CTI ON ' EDI EDI _ DOCUMENT_ ENT_ DATA_ ATA_ DI SPLAY' " Di spl ay I Doc EXPORTI EXPORTI NG DOCNUM = T_ I DOC TREE_D TREE_DII SPLAY = ' Y' EXCEPTI EXCEPTI ONS NO_ DATA_RECO ATA_ RECORD_ RD_ FOUN FOUND = 1 OTHER THERS S = 2. I F SYSY- SUB SUBRC <> 0. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. * ZAPPA ZAPPAD DV856 856 I Doc # cl i cked WHEN ' I TAB_ TAB_ SOSO- I 824856DOCNUM' . I F I TAB TAB_SO_SO- I 8248 824856 56D DOCNUM <> ' ' . MOVE I TAB_ TAB_ SOSO- I 824856DOCNUM TO T_ I DOC. CALL CALL FUNCTI CTI ON ' EDI EDI _ DOCUMENT_ ENT_ DATA_ ATA_ DI SPLAY' " Di spl ay I Doc EXPORTI EXPORTI NG DOCNUM = T_ I DOC TREE_D TREE_DII SPLAY = ' Y' EXCEPTI EXCEPTI ONS NO_ DATA_RECO ATA_ RECORD_ RD_ FOUN FOUND = 1 OTHER THERS S = 2. I F SYSY- SUB SUBRC <> 0. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. ELSE ELSE.. MESSA ESSAG GE I 999( 999( B1) WI TH TEX TEXT- 007. 007. " Cl i ck on I Doc. ENDI F. ENDCASE. SE. "Eval "Eval uat uat i on of f i el d nam names
* Loop t hr ough ough VBA VBAP and updat updat e t he t abl e ZTAB TABLE *----------------------------------------------------------------------* * - - >VBAK VBAK__ VBELN VBELN Sal es Or der Number * - - >VBA VBAK_ERD K_ERDAT Sal es Or der Dat e * - - >VBAK VBAK__ BSTN BSTNK K Pur chase Or der Number *----------------------------------------------------------------------* FORM FORM UPDATE_I PDATE_I TAB_ TAB_ SO USI USI NG VBAK VBAK__ VBELN VBELN VBAK_ VBAK_ ERDAT ERDAT VBAK VBAK__ BSTNK. * - - - LOC LOCAL VA VARI ABLES - - DATA: ATA: T_ POSN POSNR R LI KE VBAPVBAP- POSN POSNR, R, T_ VBELN VBELN__ DOCNUM LI KE EDI EDI DC- DOCNUM, T_ VBELN VBELN__ DATE ATE LI KE EDI EDI DC- CRED REDAT, T_ PRI PRI CE LI KE ZTAB ZTABLELE- O810PR 810PRI CE, T_ SEGNUM LI KE EDI EDI D4- SEGNUM, T_ 824_DO 824_DOCNUM LI KE EDI EDI DC- DOCNUM, T_ 824_NO 824_NOTE LI KE ZTAB ZTABLELE- I 824856N 824856NO OTE, T_ 824_STAT LI KE ZTAB ZTABLELE- I 824856STA 824856STAT, T, T_ 824_DATE 824_DATE LI KE EDI EDI DC- CRED REDAT, N1 TYPE TYPE I . * - - - LOC LOCAL I NTER TERNAL TAB TABLES - - DATA: I TAB_L I NKED_ KED_ I DOCS LI KE SWW_ CONTOB TOB OCCUR CCURS S 5 WI TH HEADER EADER LI NE. * I ni t i al i z at at i on CLEAR LEAR: I TAB TAB_ SO, I TAB_SO TAB_SO_EXTRA. _EXTRA. * St or e Sal Sal es Or Or der der Header eader Dat a MOVE: VBAK VBAK__ VBELN VBELN TO I TAB_ TAB_ SOSO- VBELN, VBELN, VBAK_ VBA K_ERD ERDAT TO I TAB_SO- DATUM ATUM, VBAK VBAK__ BSTNK BSTNK TO I TAB_ TAB_ SOSO- BSTKD BSTKD. MOVE: VBAK VBAK__ VBELN VBELN TO I TAB_ TAB_ SO_ SO_ EXTRAEXTRA- VBELN, VBELN, VBAK VBAK__ BSTNK BSTNK TO I TAB_ TAB_ SO_ SO_ EXTRAEXTRA- BSTNK. * Get shi p t o cust omer num number ber f r om VBPA SELECT SELE CT SI NGLE KUNNR FRO FROM VBPA I NTO I TAB_SO- KUN KUNNR WHERE HERE VBELN = VBAK_ VBAK_ VBELN AND POSN POSNR R = ' 000000' 000000' AND PAR PARVW = ' WE' . "Shi "Shi p t o part ner f unct unct i on * Loop Loop t hroug hrough t he sal es or or der der l i ne i t ems. SELECT SELE CT * FROM FROM VBA VBAP P WHERE VBELN = VBA VBAK_ K_VBELN VBELN.. T_ POSN POSNR R = VBAPVBAP- POSN POSNR R * 10. MOVE: T_ POSN POSNR R TO I TAB_SO- POSN POSNR. R. MOVE: T_ POSN POSNR R TO I TAB_SO_EXTRA- POSN POSNR, R, VBAP- FAK FAKSP TO I TAB TAB_SO_EX _SO_EXTR TRA A- FAK FAKSP, SP, " Bi l l i ng bl ock VBAPVBAP- MATNR TO I TAB_SO TAB_SO__ EXTR EXTRAA- MATN ATNR. " Mat er i al # *
Get del del i ver ver y and and i nvoi nvoi ce num number ber CLEAR: LEAR: I TAB_ TAB_ SOSO- O856NO, I TAB_ TAB_ SOSO- O856DATE, ATE, I TAB_SO- O856DO 856DOCNUM. CLEAR: LEAR: I TAB_ TAB_ SOSO- O810NO, I TAB_ TAB_ SOSO- O810DATE, ATE, I TAB TAB_SO_SO- O810PR 810PRII CE, I TAB_SO- O810DO 810DOCNUM. I NVOI CE_FLAG _FLAG = ' ' . DELI ELI VERY_FLA Y_FLAG = ' ' . SELECT VBELN VBELN VBTYP_ VBTYP_ N FROM VBFA VBFA I NTO ( VBFAVBFA- VBELN, VBELN, VBFAVBFA- VBTYP_N) VBTYP_N) WHERE VBELV = VBAK_ VBAK_ VBELN AND AND POSN POSNV V = VBAPVBAP- POSN POSNR. R. CASE CASE VBFAVBFA- VBTYP_ VBTYP_ N. WHEN ' J ' . "Del "Del i ver ver y DELI VERY_FLA Y_FLAG = ' X' . MOVE VBFAVBFA- VBELN TO I TAB_SO- O856NO. I F I TAB TAB_SO_SO- O856N 856NO <> ' ' .
* Re Ret urn t he l i st of I Docs l i nked ked to the del i very CALL FUN FUNCTI ON ' EDI EDI _ GET_L I NKED_ I DOCS' EXPORTI EXPORTI NG OBJ TYPE = ' LI KP' OBJ KEY KEY = I TAB_ TAB_ SOSO- O856NO TABLES TABLES LI NKED KED_I DOCS = I TAB TAB_L I NKED KED_I DOCS EXCEPTI EXCEPTI ONS
OBJ ECT_NOT_ FOUND =1 NO_ I DOCS_L I NKED =2 OBJ ECT_TYPE_ UNKNOWN = 3 I NTERNAL_ERROR =4 OTHERS = 5. I F SY- SUBRC = 0. CLEAR: T_ VBELN_DOCNUM, T_ 824_ DOCNUM. CLEAR: T_VBELN_DATE, T_824_DATE. * FI LTER OUT ALL BUT THE LATEST I DOCS PERFORM GET_ I DOC_MESTYP TABLES I TAB_ LI NKED_I DOCS USI NG ' LI KP' T_POSNR CHANGI NG T_ VBELN_DOCNUM T_VBELN_ DATE T_824_ STAT T_824_ NOTE T_824_ DATE T_824_ DOCNUM. MOVE T_ VBELN_DOCNUM TO I TAB_ SO- O856DOCNUM. MOVE T_ VBELN_DATE TO I TAB_SO- O856DATE. MOVE T_ 824_ DOCNUM TO I TAB_SO- I 824856DOCNUM. MOVE T_824_STAT TO I TAB_ SO- I 824856STAT. MOVE T_ 824_NOTE TO I TAB_ SO- I 824856NOTE. MOVE T_ 824_DATE TO I TAB_ SO- I 824856DATE. REFRESH: I TAB_ LI NKED_I DOCS[ ] , I TAB_L I NKED_I DOCS. CLEAR: I TAB_LI NKED_ I DOCS. ELSE. "No I Docs were l i nked t o Del i ver y MOVE ' ' TO I TAB_SO- O856DOCNUM. MOVE ' ' TO I TAB_SO- O856DATE. MOVE ' ' TO I TAB_SO- I 824856DOCNUM. MOVE ' N' TO I TAB_ SO- I 824856STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824856NOTE. MOVE ' ' TO I TAB_SO- I 824856DATE. ENDI F. ELSE. "I n case t he del i very i s not there. . . MOVE ' ' TO I TAB_SO- O856DOCNUM. MOVE ' ' TO I TAB_ SO- O856DATE. MOVE ' ' TO I TAB_ SO- I 824856DOCNUM. MOVE ' N' TO I TAB_SO- I 824856STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824856NOTE. MOVE ' ' TO I TAB_ SO- I 824856DATE. ENDI F. WHEN ' M' . "I nvoi ce I NVOI CE_FLAG = ' X' . MOVE VBFA- VBELN TO I TAB_SO- O810NO. I F I TAB_SO- O810NO <> ' ' . * Ret urn t he l i st of I Docs l i nked to the i nvoi ce CALL FUNCTI ON ' EDI _ GET_L I NKED_ I DOCS' EXPORTI NG OBJ TYPE = ' VBRK' OBJ KEY = I TAB_SO- O810NO TABLES LI NKED_I DOCS = I TAB_L I NKED_I DOCS EXCEPTI ONS OBJ ECT_NOT_ FOUND =1 NO_ I DOCS_L I NKED =2 OBJ ECT_TYPE_ UNKNOWN = 3 I NTERNAL_ERROR =4 OTHERS = 5. I F SY- SUBRC = 0. CLEAR: T_ VBELN_DOCNUM, T_ 824_DOCNUM, T_ 824_NOTE, T_ 824_STAT. CLEAR: T_VBELN_DATE, T_824_DATE. * FI LTER OUT ALL BUT THE LATEST I DOCS PERFORM GET_ I DOC_MESTYP TABLES I TAB_ LI NKED_I DOCS USI NG ' VBRK' T_ POSNR CHANGI NG T_ VBELN_DOCNUM T_VBELN_ DATE T_824_ STAT T_824_ NOTE T_824_ DATE T_824_ DOCNUM. MOVE T_ VBELN_DOCNUM TO I TAB_ SO- O810DOCNUM. MOVE T_ VBELN_DATE TO I TAB_SO- O810DATE. MOVE T_ 824_ DOCNUM TO I TAB_SO- I 824810DOCNUM. MOVE T_824_STAT TO I TAB_ SO- I 824810STAT.
MOVE T_ 824_NOTE MOVE T_ 824_DATE
TO I TAB_ SO- I 824810NOTE. TO I TAB_ SO- I 824810DATE.
* Get i nvoi ce pr i ce I F T_VBELN_DOCNUM I S I NI TI AL. CLEAR T_PRI CE. ELSE. SELECT * FROM EDI D4 WHERE DOCNUM = T_ VBELN_DOCNUM AND SEGNAM = ' E1EDP01' . MOVE EDI D4- SDATA TO E1EDP01. I F E1EDP01- POSEX = VBAP- POSNR. T_SEGNUM = EDI D4- SEGNUM. SELECT * FROM EDI D4 WHERE DOCNUM = T_ VBELN_DOCNUM AND SEGNAM = ' E1EDP26' AND PSGNUM = T_SEGNUM. MOVE EDI D4- SDATA TO E1EDP26. I F E1EDP26- QUALF = ' 010' . "Pri ce qual i f i er T_PRI CE = E1EDP26- BETRG. EXI T. ENDI F. ENDSELECT. MOVE T_PRI CE TO I TAB_SO- O810PRI CE. EXI T. ENDI F. ENDSELECT. ENDI F. REFRESH: I TAB_ LI NKED_I DOCS[ ] , I TAB_L I NKED_I DOCS. CLEAR: I TAB_LI NKED_ I DOCS. ELSE. "Di dn' t fi nd any l i nked I Docs t o t he i nvoi ce * Save i nvoi ce number f or t hose i nvoi ces wi t hout I Docs. Lat er we wi l l * s ubmi t t hese number s f or savi ng. TI TAB- O810 = I TAB_SO- O810NO. APPEND TI TAB. * SUBMI T ZVF02SAVE WI TH BI LLI NG = I TAB_SO- O810NO AND RETURN. MOVE ' ' TO I TAB_SO- O810DOCNUM. MOVE ' ' TO I TAB_SO- O810DATE. MOVE ' ' TO I TAB_SO- I 824810DOCNUM. MOVE ' N' TO I TAB_ SO- I 824810STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824810NOTE. MOVE ' ' TO I TAB_SO- I 824810DATE. MOVE ' ' TO I TAB_SO- O810PRI CE. ENDI F. ELSE. MOVE ' ' TO I TAB_SO- O810DOCNUM. MOVE ' ' TO I TAB_ SO- O810DATE. MOVE ' ' TO I TAB_ SO- I 824810DOCNUM. MOVE ' N' TO I TAB_SO- I 824810STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824810NOTE. MOVE ' ' TO I TAB_ SO- I 824810DATE. MOVE ' ' TO I TAB_ SO- O810PRI CE. MOVE ' ' TO I TAB_ SO- O810NO. ENDI F. ENDCASE. ENDSELECT. I F SY- SUBRC = 0. ELSE. MOVE ' ' TO I TAB_SO- O856DOCNUM. MOVE ' ' TO I TAB_ SO- O856DATE. MOVE ' ' TO I TAB_ SO- O856NO. MOVE MOVE MOVE MOVE
'' ' N' ' No ''
MOVE MOVE MOVE MOVE
'' '' '' ''
MOVE MOVE MOVE MOVE ENDI F.
TO I TAB_SO- I 824856DOCNUM. TO I TAB_SO- I 824856STAT. 824 r ecei ved' TO I TAB_SO- I 824856NOTE. TO I TAB_SO- I 824856DATE.
TO TO TO TO
'' ' N' ' No ''
I TAB_SO- O810DOCNUM. I TAB_ SO- O810DATE. I TAB_ SO- O810PRI CE. I TAB_ SO- O810NO.
TO I TAB_SO- I 824810DOCNUM. TO I TAB_SO- I 824810STAT. 824 r ecei ved' TO I TAB_SO- I 824810NOTE. TO I TAB_SO- I 824810DATE. " Subsequent document s
I F DELI VERY_FLAG <> ' X' .
MOVE ' ' TO I TAB_SO- I 824856DOCNUM. MOVE ' N' TO I TAB_SO- I 824856STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824856NOTE. MOVE ' ' TO I TAB_SO- I 824856DATE. ELSE. "Del i ver y was f ound. DELI VERY_FLAG = ' ' . ENDI F. I F I NVOI CE_FLAG <> ' X' . MOVE ' ' TO I TAB_SO- I 824810DOCNUM. MOVE ' N' TO I TAB_SO- I 824810STAT. MOVE ' No 824 r ecei ved' TO I TAB_SO- I 824810NOTE. MOVE ' ' TO I TAB_SO- I 824810DATE. ELSE. "I nvoi ce was f ound. I NVOI CE_FLAG = ' ' . ENDI F. APPEND: I TAB_ SO, I TAB_SO_EXTRA. ENDSELECT. I F SY- SUBRC NE 0. "Sal es Or der has no l i ne i t ems CLEAR I TAB_SO- POSNR. ENDI F. ENDFORM. " UPDATE_I TAB_SO * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m UPDATE_ZTABLE * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Update ZTABLE t abl e wi t h i nter nal t abl e dat a *----------------------------------------------------------------------* * - - >P_I TAB_SO I nt ernal t abl e t ext cont ai ni ng data t o be updat ed *----------------------------------------------------------------------* FORM UPDATE_ZTABLE TABLES P_I TAB_SO STRUCTURE I TAB_SO. MODI FY ZTABLE FROM TABLE P_ I TAB_SO. I F SY- SUBRC NE 0. " Some i t ems not updat ed MESSAGE I 999( B1) WI TH SY- DBCNT TEXT- 004. ELSE. I F SY- DBCNT EQ 0. "No ent r i es i n i t ab_so MESSAGE I 999( B1) WI TH TEXT- 005. ELSE. " & ent r i es added t o ZTABLE MESSAGE I 999( B1) WI TH SY- DBCNT TEXT- 006. ENDI F. ENDI F. ENDFORM. " UPDATE_ ZTABLE * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m PRI NT_I TAB * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Pri nt out t he 2 i nt ernal t abl es *----------------------------------------------------------------------* * - - >P_I TAB_SO ZTABLE i nf or mat i on * - - >P_I TAB_SO_EXTRA Addi t i onal i nf ormati on wi t h t he same key *----------------------------------------------------------------------* FORM PRI NT_I TAB TABLES I TAB_SO STRUCTURE I TAB_SO I TAB_SO_ EXTRA STRUCTURE I TAB_SO_EXTRA. SORT I TAB_SO BY VBELN POSNR. LOOP AT I TAB_SO. I F I TAB_SO- KUNNR I N S_KUNNR. " Onl y pr i nt out Cust omer s i n r ange SELECT SI NGLE SPART AUART FROM VBAK I NTO ( VBAK- SPART, VBAK- AUART) WHERE VBELN = I TAB_SO- VBELN. I F SY- SUBRC = 0. I F VBAK- SPART = C_SPART_12 AND VBAK- AUART = C_AUART_ZEDI . READ TABLE I TAB_SO_EXTRA WI TH KEY VBELN = I TAB_SO- VBELN POSNR = I TAB_SO- POSNR BSTNK = I TAB_SO- BSTKD. I F I TAB_SO- POSNR = ' 000010' . FORMAT COLOR COL_KEY. I F SY- TABI X <> 1. ULI NE. ENDI F. * Sal es Or der number WRI TE: / 1 I TAB_SO- VBELN. HI DE I TAB_ SO- VBELN. * PO Number WRI TE: I TAB_SO- BSTKD, * PO Dat e I TAB_SO- DATUM, * Cust omer Number I TAB_SO- KUNNR. * Sal es order header bi l l i ng bl ock
*
* * * * *
*
* * *
* * *
* *
*
SELECT SI NGLE FAKSK FROM VBAK I NTO VBAK- FAKSK WHERE VBELN = I TAB_SO- VBELN. I F SY- SUBRC = 0. WRI TE: VBAK- FAKSK. ENDI F. FORMAT COLOR OFF . ENDI F. Li ne i t emnumber I F I TAB_SO- POSNR <> ' 000010' . SKI P 1. ENDI F. FORMAT COLOR COL_ GROUP. WRI TE: / 5 I TAB_SO- POSNR, Mat er i al Number I TAB_SO_EXTRA- MATNR, Bi l l i ng bl oc k at t h e l i ne i t e m l evel I TAB_SO_EXTRA- FAKSP. FORMAT COLOR COL_ NORMAL. Del i very Number WRI TE: / 5 ' Del i ver y: ' , I TAB_SO- O856NO. HI DE I TAB_ SO- O856NO. DESADV I Doc number WRI TE: I TAB_ SO- O856DOCNUM. HI DE I TAB_SO- O856DOCNUM. DESADV Dat e WRI TE: I TAB_ SO- O856DATE. I F I TAB_SO- I 824856STAT = ' R' OR I TAB_SO- I 824856STAT = ' X' . FORMAT COLOR COL_NEGATI VE. ELSEI F I TAB_SO- I 824856STAT = ' N' . FORMAT COLOR COL_NEGATI VE. ELSEI F I TAB_SO- I 824856STAT = ' A' . FORMAT COLOR COL_ POSI TI VE. ELSE. FORMAT COLOR COL_TOTAL. ENDI F. 824 f or 856 Stat us WRI TE: / 10 ' 824 f or 856: ' , I TAB_SO- I 824856STAT. MOVE I TAB_ SO- I 824856STAT TO T_STAT. HI DE T_ STAT. 824 f or 856 I Doc Number WRI TE: I TAB_ SO- I 824856DOCNUM. HI DE I TAB_ SO- I 824856DOCNUM. 824 f or 856 I Doc Dat e WRI TE: I TAB_ SO- I 824856DATE, 824 f or 856 Er r or Text Detai l I TAB_ SO- I 824856NOTE. MOVE I TAB_ SO- I 824856DOCNUM TO T_ I DOC. HI DE T_I DOC. FORMAT COLOR COL_ NORMAL. I nvoi ce number WRI TE: / 5 ' I nvoi ce: ' , I TAB_SO- O810NO. HI DE I TAB_ SO- O810NO. I NVOI C I Doc Number I f t her e i s an i nvoi ce number but no I Doc number t hen hi ghl i ght I F I TAB_SO- O810DOCNUM = ' ' AND I TAB_SO- O810NO <> ' ' . FORMAT COLOR COL_TOTAL. WRI TE: ' NO I NVOI C I Doc!' . FORMAT COLOR OFF . ELSE. WRI TE: I TAB_SO- O810DOCNUM. ENDI F. HI DE I TAB_SO- O810DOCNUM. I NVOI C I Doc Dat e WRI TE: I TAB_ SO- O810DATE, I NVOI C I Doc Pr i ce I TAB_ SO- O810PRI CE. I F I TAB_SO- I 824810STAT = ' R' OR I TAB_SO- I 824810STAT = ' X' . FORMAT COLOR COL_NEGATI VE. ELSEI F I TAB_SO- I 824810STAT = ' N' . FORMAT COLOR COL_NEGATI VE. ELSEI F I TAB_SO- I 824810STAT = ' A' . FORMAT COLOR COL_ POSI TI VE. ELSE. FORMAT COLOR COL_TOTAL. ENDI F. 824 f or 810 Stat us WRI TE: / 10 ' 824 f or 810: ' , I TAB_SO- I 824810STAT.
MOVE I TAB_ SO- I 824856STAT TO T_STAT. HI DE T_ STAT. * 824 f or 810 I Doc Number WRI TE: I TAB_ SO- I 824810DOCNUM. HI DE I TAB_ SO- I 824810DOCNUM. * 824 f or 810 I Doc Dat e WRI TE: I TAB_ SO- I 824810DATE, * 824 f or 810 Err or Text I TAB_ SO- I 824810NOTE. MOVE I TAB_ SO- I 824810DOCNUM TO T_ I DOC. HI DE T_I DOC. FORMAT COLOR OFF. ENDI F. ENDI F. CLEAR I TAB_ SO. ENDI F. ENDLOOP. ULI NE. * Per f or m t he downl oad of t he f i l e I F P_DOWN = ' X' . PERFORM DOWNLOAD_FI LE TABLES I TAB_SO USI NG P_FI LE. ENDI F. ENDFORM. " PRI NT_I TAB * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m GET_I DOC_MESTYP * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Loop t hrough t he i nter nal t abl e and check t he message t ype * r et ur ni ng onl y t he l at est ones. *----------------------------------------------------------------------* * - - >I TAB_LI NKED_I DOCS Li st of I Docs l i nked t o Document *----------------------------------------------------------------------* FORM GET_ I DOC_MESTYP TABLES I TAB_L I NKED_I DOCS STRUCTURE SWW_CONTOB USI NG VALUE( OBJ ECT_TYPE) T_LI NE LI KE VBAP- POSNR CHANGI NG T_ VBELN_DOCNUM T_ VBELN_DATE T_824_STAT T_824_NOTE T_824_DATE T_824_DOCNUM. * Tempor ary l ocal dat a DATA: T_ DOCNUM LI KE Z1824HD TYPE Z1824TH TYPE Z1824DT TYPE Z1824TD TYPE T_SEGNUM LI KE H_MESSAGE LI KE L_MESSAGE LI KE T_MESSAGE LI KE T_STATUS LI KE N1 TYPE I .
EDI DC- DOCNUM, Z1824HD, Z1824TH, Z1824DT, Z1824TD, EDI D4- SEGNUM, ZTABLE- I 824856NOTE, ZTABLE- I 824856NOTE, ZTABLE- I 824856NOTE, ZTABLE- I 824856STAT,
" Header t ext " Li ne i t em t ext
DESCRI BE TABLE I TAB_ LI NKED_I DOCS LI NES N1. I F N1 > 1. SORT I TAB_ LI NKED_I DOCS BY OBJ KEY. ENDI F. CASE OBJ ECT_TYPE. WHEN ' LI KP' . "Del i ver y LOOP AT I TAB_LI NKED_I DOCS WHERE OBJ TYPE = ' I DOC' . T_DOCNUM = I TAB_LI NKED_ I DOCS- OBJ KEY. SELECT SI NGLE DOCNUM CREDAT MESTYP FROM EDI DC I NTO ( EDI DC- DOCNUM, EDI DC- CREDAT, EDI DC- MESTYP) WHERE DOCNUM = T_ DOCNUM. I F SY- SUBRC = 0. CASE EDI DC- MESTYP. WHEN ' DESADV' . " Out bound del i ver y T_VBELN_ DOCNUM = EDI DC- DOCNUM. T_VBELN_ DATE = EDI DC- CREDAT. WHEN ' ZAPPADV856' OR ' ZAPPADV' . " 824 Si gnal r epsonse t o 856 SELECT * FROM EDI D4 WHERE DOCNUM = EDI DC- DOCNUM AND SEGNAM = ' Z1824DT' . MOVE EDI D4- SDATA TO Z1824DT. I F Z1824DT-POLI NE <> T_LI NE. "Not r el evant f or t hi s l i ne CONTI NUE.
ELSE. "Found 824 f or t hi s l i ne i t em T_ 824_DOCNUM = EDI DC- DOCNUM. T_824_DATE = EDI DC- CREDAT. ENDI F. ENDSELECT. ENDCASE. ENDI F. ENDLOOP. WHEN ' VBRK' . " I nvoi ce LOOP AT I TAB_LI NKED_I DOCS WHERE OBJ TYPE = ' I DOC' . T_DOCNUM = I TAB_LI NKED_ I DOCS- OBJ KEY. SELECT SI NGLE DOCNUM CREDAT MESTYP FROM EDI DC I NTO ( EDI DC- DOCNUM, EDI DC- CREDAT, EDI DC- MESTYP) WHERE DOCNUM = T_ DOCNUM. I F SY- SUBRC = 0. CASE EDI DC- MESTYP. WHEN ' I NVOI C' . " Out bound del i very T_VBELN_ DOCNUM = EDI DC- DOCNUM. T_VBELN_ DATE = EDI DC- CREDAT. WHEN ' ZAPPADV810' OR ' ZAPPADV' . " 824 Si gnal r epsonse t o 810 SELECT * FROM EDI D4 WHERE DOCNUM = EDI DC- DOCNUM AND SEGNAM = ' Z1824DT' . MOVE EDI D4- SDATA TO Z1824DT. I F Z1824DT-POLI NE <> T_LI NE. "Not r el evant f or t hi s l i ne CONTI NUE. ELSE. "Found 824 f or t hi s l i ne i t em T_ 824_DOCNUM = EDI DC- DOCNUM. T_824_DATE = EDI DC- CREDAT. ENDI F. ENDSELECT. ENDCASE. ENDI F. ENDLOOP. ENDCASE.
* Check st at us of t he 824 I Docs I F T_824_DOCNUM I S I NI TI AL. " No 824 l i nked t o Document T_824_NOTE = ' No 824 r ecei ved' . T_824_STAT = ' N' . ELSE. SELECT SI NGLE * FROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND SEGNAM = ' Z1824HD' . I F SY- SUBRC = 0. MOVE EDI D4- SDATA TO Z1824HD. CASE Z1824HD- ACKCODE. WHEN ' TA' . "Tr ansact i on accepted H_MESSAGE = ' OK' . L_MESSAGE = ' OK' . T_STATUS = ' A' . WHEN ' TR' . "Tr ansacti on r ej ect ed * Header t ext SELECT SI NGLE * FROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND SEGNAM = ' Z1824TH' . I F SY- SUBRC = 0. MOVE EDI D4- SDATA TO Z1824TH. H_ MESSAGE = Z1824TH- LI NE. ELSE. H_ MESSAGE = ' No header er r or t ext segment Z1824TH' . ENDI F. "Sear ch f or Text header SELECT * F ROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND SEGNAM = ' Z1824DT' . MOVE EDI D4- SDATA TO Z1824DT. I F Z1824DT- POLI NE = T_LI NE. T_SEGNUM = EDI D4- SEGNUM. I F Z1824DT- ACKCODE = ' I A' . "I t emaccepted L_MESSAGE = ' OK' . T_STATUS = ' A' . EXI T. ELSEI F Z1824DT- ACKCODE = ' I C' . "I t em accepted but changed T_STATUS = ' C' . * Li ne i t em t ext f or t hat l i ne i t em number SELECT SI NGLE * FROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND
PSGNUM = T_ SEGNUM AND SEGNAM = ' Z1824TD' .
I F SY- SUBRC = 0. MOVE EDI D4- SDATA TO Z1824TD. L_ MESSAGE = Z1824TD- LI NE. ELSE. L_MESSAGE = ' No er r or t ext f or l i ne i t em i n Z1824TD' . ENDI F. EXI T. ELSE. T_STATUS = ' R' . * Li ne i t em t ext f or t hat l i ne i t em number SELECT SI NGLE * FROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND PSGNUM = T_ SEGNUM AND SEGNAM = ' Z1824TD' . I F SY- SUBRC = 0. MOVE EDI D4- SDATA TO Z1824TD. L_ MESSAGE = Z1824TD- LI NE. ELSE. L_MESSAGE = ' No er r or t ext f or l i ne i t em i n Z1824TD' . ENDI F. EXI T. ENDI F. " I t emaccepted ELSE. "Wr ong l i ne i t em CONTI NUE. ENDI F. ENDSELECT. " Sel ect on Z1824TD I F SY- SUBRC <> 0. L_MESSAGE = ' No i t emdet ai l s i n 824! ' . * Header t ext SELECT SI NGLE * FROM EDI D4 WHERE DOCNUM = T_ 824_ DOCNUM AND SEGNAM = ' Z1824TH' . I F SY- SUBRC = 0. MOVE EDI D4- SDATA TO Z1824TH. H_MESSAGE = Z1824TH- LI NE. ELSE. H_MESSAGE = ' No header err or t ext ' . ENDI F. ENDI F. * T_STATUS = ' R' . ENDCASE. CONCATENATE H_ MESSAGE ' | ' L_ MESSAGE I NTO T_ MESSAGE. T_824_ NOTE = T_MESSAGE. T_824_ STAT = T_STATUS. ELSE. T_824_ NOTE = ' No Li ne i t em det ai l segment i n 824' . T_STATUS = ' X' . ENDI F. ENDI F. ENDFORM. " GET_ I DOC_MESTYP * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m DOWNLOAD_FI LE * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Update col umn headi ngs and per f orm downl oad t o f i l e. *----------------------------------------------------------------------* * - - >I TAB_SO ZTABLE t abl e * - - >P_FI LE Fi l e name f or downl oad *----------------------------------------------------------------------* FORM DOWNLOAD_ FI LE TABLES I TAB_SO STRUCTURE I TAB_SO USI NG P_FI LE. *** Popul ate I t abs f or downl oad * Col umn names MOVE ' Cl i ent ' TO T_COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' PO Number ' TO T_ COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' PO Li ne Number ' TO T_ COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' SO Number ' TO T_ COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' PO Dat e' TO T_ COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' Cust omer ' TO T_COLNAMES- NAME. APPEND T_ COLNAMES. MOVE ' Del i ver y Dat e' TO T_COLNAMES- NAME.
T_ COLNAMES. Del i ver y I Doc Number ' TO T_COLNAMES- NAME. T_ COLNAMES. Del i ver y Number ' TO T_ COLNAMES- NAME. T_ COLNAMES. 824 St at us f or 856' TO T_COLNAMES- NAME. T_ COLNAMES. 824 Dat e f or 856' TO T_ COLNAMES- NAME. T_ COLNAMES. 824 I Doc f or 856' TO T_COLNAMES- NAME. T_ COLNAMES. 824 Not e f or 856' TO T_ COLNAMES- NAME. T_ COLNAMES. I nvoi ce Dat e' TO T_COLNAMES- NAME. T_ COLNAMES. I nvoi ce I Doc Number ' TO T_COLNAMES- NAME. T_ COLNAMES. I nvoi ce Number ' TO T_COLNAMES- NAME. T_ COLNAMES. I nvoi ce Pr i ce' TO T_COLNAMES- NAME. T_ COLNAMES. 824 St at us f or 810' TO T_COLNAMES- NAME. T_ COLNAMES. 824 Dat e f or 810' TO T_ COLNAMES- NAME. T_ COLNAMES. 824 I Doc f or 810' TO T_COLNAMES- NAME. T_ COLNAMES. 824 Not e f or 810' TO T_ COLNAMES- NAME. T_ COLNAMES.
* Wr i t e dat a i n i nt ernal t abl e I TAB_SO t o fi l e speci f i ed i n par ameters CALL FUNCTI ON ' WS_ DOWNLOAD' EXPORTI NG FI LENAME = P_FI LE FI LETYPE = ' DAT' TABLES DATA_ TAB = I TAB_SO FI ELDNAMES = T_ COLNAMES EXCEPTI ONS FI LE_ OPEN_ ERROR =1 FI LE_WRI TE_ERROR =2 I NVALI D_FI LESI ZE =3 I NVALI D_ TABLE_WI DTH =4 I NVALI D_TYPE =5 NO_BATCH =6 UNKNOWN_ERROR =7 GUI _REFUSE_FI LETRANSFER = 8 OTHERS = 9. I F SY- SUBRC = 0. ELSEI F SY- SUBRC = 1. MESSAGE I 027( Z3) WI TH P_FI LE. ELSEI F SY- SUBRC = 2. MESSAGE I 028( Z3) WI TH P_FI LE. ELSEI F SY- SUBRC = 3. MESSAGE I 001( Z4) WI TH P_FI LE. ELSEI F SY- SUBRC = 4. MESSAGE I 002( Z4) WI TH P_FI LE. ELSEI F SY- SUBRC = 5. MESSAGE I 003( Z4) WI TH P_FI LE. ELSEI F SY- SUBRC = 6. MESSAGE I 004( Z4) WI TH P_FI LE. ELSEI F SY- SUBRC = 7. MESSAGE I 005( Z4) WI TH P_FI LE. ELSEI F SY- SUBRC = 8. MESSAGE I 006( Z4) WI TH P_FI LE. ELSE. MESSAGE I 007( Z4) WI TH P_FI LE. ENDI F. ENDFORM. " DOWNLOAD_ FI LE * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m SAVE_BI LLI NG_DOC * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Loop thr ough the i nt ernal t abl e set up t o st ore t he i nvoi ce number s * of t hose i nvoi ces t hat do not have I NVOI C I docs at t ached t o t hem. * i . e. The ZD01 out put was not cr eat ed f or some r eason. * By savi ng the i nvoi ce (whi ch i s what t hi s progr am does) t he out put
* s houl d be generat ed. *----------------------------------------------------------------------* * - - >TI TAB St ores i nvoi ce number s of t hose i nvoi ces t hat do not * have I NVOI C I Docs l i nked t o t hem. *----------------------------------------------------------------------* FORM SAVE_BI LLI NG_DOC TABLES TI TAB STRUCTURE TI TAB. DATA: N TYPE I . LOOP AT TI TAB. SUBMI T ZVF02SAVE WI TH BI LLI NG = TI TAB- O810 AND RETURN. MESSAGE I 009( Z4) WI TH TI TAB- O810. ENDLOOP. I F SY- SUBRC = 0. DESCRI BE TABLE TI TAB LI NES N. MESSAGE I 008( Z4) WI TH N. ENDI F. ENDFORM. " SAVE_BI LLI NG_DOC
7.10.5
Example upload fil e to IDoc
REPORT ZS7BM000005 message- i d ZS7. *__________________________________________________ ____________________ */ Program Name: Cr eat i on of ORDRSP I Docs f r om f i l e E020 */ Descri pt i on : Thi s pr ogr amr eads i n external f i l e E020 cont ai ni ng * order conf i r mati on data f r omi nt ernal vendors and * cr eat es one ORDRSP I Doc per PO. */ Transacti on : n/ a - r un f r omj ob Z_ccc_S7B_Dnnnnn, * wher e ' c cc ' = 3- di gi t c l i ent and ' nnnnn' = z er o - f i l l ed * sequence number . *__________________________________________________ ____________________ t a bl es : l f a1, e1edk01, e1edk02, e1edp01, e1edp19, e1edp20, e1edp02, e1eds01, zst 7f _t y_vendor s. par ameter s:
p_path l i ke PATH- PATHEXTERN def aul t ' / f t p/ atac/ i n/ ' .
dat a:
I NFI LE back_pat h( 7) i nf o_ no of f s et p01_ctr seg_num
LI KE t ype l i ke l i ke l i ke l i ke
PATH- PATHEXTERN, c val ue ' backup/ ' , ekpo- i nf nr , s y- f dpos , sy- i ndex, sy- i ndex.
dat a:
OUTFI LE LI KE PATH- PATHEXTERN, t oday( 8) t ype c, out f i l e_ er r ( 1 ) t ype c .
dat a:
begi n of uty_vendors occur s 10, l i f nr l i ke l f a1- l i f nr , name_abbr l i ke zst 7f _t y_vendor s- name_abbr, si t e_code l i ke zst7f_ t y_vendors- si t e_code, shi p_days l i ke zst 7f _t y_vendors- shi p_days, end of uty_vendor s.
dat a:
i ZSS7B20 l i ke ZSS7B20.
dat a: dat a:
i docdat a l i ke edi _dd occur s 5 wi t h header l i ne. i edi dc l i ke edi _dc occur s 1 wi t h header l i ne.
dat a:
begi n of i e020 occur s 10, l i f nr l i ke l f a1- l i f nr , shi p_days l i ke zst 7f _t y_vendors- shi p_days, po_number ( 10) t ype n, po_l i neno(5) t ype n, sl i p_number l i ke e1edp02- bel nr, sched_dat e l i ke e1edp02- dat um, "char 8 sched_qt y l i ke e1edp20- wmeng, cust _par t no l i ke e1edp19- i dt nr , vendor_ par t no l i ke e1edp19- mf r pn, sched_del i v_dat e l i ke e1edp20- edat u, " f or mat OK - c cyymmdd uom l i ke e1edp01- menee,
qt y_or der ed end of i e020.
l i ke e1edp01- menge,
dat a: save_po l i ke i e020- po_number , save_l i ne l i ke i e020- po_l i neno, save_vend_par t l i ke i e020-vendor _par t no, save_cust _par t l i ke i e020- cust _part no. *-----------------------------------------------------------------* MAI N PROCESSI NG LOOP *-----------------------------------------------------------------START- OF- SELECTI ON. t oday = sy- dat l o. * f i nd al l i nt ernal vendors s el ec t a ~l i f nr b~name_abbr b~si t e_code b~shi p_days i nt o cor r espondi ng fi el ds of t abl e ut y_vendors f r o m l f a1 as a i nner j oi n zst 7f _t y_vendor s as b on a~l i f nr = b~l i f nr wher e a~kt okk = ' ZZTY' and b~shi p_code = ' ' . concat enate ' SAP' sy-sysi d( 3) i nt o i edi dc- sndpor. * i ni t i al i z e c ont r ol r e cor d: move: ' 2' t o i edi dc- di rect, ' ORDERS01' t o i edi dc- doctyp, ' ORDRSP' t o i edi dc- mest yp, ' F' t o i edi dc - s t d, ' E020' t o i edi dc- st dmes, ' L S' t o i edi dc - s ndpr t , ' TY_VENDORS' t o i edi dc- sndprn, sy- dat l o t o i edi dc- credat , sy- t i ml o t o i edi dc- creti m. append i edi dc. e1edk01- act i on = ' 000' . l oop at ut y_vendors. cl ear i e020. ref resh i e020. i f not ut y_vendors- name_abbr i s i ni t i al . * dat af i l es ar e recei ved wi t h nami ng convent i on: * E020__ UTY concat enat e p_path ' E020_' uty_vendor s- name_abbr ' _UTY' i nt o i nf i l e. i f not sy-subrc i s i ni t i al . "pat hname t oo l ong * Fi l ename t oo l ong: & message w016 wi t h i nf i l e. cont i nue. endi f . condense i nf i l e. OPEN DATASET I NFI LE F OR I NPUT I N TEXT MODE. i f not s y- s ubr c i s i ni t i al . *' Cannot open dat aset & on &' message i 013 wi t h i nf i l e sy- datum. el se. "successful f i l e open concat enate p_path back_pat h ' E020_' ut y_vendor s- name_abbr ' _UTY' t oday i nt o out f i l e. i f not sy-subr c i s i ni t i al . "pat hname t oo l ong * Fi l ename t oo l ong: & message w016 wi t h outf i l e. cont i nue. endi f . condense out f i l e. OPEN DATASET OUTFI LE FOR OUTPUT I N TEXT MODE. * i f t he t i mestamped f i l e cannot be created, do not pr ocess t he * i nput f i l e, because t he i nput f i l e i s del et ed af t er processi ng, * and t her e woul d be no r ecor d of t he dat a.
i f not s y- s ubr c i s i ni t i al . *' ERROR openi ng f i l e & f or out put ' c l os e dat as et i nf i l e. message i 033 wi t h out f i l e. cont i nue. "process next vendor ' s f i l e endi f . do. r ead dat aset i nf i l e i nt o i zss7b20. case sy-subr c. when 0. t r ansf er i zss7b20 t o out f i l e. i f i z s s7b20- dat a code = ' T' . " t r a i l er r ec per f or m pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor' s f i l e endi f . check i zss7b20- dat acode = ' D' . "dat a r ec move- corr espondi ng uty_vendor s t o i e020. move- corr espondi ng i zss7b20 t o i e020. perf orm conver t _po_no usi ng i zss7b20- pono_pol i ne changi ng i e020- po_number i e020- po_l i neno. perf orm conver t _dat e usi ng i zss7b20-sched_dat e i zss7b20- sched_t ype i zss7b20- shi p_met hod changi ng i e020- sched_dat e i e020-shi p_days i e020- sched_del i v_dat e. perf orm convert _quant i t i es usi ng i zss7b20- uom i zss7b20- sched_qt y i zss7b20- qt y_order ed changi ng i e020- uom i e020- sched_qt y i e020- qt y_order ed. append i e020. when 4. " EOF perf orm pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor ' s f i l e when ot her s. * ERROR r eadi ng dat aset & on & message w015 wi t h i nf i l e sy- dat um. exi t . " di s cont i nue f i l e r e ads endcase. enddo. c l os e dat a set : i nf i l e, out f i l e. del et e dat a s et i nf i l e. endi f . endi f . endl oop. " UTY_VENDORS * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m process _one_vendor * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Recor ds f r om one vendor f i l e ar e now i n t he i nt er nal tabl e * i e020. *----------------------------------------------------------------------* FORM pr ocess_one_vendor usi ng val ue( i nf i l e). sor t i e020 by po_number po_l i neno. l oop at i e020. i f s y- t abi x > 1. i f ( i e020- po_number <> save_po or i e020- po_l i neno <> save_l i ne ) . per f or m i doc_mat _seg. endi f . endi f . i f i e020- po_number <> save_po. i f s y- t abi x > 1. per f or m post_prev_i doc. endi f . per f orm i doc_header _segs. endi f . i f ( i e020- po_number <> save_po or i e020- po_l i neno <> save_l i ne ) . i f s y- t abi x > 1. per f or m i doc_i t em_segs. endi f .
endi f . perf orm i doc_sched_segs. save_po = i e020- po_number . save_l i ne = i e020- po_l i neno. save_vend_par t = i e020- vendor _par t no. save_cust _par t = i e020- cust _par t no. endl oop. per f or m i doc_mat_seg. perf orm post_prev_i doc. * Fi l e successf ul l y pr ocessed: & message s035 wi t h i nfi l e. ENDFORM.
" pr oces s_ one_vendor
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form conver t _po_no * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * text *----------------------------------------------------------------------* FORM conver t _po_no usi ng val ue( i nf i el d) changi ng po_number l i ke i e020- po_number po_l i ne l i ke i e020- po_l i neno. dat a:
cpos l i ke sy- f dpos, l pos l i ke sy- f dpos , c l i ne( 6 ) t ype c.
* i f t he i nfi el d cont ai ns a hyphen, assume that t he pr ecedi ng charact ers * r epr esent t he po number , i f t hey ar e numeri c. The po l i ne number i s * assumed t o be al l numeri c char act ers af t er t he hyphen. i f i nf i el d ca ' - ' . i f i nf i el d( sy-f dpos) co ' 0123456789' . "numer i c po_number = i nf i el d( sy- f dpos). cpos = sy- f dpos + 1. endi f . el se. "no hyphen - PTY i f i nf i el d( 2) = ' 71' . "SAP number range cpos = 10. el se. " Syt eLi ne number cpos = 6. endi f . i f i nf i el d( cpos) co ' 0123456789' . "numer i c po_number = i nf i el d( cpos) . endi f . endi f . i f not po_ number i s i ni t i al . whi l e i nf i el d+cpos(1) co ' 0123456789' . cl i ne+l pos(1) = i nf i el d+cpos(1). l pos = l pos + 1. cpos = cpos + 1. endwhi l e. s hi f t c l i ne l ef t d el et i ng l eadi ng ' 0' . i f not c l i ne i s i ni t i al . po_ l i ne = c l i ne. endi f . endi f . * Put out a warni ng i n the j ob l og, but cr eat e the I Doc to save the data i f ( po_ number i s i ni t i al or po_ l i ne i s i ni t i al ) . * PO number - l i ne i t emconver si on f ai l ed: & message w016 wi t h i nf i el d. endi f . ENDFORM.
" conver t _po_no
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form conver t _date * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Conver t yymmdd t o cc yymmdd f or SAP and * conver t shi p dat e t o del i ver y dat e *----------------------------------------------------------------------* FORM conver t _dat e USI NG val ue( DATE6) val ue( DATE_TYPE) val ue( i _shi p_code) CHANGI NG DATE8
l i ke I E020- SCHED_ DATE
SHI P_DAYS l i ke i e020- shi p_days DELI VERY_DATE l i ke i e020- sched_del i v_dat e. dat a:
cent ( 2) type c, d_dat e t ype d.
* add cent ury t o schedul e dat e check dat e6 cn ' / 0' . i f dat e6( 2) < ' 90' . cent = ' 20' . el s e. cent = ' 19' . endi f . concat enat e cent dat e6 i nto dat e8. * conver t shi p date to del i ver y dat e (i f necessar y) i f dat e_type <> ' ETA' . " del i ver y dat e not sent i f not i _shi p_code i s i ni t i al . "shi p met hod sent sel ect si ngl e shi p_days f r omzst 7f _t y_vendor s i nt o shi p_days wher e l i f nr = i e020- l i f nr and shi p_code = i _shi p_code. endi f . * def aut shi p_days ar e passed i n and wi l l be changed onl y * i f a number speci f i c t o the shi ppi ng method i s f ound i n * t he sel ect above i f ( shi p_days > 0 and not d el i ver y _ dat e i s i ni t i al ) . * put t he date i nto a date f i el d, so SAP wi l l do dat e math d_dat e = del i ver y_dat e. d_dat e = d_dat e + shi p_days. del i ver y_date = d_dat e. s hi f t d el i ver y _ dat e l ef t d el et i ng l eadi ng ' ' . endi f . endi f . ENDFORM.
" conver t _dat e
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m quant i t y_conver si on * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * The quant i t i es i n t he i nput f i l e are i mpl i ed 3- deci mal , * so need t o be conver t ed i nto a "r eal " number . * Al so, t he uni t of measure may be ' KP' i ndi cati ng t hat t he qt y * i s gi ven i n t housands. *----------------------------------------------------------------------* FORM conver t _quant i t i es USI NG val ue( i _UOM) val ue( i _conf i r m_qt y) val ue( i _QTY_ORDERED) CHANGI NG o_uom l i ke i E020- UOM o_conf i r m_qt y l i ke I E020- SCHED_QTY o_qt y_or der ed l i ke I E020- QTY_ORDERED. const ant s: t hou t ype p deci mal s 3 val ue ' 1000' . dat a:
n_conf i r m_qt y l i ke ekpo- menge, n_qt y_ordered l i ke ekpo- menge.
i f ( i _conf i r m_qty co ' 0123456789' and i _ c onf i r m_ qt y c n ' 0' ) . n_conf i r m_qty = i _conf i r m_qty. n_conf i r m_qty = n_conf i r m_qty / t hou. endi f . i f ( i _qt y_or dered co ' 0123456789' and i _ qt y_ or d er e d c n ' 0' ) . n_qty_or dered = i _qty_or der ed. n_qty_or dered = n_qty_or dered / t hou. endi f . i f i _ uom = ' KP' . n_conf i r m_qty = n_conf i r m_qty / t hou. n_qty_or dered = n_qty_or dered / t hou. endi f . o_ uom = ' PCE' . i f not n_ conf i r m_ qt y i s i ni t i al .
o_conf i r m_qty = n_conf i r m_qty. shi f t o_conf i rm_qt y l ef t del et i ng l eadi ng space. el s e. cl ear o_conf i r m_qty. endi f . i f not n_ qt y _ or der e d i s i ni t i al . o_qt y_order ed = n_qty_or dered. shi f t o_qt y_or dered l ef t del eti ng l eadi ng space. el s e. cl ear o_qt y_or dered. endi f . ENDFORM.
" conver t _quant i t i es
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form i doc_header _segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * cr eat e i nter nal t abl e ent r i es f or PO header segment s: * E1EDK01 * E1EDK02 *----------------------------------------------------------------------* FORM i doc_header _segs. cl ear seg_num. i docdata- segnam= ' E1EDK01' . i docdata- sdata = e1edk01. per f or m append_i doc_r ec. cl ear e1edk02. i docdata- segnam= ' E1EDK02' . e1edk02- qual f = ' 001' . e1edk02- bel nr = i e020- po_number . i docdata- sdata = e1edk02. per f or m append_i doc_r ec. ENDFORM.
" i doc_header _ segs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m i doc_i t em_segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e i nt er nal t abl e ent r i es f or PO i t em header segment s: * E1EDP01 * E1EDP02 *----------------------------------------------------------------------* FORM i doc_i t em_segs. cl ear e1edp01. i docdata- segnam= ' E1EDP01' . e1edp01- menee = i e020- uom. e1edp01- menge = i e020- qty_ ordered. i docdata- sdata = e1edp01. per f or m append_i doc_r ec. cl ear e1edp02. i docdata- segnam= ' E1EDP02' . e1edp02- qual f = ' 001' . e1edp02- bel nr = i e020- po_number . e1edp02- zei l e = i e020- po_l i neno. i docdata- sdata = e1edp02. per f or m append_i doc_r ec. i docdata- segnam= ' E1EDP02' . cl ear e1edp02. e1edp02- qual f = ' 002' . e1edp02-bel nr = i e020- sl i p_number . e1edp02-datum = i e020- sched_dat e. i docdata- sdata = e1edp02. per f or m append_i doc_r ec. p01_ctr = p01_ctr + 1. ENDFORM.
" i doc_i t em_s egs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form i doc_sched_segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e i nt er nal t abl e ent r i es f or PO i t em schedul e segment s: * E1EDP20
*----------------------------------------------------------------------* FORM i doc_s ched_segs. cl ear e1edp20. i docdata- segnam= ' E1EDP20' . e1edp20-edat u = i e020- sched_del i v_date. e1edp20- wmeng = i e020- sched_qt y. i docdata- sdata = e1edp20. per f or m append_i doc_r ec. ENDFORM.
" i doc_s ched_segs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form i doc_mat _seg * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e i nt er nal t abl e ent r i es f or PO i t em materi al no. segment s: * E1EDP19 *----------------------------------------------------------------------* FORM i doc_mat_ seg. t abl es:
ekpo.
cl ear e1edp19. i docdata- segnam= ' E1EDP19' . e1edp19- qual f = ' 002' . e1edp19-i dt nr = save_vend_par t . e1edp19- mf r pn = save_cust _part . i docdata- sdata = e1edp19. per f or m append_i doc_r ec. cl ear e1edp19. sel ect si ngl e mat nr f r omekpo i nt o e1edp19- i dt nr wher e ebel n = save_po and ebel p = save_l i ne. i f not e1edp19- i dt n r i s i ni t i al . i docdata- segnam = ' E1EDP19' . e1edp19- qual f = ' 001' . i docdata- sdat a = e1edp19. perf orm append_i doc_r ec. endi f . ENDFORM.
" i doc_ mat _ seg
*************************************************** ******************** *& For m post_ prev_i doc * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e a dat abase i doc f r om t he i docdat a t abl e and cl ear t abl e. *----------------------------------------------------------------------* FORM post _prev_i doc. cl ear e1eds01. i docdata- segnam= ' E1EDS01' . e1eds01-s umi d = ' 001' . e1eds01- summe = p01_ct r . shi f t e1eds01- summe l ef t del eti ng l eadi ng space. i docdata- sdata = e1eds01. per f or m append_i doc_r ec. CALL FUNCTI ON ' I NBOUND_ I DOC_PROCESS' TABLES I DOC_ CONTROL = i edi dc I DOC_DATA = i docdata. commi t wor k. r ef r esh i docdat a. c l ear : i docdat a, p01_ctr , save_po, save_l i ne, save_vend_part , save_cust _par t . ENDFORM.
*& Form append_i doc_r ec * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * add a data r ecor d t o t he I Doc i nt ernal t abl e *----------------------------------------------------------------------* FORM append_i doc_r ec. i docdata- t abnam= i docdata- segnam. seg_num = seg_num + 1. i docdat a- segnum = seg_num. shi f t i docdat a- segnum l ef t del et i ng l eadi ng space. append i docdat a. cl ear i docdat a. ENDFORM.
7.10.6
" append_i doc_r ec
IDoc creation from inbound file
REPORT ZS7BM000006 message- i d ZS7. *__________________________________________________ ____________________ */ Program Name: Cr eat i on of DESADV & I NVOI C I Docs f r om f i l e E021 */ Descri pt i on : Thi s pr ogr amr eads i n external f i l e E021 cont ai ni ng * shi ppi ng and i nvoi ce dat a f r omi nter nal vendor s and * cr eat es one DESADV and one I NVOI C I Doc per i nvoi ce. */ Transacti on : n/ a - r un f r omj ob Z_ccc_S7B_Annnnn, where * ' c cc ' = 3- di gi t c l i ent and ' nnnnn' = z er o - f i l l ed * sequence number mat chi ng t he schedul ed j ob f or E020. *__________________________________________________ ____________________ t a bl es : l f a1, l f m1, ekpo, ei ne, e1edk01, e1edk02, e1edk07, e1edk08, e1edk06, e1edk03, e1edka1, e1edka2, e1edp07, e1edp09, e1edp19, e1edp01, e1edp02, e1edp26, e1edp04, e1eds01, e1eds02, zst 7f _t y_vendor s. par amet er s:
p_pat h l i ke PATH- PATHEXTERN def aul t ' / f t p/ at ac/ i n/ ' .
dat a:
I NFI LE LI KE PATH- PATHEXTERN, back_pat h( 7) t ype c val ue ' backup/ ' , of f s et l i k e s y- f dpos , p07_ctr l i ke sy- i ndex, i nvoi ce_t otal t ype p deci mal s 3, d_seg_num l i ke sy- i ndex, i _seg_num l i ke sy- i ndex.
dat a:
OUTFI LE LI KE PATH- PATHEXTERN, t oday( 8) t ype c.
dat a:
begi n of uty_vendors occur s 10, l i f nr l i ke l f a1- l i f nr , waer s l i ke l f m1-waer s, name_abbr l i ke zst 7f _t y_vendor s- name_abbr, shi p_days l i ke zst 7f _t y_vendors- shi p_days, end of uty_vendor s.
dat a:
i ZSS7B21 l i ke ZSS7B21.
dat a: dat a: dat a: dat a:
desadvdata l i nvoi cdat a l dedi dc l i ke i edi dc l i ke
i ke edi i ke edi edi _dc edi _dc
_dd occur s _dd occur s occur s 1 wi occur s 1 wi
5 wi t h header l i ne. 5 wi t h header l i ne. t h header l i ne. t h header l i ne.
dat a:
begi n of i e021 occur s 10, l i f nr l i ke l f a1- l i f nr , shi p_days l i ke zst 7f _t y_vendors- shi p_days, i nvoi ce_no l i ke e1edk08- vbel n, st at l i ke e1edk01- act i on, po_number ( 10) t ype n, po_l i neno(5) t ype n, sl i p_number l i ke e1edp09- vbel n, shi pt o_i d l i ke e1edka1- par t n, vendor_i d l i ke e1edka1- par t n, endcust _name l i ke e1edka1- name1, cust _part no l i ke e1edp09- kdmat , "char 35 vendor_ par t no l i ke e1edp09- matnr , " char 35 i nvoi ce_qty l i ke e1edp09- l f i mg, qty_ uom l i ke e1edp01- menee, uni t _pri ce l i ke e1edp01- vprei , pri ce_uom l i ke e1edp01- pmene, pr i ce_qty l i ke e1edp01- pei nh, l i ne_amount l i ke e1edp26- bet r g, cur r ency l i ke e1edk01- cur cy, et d l i ke e1edk06- dat um, "s hi p dat e eta l i ke e1edk06- dat um, "del i ver y date shi p_i d l i ke e1edk08- t rai d, shi p_method l i ke e1edk08- t r aty, cr eat e_dat e l i ke e1edk03- dat um, pl ant l i ke ekpo- wer ks, end of i e021.
dat a: save_po l i ke i e021- po_number , save_l i ne l i ke i e021- po_l i neno, save_stat l i ke i e021- stat, save_i nvoi ce l i ke i e021- i nvoi ce_no. const ant s: hun_t hou t ype p deci mal s 5 val ue ' 100000' , t hou t ype p deci mal s 3 val ue ' 1000' . * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& DEFI NI TI ON: append_i doc_ r ec * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * add a data r ecor d t o t he I Doc i nt ernal t abl e *----------------------------------------------------------------------* def i ne append_i doc_rec. &1- t abnam = &1- segnam. &2_seg_num = &2_seg_num + 1. &1- segnum = &2_s eg_num. shi f t &1- segnum l ef t del eti ng l eadi ng space. append &1. cl ear &1. end- of - defi ni t i on.
" append_i doc_r ec
*-----------------------------------------------------------------* MAI N PROCESSI NG LOOP *-----------------------------------------------------------------START- OF- SELECTI ON. t oday = sy- datum. * f i nd al l i nt ernal vendors s el ec t a ~l i f nr b~waer s c~name_abbr c~shi p_days i nt o cor r espondi ng fi el ds of t abl e ut y_vendors f r o m l f a1 as a i nner j oi n l f m1 as b on a~l i f nr = b~l i f nr i nner j oi n zst 7f _t y_vendor s as c on a~l i f nr = c ~l i f nr wher e a~kt okk = ' ZZTY' and b~ekor g = ' 7100' and c~shi p_code = ' ' . per f or m i ni t _desadv.
per f or m i ni t _ i nvoi c . concat enate ' SAP' sy-sysi d( 3) i nt o: i edi dc- sndpor , dedi dc- sndpor. l oop at ut y_vendors. cl ear i e021. ref resh i e021. i f not ut y_vendors- name_abbr i s i ni t i al . * dat af i l es ar e recei ved wi t h nami ng convent i on: * E020__ UTY concat enat e p_path ' E021_' uty_vendor s- name_abbr ' _UTY' i nt o i nf i l e. i f not sy-subrc i s i ni t i al . "pat hname t oo l ong * Fi l ename t oo l ong: & message i 016 wi t h i nf i l e. cont i nue. endi f . condense i nf i l e. OPEN DATASET I NFI LE F OR I NPUT I N TEXT MODE. i f not s y- s ubr c i s i ni t i al . *' Cannot open dat aset & on &' message i 013 wi t h i nf i l e sy- datum. cont i nue. el s e. concat enate p_path back_pat h ' E021_' ut y_vendor s- name_abbr ' _UTY' t oday i nt o out f i l e. i f not sy-subr c i s i ni t i al . "pat hname t oo l ong * Fi l ename t oo l ong: & message i 016 wi t h out f i l e. cont i nue. endi f . condense out f i l e. OPEN DATASET OUTFI LE FOR OUTPUT I N TEXT MODE. * i f t he datest amped f i l e cannot be created, do not pr ocess t he * i nput f i l e, because t he i nput f i l e i s del et ed af t er processi ng, * and t her e woul d be no r ecor d of t he dat a. i f not s y- s ubr c i s i ni t i al . *' ERROR openi ng f i l e & f or out put ' c l os e dat as et i nf i l e. message i 033 wi t h out f i l e. cont i nue. "process next vendor ' s f i l e endi f . do. r ead dat aset i nf i l e i nt o i zss7b21. case sy-subr c. when 0. t r ansf er i zss7b21 t o out f i l e. i f i z s s7b21- dat a code = ' T' . " t r a i l er r ec per f or m pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor' s f i l e endi f . check: i zss7b21- dat acode = ' A' . "dat a rec case i zss7b21- st at us. when ' ' . "new i e021- s t at = ' 000' . when ' M' . "modi f i cati on i e021- s t at = ' 002' . when ' D' . "del et i on i e021- s t at = ' 003' . endcase. move- corr espondi ng uty_vendor s t o i e021. move- corr espondi ng i zss7b21 t o i e021. perf orm conver t _po_no usi ng i zss7b21- pono_pol i ne changi ng i e021- po_number i e021- po_l i neno. perf orm convert _dat es usi ng i e021- l i f nr i zss7b21- etd i zss7b21- eta i zss7b21- shi p_method i zss7b21- cr eat e_date changi ng i e021- et a i e021- shi p_days. perf orm quant i t y_conver si on usi ng i zss7b21- qt y_uom i zss7b21- i nvoi ce_qty
i zss7b21- uni t _pri ce changi ng i e021- qty_uom i e021- i nvoi ce_qty i zss7b21- l i ne_amount . per f orm money_convers i on usi ng i zss7b21- cur r ency i zss7b21- uni t _pri ce i zss7b21- pr i ce_uom i zss7b21- l i ne_amount changi ng i e021- curr ency i e021- pr i ce_uom i e021- pr i ce_qt y i e021- uni t _pri ce i e021- l i ne_amount . per f orm SAP_vendor_ par t no changi ng i e021- cust _par t no. append i e021. when 4. " EOF perf orm pr ocess_one_vendor usi ng i nf i l e. exi t . "process next vendor ' s f i l e when ot her s. * ERROR r eadi ng dat aset & - & message i 015 wi t h i nf i l e sy- datum. exi t . endcase. enddo. c l os e dat a set : i nf i l e, out f i l e. del et e dat a s et i nf i l e. endi f . endi f . endl oop. " UTY_VENDORS * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m process _one_vendor * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Pre- pr ocessed r ecor ds f r omone vendor f i l e are now i n t he * i nt er nal t abl e i e021 - r eady t o creat e I Docs *----------------------------------------------------------------------* FORM pr ocess_one_vendor usi ng val ue( i nf i l e). sort i e021 by i nvoi ce_no st at po_number po_l i neno. l oop at i e021. i f ( i e021- i nvoi ce_no <> save_i nvoi ce or i e021- stat <> save_stat ) . i f s y- t abi x > 1. per f or m post_i docs usi ng i e021- stat. endi f . per f orm i doc_header _segs usi ng i e021- st at . endi f . i f ( i e021- stat <> save_stat or i e021- po_number <> save_po or i e021- po_l i neno <> save_l i ne or i e021- i nvoi ce_no <> save_i nvoi ce ) . i f ( s y- t a bi x > 1 and i e021- s t at = ' 000' ) . per f orm i doc_poheader_s egs. endi f . endi f . perf orm i doc_i t em_segs usi ng i e021- st at. save_po = i e021- po_number . save_l i ne = i e021- po_l i neno. save_i nvoi ce = i e021- i nvoi ce_no. save_st at = i e021- stat. endl oop. perf orm post_i docs usi ng i e021- stat. * Fi l e successf ul l y pr ocessed: & message s035 wi t h i nfi l e. ENDFORM.
" pr oces s_ one_vendor
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form conver t _po_no * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Br eak t he PO number & l i ne f i el d i nt o separat e f i el ds *----------------------------------------------------------------------* FORM conver t _po_no usi ng val ue( i nf i el d) changi ng po_number l i ke i e021- po_number
po_l i ne l i ke i e021- po_l i neno. dat a:
cpos l i ke sy- f dpos, l pos l i ke sy- f dpos , c l i ne( 6 ) t ype c.
* i f t he i nfi el d cont ai ns a hyphen, assume that t he pr ecedi ng charact ers * r epr esent t he po number , i f t hey ar e numeri c. The po l i ne number i s * assumed t o be al l numeri c char act ers af t er t he hyphen. i f i nf i el d ca ' - ' . i f i nf i el d( sy-f dpos) co ' 0123456789' . "numer i c po_number = i nf i el d( sy- f dpos). cpos = sy- f dpos + 1. endi f . el se. "no hyphen - PTY i f i nf i el d( 2) = ' 71' . "SAP number range cpos = 10. el se. " Syt eLi ne number cpos = 6. endi f . i f i nf i el d( cpos) co ' 0123456789' . "numer i c po_number = i nf i el d( cpos) . endi f . endi f . i f not po_ number i s i ni t i al . whi l e i nf i el d+cpos(1) co ' 0123456789' . cl i ne+l pos(1) = i nf i el d+cpos(1). l pos = l pos + 1. cpos = cpos + 1. endwhi l e. s hi f t c l i ne l ef t d el et i ng l eadi ng ' 0' . i f not c l i ne i s i ni t i al . po_ l i ne = c l i ne. endi f . endi f . * Put out a warni ng i n the j ob l og, but cr eat e the I Doc to save the data i f ( po_ number i s i ni t i al or po_ l i ne i s i ni t i al ) . * PO number - l i ne i t emconver si on f ai l ed: & message i 034 wi t h i nf i el d. endi f . ENDFORM. " conver t _po_no * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form conver t _dates * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Conver t shi p dat e t o del i ver y dat e, i f necessar y *----------------------------------------------------------------------* FORM conver t _dates usi ng val ue( vendor_ no) val ue( i _shi p_dat e) val ue( i _del i very_dat e) val ue( i _shi p_code) val ue( i _cr eat e_date) changi ng o_del i ver y_date shi p_days. dat a: * * * *
shi p_date t ype d.
i f del i very dat e not sent , cal cul at e i t f r om shi p dat e pl us shi p days. Not e that t hi s l ogi c coul d l eave del i ver y dat e bl ank, i f shi p dat e i s not numer i c. i f ( i _ del i ver y_ dat e i s i ni t i al or i _del i very_dat e co ' 0' ) . "no del i very dat e sent i f ( i _shi p_dat e co ' 0123456789' and i _shi p_dat e cn ' 0' ). "shi p dat e sent * move the shi p dat e i nto a dat e f i el d to add days shi p_dat e = i _shi p_dat e. el sei f ( i _cr eat e_date co ' 0123456789' and i _ c r eat e_ dat e c n ' 0' ) . shi p_dat e = i _creat e_dat e. endi f . i f not i _ shi p_ code i s i ni t i al . sel ect si ngl e shi p_days f r omzst 7f _t y_vendor s i nto shi p_days where l i f nr = vendor_no
and shi p_code = i _shi p_code. endi f . i f not s hi p_ dat e i s i ni t i al . i f s hi p_ days > 0. shi p_dat e = shi p_dat e + shi p_days. o_del i ver y_dat e = shi p_dat e. s hi f t o_ del i ver y _ dat e l ef t d el et i ng l eadi ng ' ' . endi f . endi f . el se. "del i ver y dat e sent o_del i very_dat e = i _del i ver y_dat e. endi f . ENDFORM.
" conver t _dat es
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m quant i t y_conver si on * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * The quant i t i es i n t he i nput f i l e are i mpl i ed 3- deci mal , * so need t o be conver t ed i nto a "r eal " number . * Al so, t he uni t of measure may be ' KP' i ndi cati ng t hat t he qt y * i s gi ven i n t housands. *----------------------------------------------------------------------* FORM quant i t y_conver si on USI NG val ue( i _UOM) val ue( i _i nvoi ce_qt y) val ue( i _ uni t _ p r i c e) CHANGI NG o_uom l i ke i E021- qt y_UOM o_i nvoi ce_qty l i ke I E021- I NVOI CE_QTY c_LI NE_AMOUNT l i ke i zss7b21- l i ne_amount. dat a: dat a: dat a: dat a: dat a:
* * *
* *
f _i nvoi ce_qt y t ype f . n_i nvoi ce_qty l i ke l i ps- kcmeng. f _ uni t _ p r i c e t y pe f . f _l i ne_amt type f . n_l i ne_amt 0 t ype p deci mal s 0.
i f ( i _i nvoi ce_qty co ' 0123456789' and i _ i nvoi c e_ qt y c n ' 0' ) . f _ i nvoi c e_ qt y = i _ i nvoi c e_ qt y . i f no ext ended pri ce i s sent , cal cul at e i t i f c _l i ne_ amount i s i ni t i al . t he qt y i s i mpl i ed 3- dec , t h e pr i c e i s s t i l l i mpl i ed 5- dec, and l i ne amount shoul d be i mpl i ed 3- dec. f _ uni t _ pr i c e = i _ uni t _ pr i c e. f _l i ne_amt = ( f _i nvoi ce_qt y * f _uni t _pri ce ) / 100000. n_l i ne_amt 0 = f _l i ne_amt . c_l i ne_amount = n_l i ne_amt 0. shi f t c_l i ne_amount l eft del et i ng l eadi ng space. endi f . i f t he i nvoi ce qt y i s per 1000, t he i mpl i ed 3-dec ti mes 1000 equal s t he unconver t ed val ue. Ot her wi se, di vi de by 1000 t o get t he PCE qt y i f i _ uom = ' KP' . n_i nvoi ce_qt y = f _i nvoi ce_qt y. el s e. n_i nvoi ce_qt y = f _i nvoi ce_qt y / t hou. endi f . endi f . o_ uom = ' PCE' . i f n ot n_ i nvoi c e_ qt y i s i ni t i al . o_i nvoi ce_qt y = n_i nvoi ce_qt y. shi f t o_i nvoi ce_qt y l ef t del et i ng l eadi ng space. el s e. cl ear o_i nvoi ce_qt y. endi f .
ENDFORM.
" quant i t y_conver si on
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m money_conver si on * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * Add t he i mpl i ed deci mal s and st or e pr i ce- per qt y, i f * pr i ce per 1, 000 i s sent . *----------------------------------------------------------------------* FORM money_c onver si on USI NG val ue( I _ CURR) val ue(i _UNI T_PRI CE)
val ue( i _UOM) val ue( i _LI NE_AMOUNT) CHANGI NG o_CURRENCY l i ke i e021- cur r ency o_PRI CE_UOM l i ke i e021- pri ce_uom o_PRI CE_QTY l i ke i e021- pri ce_qt y o_UNI T_PRI CE l i ke i e021- uni t _pri ce o_LI NE_AMOUNT l i ke i e021- l i ne_amount .
dat a:
n_uni t _pri ce t ype p deci mal s 5, n_l i ne_amount t ype p deci mal s 3.
* not al l of t he * master def aul t c as e i _ c ur r ( 2) . when ' US' . o_cur r ency when ' J P' . o_ c ur r enc y when ot her s. o_cur r ency endcase.
vendors send t he curr ency code, so use t he vendor
* uni t pr i ce i s i i f ( i _ uni t _ pr i i _uni t _pri n_ uni t _ pr i c e n_uni t _pri ce endi f .
mpl i ed 5- dec c e c n ' 0' and ce co ' 0123456789' ) . = i _ uni t _ pr i c e. = n_uni t _pr i ce / hun_t hou.
= ' USD' . = ' J PY' . = uty_vendors- waer s.
* l i ne pr i ce i s i mpl i ed 3- dec i f ( i _l i ne_amount co ' 0123456789' and i _l i ne_amount cn ' 0' ) . n_l i ne_amount = i _l i ne_amount . n_l i ne_amount = n_l i ne_amount / t hou. endi f . * ' KP' = pr i ce per t housand i f i _ uom = ' KP' . o_ pr i c e_ qt y = ' 1000' . el s e. o_ pr i c e_ qt y = ' 1' . endi f . o_ pr i c e_ uom = ' PCE' . i f n ot n_ uni t _ pr i c e i s i ni t i al . o_ uni t _ p r i c e = n_ uni t _ pr i c e. shi f t o_uni t _pri ce l ef t del et i ng l eadi ng space. el s e. c l ear o_ uni t _ p r i c e. endi f . i f n ot n _ l i ne_ amount i s i ni t i al . o_l i ne_amount = n_l i ne_amount . shi f t o_l i ne_amount l ef t del eti ng l eadi ng space. el s e. cl ear o_l i ne_amount. endi f . ENDFORM.
" money_c onver si on
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m SAP_vendor _par t no * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * r epl ace UTY par t number sent by vendor wi t h SAP mat er i al no. * f rom PO l i ne i t em. *----------------------------------------------------------------------* FORM SAP_vendor_part no changi ng cust_ part no l i ke i e021- cust _par t no. t abl es: makt. dat a: part no_sent l i ke makt - makt x. par t no_sent = cust _par t no. cl ear: makt , cust _par t no. sel ect si ngl e mat nr f r omekpo i nt o cust _par t no wher e ebel n = i e021- po_number and ebel p = i e021- po_l i neno.
i f sy- s ubr c i s i ni t i al . *compar e mat eri al descr i pti on t o part number sent by vendor sel ect s i ngl e maktx f r om makt i nto makt- maktx wher e mat nr = cust _part no. i f part no_sent <> makt - makt x. * ' Par t No. Mi smat ch: PO & - &, Par t sent &, SAP mat . no. &' message i 031 wi t h i e021- po_number i e021- po_l i neno par t no_s ent makt - makt x. endi f . el se. "PO l i ne not found *t r y t o f i nd SAP mater i al number usi ng 20- char cat al og no. sent sel ect si ngl e matnr f r om makt i nt o cust _par t no wher e maktx = par t no_sent . i f not s y- s ubr c i s i ni t i al . * ' SAP mater i al no. not f ound f or & - PO & - &' message i 032 wi t h part no_sent i e021- po_number i e021- po_l i neno. endi f . endi f . *i f not f ound, I Doc wi l l go to workf l ow f or mi ssi ng mat er i al no. ENDFORM.
" SAP_vendor _par t no
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form i doc_header _segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e i nt er nal t abl e ent r i es f or header segment s. * DESADV: * E1EDK07 * E1EDKA1 * E1EDK03 * E1EDK08 * E1EDKA2 * E1EDK06 * I NVOI C: * E1EDK01 * E1EDKA1( s) * E1EDK02 * E1EDK03( s) *----------------------------------------------------------------------* FORM i doc_header _segs usi ng val ue( desadv_ok). * I NVOI C cl ear i _seg_num. i nvoi cdat a- segnam = ' E1EDK01' . e1edk01- act i on = i e021- st at. i f i e021- c ur r enc y( 2) = ' US' . e1edk01-cur cy = ' USD' . el s e. e1edk01- curcy = ' J PY' . endi f . i nvoi cdata- sdat a = e1edk01. append_i doc_r ec i nvoi cdat a i . cl ear e1edka1. i nvoi cdat a- segnam = ' E1EDKA1' . e1edka1-parvw = ' RE' . e1edka1- par t n = i e021- shi pt o_i d. i nvoi cdata- sdat a = e1edka1. append_i doc_r ec i nvoi cdat a i . cl ear e1edka1. i nvoi cdat a- segnam = ' E1EDKA1' . e1edka1- par vw = ' LF' . e1edka1- part n = i e021- l i f nr. e1edka1- l i f nr = i e021- s hi pt o _ i d. i nvoi cdata- sdat a = e1edka1. append_i doc_r ec i nvoi cdat a i . i f not i e021- endcust_name i s i ni t i al . cl ear e1edka1. i nvoi cdat a-segnam= ' E1EDKA1' . e1edka1- par vw = ' WE' . e1edka1- name1 = i e021- endcust _name. i nvoi cdata- sdat a = e1edka1. append_i doc_r ec i nvoi cdata i . endi f .
cl ear e1edk02. i nvoi cdat a- segnam = ' E1EDK02' . e1edk02- qual f = ' 009' . e1edk02- bel nr = i e021- i nvoi ce_no. i nvoi cdata- sdat a = e1edk02. append_i doc_r ec i nvoi cdat a i . cl ear e1edk03. i nvoi cdat a- segnam = ' E1EDK03' . e1edk03- i ddat = ' 012' . e1edk03-datum = i e021- cr eat e_date. i nvoi cdata- sdat a = e1edk03. append_i doc_r ec i nvoi cdat a i . i nvoi cdat a- segnam = ' E1EDK03' . e1edk03- i ddat = ' 024' . i nvoi cdata- sdat a = e1edk03. append_i doc_r ec i nvoi cdat a i . check desadv_ok = ' 000' . * DESADV cl ear d_seg_num. desadvdat a- segnam = ' E1EDK07' . e1edk07- act i on = i e021- st at. e1edk07- bol nr = i e021- i nvoi ce_no. desadvdat a- sdat a = e1edk07. append_i doc_ r ec desadvdat a d. cl ear e1edka1. desadvdat a- segnam = ' E1EDKA1' . desadvdat a- sdat a = e1edka1. append_i doc_ r ec desadvdat a d. cl ear e1edk03. desadvdat a- segnam = ' E1EDK03' . desadvdat a- sdat a = e1edk03. append_i doc_ r ec desadvdat a d. cl ear e1edk08. desadvdat a- segnam = ' E1EDK08' . e1edk08-vbel n = i e021- i nvoi ce_no. e1edk08- t rai d = i e021- shi p_i d. e1edk08-t r aty = i e021- shi p_method. desadvdat a- sdat a = e1edk08. append_i doc_ r ec desadvdat a d. cl ear e1edka2. desadvdat a- segnam = ' E1EDKA2' . desadvdat a- sdat a = e1edka2. append_i doc_ r ec desadvdat a d. cl ear e1edk06. desadvdat a- segnam = ' E1EDK06' . e1edk06- i ddat = ' 025' . "document dat e e1edk06-datum = i e021- cr eat e_date. desadvdat a- sdat a = e1edk06. append_i doc_ r ec desadvdat a d. i f not i e021- e t a i s i ni t i al . cl ear e1edk06. desadvdata- segnam = ' E1EDK06' . e1edk06- i ddat = ' 001' . "del i ver y dat e e1edk06-datum = i e021-et a. desadvdata- sdat a = e1edk06. append_i doc_r ec desadvdat a d. endi f . i f not i e021- e t d i s i ni t i al . cl ear e1edk06. desadvdata- segnam = ' E1EDK06' . e1edk06- i ddat = ' 010' . "shi p date e1edk06-datum = i e021-et d. desadvdata- sdat a = e1edk06. append_i doc_r ec desadvdat a d. endi f . ENDFORM.
" i doc_header _ segs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& Form i doc_poheader _segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * cr eat e i nter nal t abl e ent r i es f or DESADV PO/ i t ems egment s * E1EDP07 *----------------------------------------------------------------------* FORM i doc_poheader _segs. * DESADV cl ear e1edp07. desadvdat a- segnam = ' E1EDP07' . e1edp07- bst nk = i e021- po_number . e1edp07-posex = i e021- po_l i neno. desadvdat a- sdat a = e1edp07. append_i doc_ r ec desadvdat a d. p07_ctr = p07_ctr + 1. ENDFORM.
" i doc_poheader _ segs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m i doc_i t em_segs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * creat e i nt er nal t abl e ent r i es f or PO i t em segment s: * DESADV: E1EDP09 * I NVOI C: E1EDP01 Qt ys * E1EDP02 r ef nos. ( PO number / l i ne) * E1EDP19 par t number s * E1EDP26 amount s * E1EDP04 t axes *----------------------------------------------------------------------* FORM i doc_i t em_segs usi ng val ue( desadv_ok). dat a:
n_l i ne_amt
t ype p deci mal s 3.
*I NVOI C cl ear e1edp01. i nvoi cdat a- segnam = ' E1EDP01' . e1edp01- menee = i e021- qt y_uom. e1edp01- menge = i e021- i nvoi ce_qty. e1edp01- vpr ei = i e021- uni t _pr i ce. e1edp01- pmene = i e021- pr i ce_uom. e1edp01- pei nh = i e021- pr i ce_qty. e1edp01- net wr = i e021- l i ne_amount. i nvoi cdata- sdat a = e1edp01. append_i doc_r ec i nvoi cdat a i . cl ear e1edp02. i nvoi cdat a- segnam = ' E1EDP02' . e1edp02- qual f = ' 001' . e1edp02- bel nr = i e021- po_number . e1edp02- zei l e = i e021- po_l i neno. i nvoi cdata- sdat a = e1edp02. append_i doc_r ec i nvoi cdat a i . cl ear e1edp19. i nvoi cdat a- segnam = ' E1EDP19' . e1edp19- qual f = ' 001' . e1edp19- i dt nr = i e021- cust _part no. i nvoi cdata- sdat a = e1edp19. append_i doc_r ec i nvoi cdat a i . cl ear e1edp19. i nvoi cdat a- segnam = ' E1EDP19' . e1edp19- qual f = ' 002' . e1edp19-i dt nr = i e021- vendor _par t no. i nvoi cdata- sdat a = e1edp19. append_i doc_r ec i nvoi cdat a i . cl ear e1edp26. i nvoi cdat a- segnam = ' E1EDP26' . e1edp26- qual f = ' 003' . e1edp26-betr g = i e021- l i ne_amount . i nvoi cdata- sdat a = e1edp26. append_i doc_r ec i nvoi cdat a i .
* dummy t ax s eg cl ear e1edp04. i nvoi cdat a- segnam = ' E1EDP04' . e1edp04-msatz = ' 0. 00' . i nvoi cdata- sdat a = e1edp04. append_i doc_r ec i nvoi cdat a i . n_l i ne_amt = i e021- l i ne_amount . i nvoi c e_ t o t a l = i nvoi c e_ t o t al + n_ l i ne_ amt . check desadv_ok = ' 000' . * DESADV cl ear e1edp09. desadvdat a- segnam = ' E1EDP09' . e1edp09-vbel n = i e021- sl i p_number . e1edp09- matnr = i e021- vendor_ par t no. e1edp09- vr kme = i e021- qt y_uom. e1edp09- l f i mg = i e021- i nvoi ce_qty. desadvdat a- sdat a = e1edp09. append_i doc_ r ec desadvdat a d. ENDFORM.
" i doc_i t em_s egs
*************************************************** ******************** *& For m post_ i docs * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * cr eat e dat abase I Docs f r om t he i docdata t abl es and cl ear t abl es. *----------------------------------------------------------------------* FORM post _i docs usi ng val ue(desadv_ok). *I NVOI C cl ear e1eds01. i nvoi cdat a- segnam = ' E1EDS01' . e1eds01-s umi d = ' 010' . e1eds01- summe = i nvoi ce_t ot al . e1eds01- waer q = i e021- curr ency. shi f t e1eds01- summe l ef t del eti ng l eadi ng space. i nvoi cdat a- sdat a = e1eds01. append_i doc_r ec i nvoi cdat a i . CALL FUNCTI ON ' I NBOUND_ I DOC_PROCESS' TABLES I DOC_ CONTROL = i edi dc I DOC_DATA = i nvoi cdat a. commi t wor k. * DESADV i f desadv_ok = ' 000' . cl ear e1eds02. desadvdata- segnam = ' E1EDS02' . e1eds02- sumi d = ' 001' . e1eds02- summe = p07_ct r . shi f t e1eds02-summe l eft del eti ng l eadi ng space. desadvdata- sdat a = e1eds02. append_i doc_r ec desadvdat a d. CALL FUNCTI ON ' I NBOUND_I DOC_PROCESS' TABLES I DOC_CONTROL = dedi dc I DOC_DATA = desadvdat a. commi t wor k. endi f . r efr esh: desadvdata, i nvoi cdat a. c l ear : desadvdat a, i nvoi cdat a, p07_ctr , i nvoi c e_ t ot a l , save_st at , save_po, save_l i ne,
save_i nvoi ce.
ENDFORM.
" post _i docs
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& For m i ni t _desadv * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * add a DESDAV cont r ol r ecord and i ni t i al i ze f i el ds *----------------------------------------------------------------------* FORM i ni t _desadv. cl ear dedi dc. r ef r esh dedi dc. * i ni t i al i z e c ont r ol r e cor d: move: ' 2' t o dedi dc- di rect, ' DESADV01' t o dedi dc- doct yp, ' DESADV' t o dedi dc- mest yp, ' F' t o dedi dc - s t d, ' E021' t o dedi dc- st dmes, ' LS' t o dedi dc- sndprt , ' TY_VENDORS' t o dedi dc- sndprn, sy- dat l o t o dedi dc- credat , sy- t i ml o t o dedi dc- creti m. append dedi dc. ENDFORM.
" i ni t _desadv
* &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *& F or m i ni t _ i nvoi c * &- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * add a I NVOI C cont rol record and i ni t i al i ze f i el ds *----------------------------------------------------------------------* F ORM i ni t _ i nvoi c . c l ear i edi dc . r e f r es h i edi dc . * i ni t i al i z e c ont r ol r e cor d: move: ' 2' t o i edi dc- di rect, ' I NVOI C01' t o i edi dc- doct yp, ' I NVOI C' t o i edi dc- mest yp, ' MM' t o i edi dc- mescod, ' F' t o i edi dc - s t d, ' E021' t o i edi dc- st dmes, ' L S' t o i edi dc - s ndpr t , ' TY_VENDORS' t o i edi dc- sndprn, sy- dat l o t o i edi dc- credat , sy- t i ml o t o i edi dc- creti m. append i edi dc. ENDFORM.
7.10.7
" i ni t _i nvoi c
Lis t transactions
*----------------------------------------------------------------------* * REPORT Z_TRANSACTI ONS * *----------------------------------------------------------------------* * TEXT EL EMENTS * ------------* Headi ng * Transact i on code Text * * Sel ecti on text s * P_ DNLD Downl oad? * P_FI LE Fi l ename: * S_SPRSL Language: * S_TCODE Tr ansact i on Code: * * Text Symbol s * 001 Transacti on Sel ecti on * 002 Downl oad Opt i on * 003 Fi l ename *----------------------------------------------------------------------* REPORT z_t r ansact i ons. TABLES: t st ct .
TYPES: BEGI N OF i t ab_t x, t code LI KE tst ct- t code, t t ext LI KE t s t c t - t t ext , END OF i t ab_t x. DATA: i t ab_t x tx i t ab_f i l e p_f i l e r etur ncode f i l es t r i ng
TYPE TYPE LI KE LI KE LI KE TYPE
i t ab_t x OCCURS 0 WI TH HEADER LI NE, i t ab_t x, sval OCCURS 0 WI TH HEADER LI NE, rl grap- f i l ename, sy- subrc, s t r i ng.
DATA: BEGI N OF f i el ds OCCURS 2. I NCLUDE STRUCTURE s val . DATA: END OF f i el ds. * t ext- 001 = Transact i on Sel ect i on SELECTI ON- SCREEN BEGI N OF BLOCK t r ansx WI TH FRAME TI TLE t ext - 001. SELECT- OPTI ONS: s_t code FOR t st ct - t code, s _ spr s l FOR t s t c t - s pr s l . SELECTI ON- SCREEN END OF BLOCK t r ansx . * t ext - 002 = Downl oad Opti on SELECTI ON- SCREEN BEGI N OF BLOCK dl d WI TH FRAME TI TLE t ext - 002. PARAMETERS: p_dnl d TYPE c AS CHECKBOX. SELECTI ON- SCREEN END OF BLOCK dl d. AT SELECTI ON- SCREEN OUTPUT. p_ f i l e = ' C: \ SAPTXl i s t . xl s ' . p_ dnl d = ' X' . MOVE ' I ' TO s_spr sl - si gn. MOVE ' EQ' TO s_sprsl - opt i on. MOVE ' EN' TO s_s prsl - l ow. APPEND s_s prsl . START- OF- SELECTI ON. REFRESH i t ab_t x. SELECT * FROM t st ct I NTO CORRESPONDI NG FI ELDS OF TABLE i t ab_t x WHERE t code I N s_t code AND sprs l I N s_s prsl . I F sy- subrc <> 0. MESSAGE s265( sf ) . ELSE. SORT i t ab_t x BY t code. LOOP AT i t ab_t x. WRI TE: / 1 i t ab_t x-t code( 20) , AT 20 i t ab_t x- t t ext . ENDLOOP. I F p_ dnl d = ' X' . CLEAR f i el ds. f i el ds-t abname = ' RLGRAP' . f i el ds- f i el dname = ' FI LENAME' . f i el ds - val ue = p_ f i l e. f i el ds- f i el d_ at t r = ' 00' . APPEND f i el ds. CALL FUNCTI ON ' POPUP_GET_ VALUES' EXPORTI NG popup_t i t l e = t ext - 003 I MPORTI NG r eturncode = r etur ncode TABLES f i el ds = f i el ds EXCEPTI ONS er r or _ i n_ f i el ds = 1 OTHERS = 2. CHECK r et ur ncode EQ space. f i l es t r i ng = f i el ds - val ue. CALL FUNCTI ON ' GUI _ DOWNLOAD' EXPORTI NG f i l ename
= f i l es t r i ng
wr i t e _ f i el d_ s epar a t or =',' TABLES dat a_t ab = i t ab_t x EXCEPTI ONS f i l e_ wr i t e _er r or =1 no_bat ch =2 gui _ r e f u se_ f i l et r ans f e r = 3 i nval i d_ t y pe =4 no_aut hor i t y =5 unknown_err or =6 header_not_al l owed =7 separat or_not_al l owed =8 f i l es i z e_ not _ al l owed =9 header_t oo_l ong = 10 dp_err or _cr eat e = 11 dp_err or_send = 12 dp_err or _wr i t e = 13 unknown_dp_er r or = 14 access_ deni ed = 15 dp_out _of _memor y = 16 di s k_ f u l l = 17 dp_t i meout = 18 f i l e_not _f ound = 19 dat apr ovi der_except i on = 20 c ont r o l _ f l us h_ er r or = 21 OTHERS = 22. I F sy- subrc <> 0. MESSAGE s999(b1) WI TH ' Fi l e ' f i l estr i ng ' NOT cr eat ed! ' . ELSE. MESSAGE s999(b1) WI TH ' Fi l e ' f i l estr i ng ' Cr e at e d s uc ces s f ul l y! ' . ENDI F. " Check on downl oad succes s ENDI F. " Downl oad ENDI F. "Check on sel ect i on
7.10.8
Report wit h joi ns and macros
REPORT ZREPORT message-id z11 LINE-SIZE 180 LINE-COUNT 65 NO STANDARD PAGE HEADING. tables: vbrk, vbrp, knvp, kna1, T100, BHDGD. data: gpct type p decimals 1. SELECT-OPTIONS: SELECT-OPTIONS: SELECT-OPTIONS: SELECT-OPTIONS: SELECT-OPTIONS:
DATA: BEGIN OF REPLINES OCCURS 100, MATKL LIKE VBRP-MATKL, "material group ARKTX LIKE VBRP-ARKTX, "old material no. MATNR LIKE VBRP-MATNR, "ATAC material no. KUNAG LIKE vbrk-kunag, "customer no. NAME1 like kna1-name1, "customer name BUKRS like VBRK-BUKRS, "company code VBELN like vbrk-vbeln, "invoice no. FKDAT like vbrk-fkdat, "invoice date (ccyymmdd) FKIMG like VBRP-FKIMG, "inv. qty (3-dec) KZWI2 like VBRP-KZWI2, "line price (2-dec) WAVWR like VBRP-WAVWR, "line cost (2-dec) KUNN2 like KNVP-KUNN2, "Sales rep VBTYP like VBRK-VBTYP, "document type END OF REPLINES. DATA: FKIMG_SUM_GRP like vbrp-fkimg, KZWI2_SUM_GRP like vbrp-KZWI2, WAVWR_SUM_GRP like vbrp-WAVWR,
FKIMG_SUM_MAT like vbrp-fkimg, KZWI2_SUM_MAT like vbrp-KZWI2, WAVWR_SUM_MAT like vbrp-WAVWR. DATA: save_matnr like vbrp-matnr, save_matkl like vbrp-matkl, save_arktx like vbrp-arktx, lin like sy-tabix, offset type i, hun type p decimals 2 value 100, c_low(20), c_high(20), h_tag(15). data:: date_string_I(150) cust_string_I(150) srep_string_I(150) mgrp_string_I(150) gpct_string_I(150) date_string_E(150) cust_string_E(150) srep_string_E(150) mgrp_string_E(150) gpct_string_E(150)
type type type type type type type type type type
c, c, c, c, c, c, c, c, c, c.
ranges: r_atyp for vbrp-autyp, r_vtyp for vbrk-vbtyp. *________________________________________________________ * DEFINITIONS *________________________________________________________ define add_comma. * add comma for selection criteria output string if offset > 0. &1_string_&2+offset(1) = ','. offset = offset + 2. endif. END-of-definition.
" add_comma
DEFINE create_string. * loop for inclusions loop at s_&1. offset = strlen( &1_string_&2 ). c_low = s_&1-low. c_high = s_&1-high. shift c_low left deleting leading '0'. shift c_high left deleting leading '0'. shift c_low left deleting leading space. shift c_high left deleting leading space. if '&1' = 'date'. concatenate c_low+4(2) '/' c_low+6(2) '/' c_low+2(2) into c_low. if not c_high is initial. concatenate c_high+4(2) '/' c_high+6(2) '/' c_high+2(2) into c_high. endif. endif. case s_&1-option. when 'EQ'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = c_low. when 'NE'. check s_&1-sign = '&3'. add_comma &1 &2. &1_string_&2+offset = c_low. when 'GT'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = 'Greater than'. offset = offset + 13. &1_string_&2+offset = c_low. when 'LE'. check s_&1-sign = '&2'.
add_comma &1 &2. &1_string_&2+offset = 'Less than or equal to'. offset = offset + 22. &1_string_&2+offset = c_low. when 'LT'. check s_&1-sign = '&2'. add_comma &1 &2. &1_string_&2+offset = 'Less than'. offset = offset + 10. &1_string_&2+offset = c_low. when 'BT'. check s_&1-sign = '&2'. add_comma &1 &2. concatenate &1_string_&2 c_low '-' c_high into &1_string_&2 separated by space. when 'NB'. check s_&1-sign = '&3'. add_comma &1 &2. concatenate &1_string_&2 c_low '-' c_high into &1_string_&2 separated by space. endcase. endloop. END-OF-DEFINITION.
" create_string
DEFINE WRITE_STRING. if ( &1_string_I is initial and &1_string_E is initial ). &1_string_I = 'All'. endif. if not &1_string_I is initial. write: /05 h_tag, 22 'include:', 31 &1_string_I. if not &1_string_E is initial. write: /22 'exclude:', 31 &1_string_E. endif. elseif not &1_string_E is initial. write: /05 h_tag, 22 'exclude:', 31 &1_string_E. endif. END-OF-DEFINITION.
START-OF-SELECTION. * ASSUMPTION: All quantities are in sales units. Since quantities * are summed to the material group level, it is assumed that all * materials within a material group have the same sales unit of * measure. select a~kunag a~vbeln a~fkdat a~bukrs a~vbtyp b~matkl b~matnr b~arktx b~fkimg b~kzwi2 b~wavwr c~name1 d~kunn2 into corresponding fields of table replines from vbrk as a inner join vbrp as b on a~vbeln = b~vbeln inner join kna1 as c on a~kunag = c~kunnr left outer join knvp as d on a~kunag = d~kunnr and a~vkorg = d~vkorg and a~vtweg = d~vtweg and d~spart = '71' and d~parvw = 'CO' and d~parza = '000' where a~vkorg = '7100' and a~vbtyp in r_vtyp and a~fkdat in s_date and a~kunag in s_cust and b~matkl in s_mgrp and b~autyp in r_atyp. END-OF-SELECTION. PERFORM INIT_BATCH_HEADING. SORT REPLINES BY MATKL MATNR KUNAG FKDAT. PERFORM LIST_DISPLAY. AT LINE-SELECTION. * run transaction to display invoice document * passing parameter values via memory SET PARAMETER ID 'VF' FIELD REPLINES-VBELN. CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN. ******************************************* TOP-OF-PAGE DURING LINE-SELECTION. PERFORM HEADING_DISPLAY. ******************************************* TOP-OF-PAGE. PERFORM HEADING_DISPLAY.
************************************************************************ * FORMS ************************************************************************ *----------------------------------------------------------------------* FORM LIST_DISPLAY * Output internal table, REPLINES *----------------------------------------------------------------------FORM LIST_DISPLAY. data: gross_profit like vbrp-kzwi2, gp_percent type p decimals 1, uprice type p decimals 5, ucost type p decimals 5, hun type p decimals 2 value 100, neg type p decimals 2 value -1. data: invoice_no(10).
*
*
* * *
LOOP AT REPLINES. FORMAT COLOR COL_NORMAL INTENSIFIED ON INVERSE OFF. check ( replines-fkimg > 0 or replines-KZWI2 > 0 or replines-WAVWR > 0 ). change sign on cancellations if ( replines-vbtyp = 'N' or replines-vbtyp = 'S' ). replines-fkimg = replines-fkimg * neg. replines-KZWI2 = replines-KZWI2 * neg. replines-WAVWR = replines-WAVWR * neg. endif. calculate gross profit percent and apply selection value range gross_profit = replines-kzwi2 - replines-wavwr. gp_percent = ( gross_profit / replines-kzwi2 ) * hun. check: gp_percent in s_gpct, replines-kunn2 in s_srep. calculate unit price uprice = replines-kzwi2 / replines-fkimg. calculate unit cost ucost = replines-wavwr / replines-fkimg. begin output if ( save_matnr <> replines-matnr and not save_matnr is initial ). perform material_footer. endif. if ( save_matkl <> replines-matkl and not save_matkl is initial ). perform material_group_footer. endif. save_matkl = replines-matkl. save_matnr = replines-matnr. save_arktx = replines-arktx. invoice_no = replines-vbeln. shift: invoice_no left deleting leading '0', replines-kunag left deleting leading '0', replines-matnr left deleting leading '0'. WRITE: /01(3) REPLINES-MATKL, 05(20) REPLINES-ARKTX, 26(7) REPLINES-MATNR, 34(8) REPLINES-KUNAG, 42(14) REPLINES-NAME1, 57(10) INVOICE_NO, 68 REPLINES-FKDAT MM/DD/YY, 79(12) REPLINES-FKIMG decimals 0, 92(15) REPLINES-KZWI2, 108(12) UPRICE, 121(15) REPLINES-WAVWR, 137(12) UCOST, 150(15) gross_profit, 166(8) gp_percent, 175 '%'. HIDE: REPLINES-BUKRS, REPLINES-VBELN. FKIMG_SUM_GRP = FKIMG_SUM_GRP + replines-fkimg. KZWI2_SUM_GRP = KZWI2_SUM_GRP + replines-KZWI2. WAVWR_SUM_GRP = WAVWR_SUM_GRP + replines-WAVWR.
FKIMG_SUM_MAT = FKIMG_SUM_MAT + replines-fkimg. KZWI2_SUM_MAT = KZWI2_SUM_MAT + replines-KZWI2. WAVWR_SUM_MAT = WAVWR_SUM_MAT + replines-WAVWR. FORMAT COLOR COL_NORMAL INTENSIFIED OFF INVERSE OFF. ENDLOOP. * output last totals perform material_footer. perform material_group_footer. * Report footer IF NOT SY-SUBRC IS INITIAL. SKIP. SKIP. WRITE: /50 '*** NO RECORDS SELECTED ***'. EXIT. ELSE. FORMAT COLOR COL_KEY ON INTENSIFIED OFF INVERSE OFF. WRITE: /55 '*** END OF REPORT ***'. ENDIF. SY-LSIND = 0. "replaces basic list ENDFORM.
*---------------------------------------------------------------------FORM INIT_BATCH_HEADING. * BHDGD-LINES = SY-LINSZ. "number of characters per line BHDGD-LINES = 177. "number of characters per line BHDGD-UNAME = SY-UNAME. "user name creating report BHDGD-REPID = SY-REPID. "abap name BHDGD-LINE1 = SY-TITLE. "report title from attributes BHDGD-BUKRS = '7100'. "company BHDGD-INIFL = '0'. "says you are initializing the heading ENDFORM. *---------------------------------------------------------------------FORM HEADING_DISPLAY. PERFORM BATCH-HEADING(RSBTCHH0). SKIP. h_tag = 'Invoice Dates'. write_string date. h_tag = 'Customers'. write_string cust. h_tag = 'Sales Reps'. write_string srep. h_tag = 'Material Groups'. write_string mgrp. h_tag = 'Gr.Profit Pct'. write_string gpct. skip 2. FORMAT COLOR COL_KEY ON INTENSIFIED OFF INVERSE OFF. WRITE: /01 'Mat', 26 'ATAC', 34 'Customer', 57 'Invoice', 68 'Invoice', 79(12) 'Invoice' right-justified, 92(15) 'Extended' right-justified, 108(12) 'Unit or Avg' right-justified, 121(15) 'Extended' right-justified, 137(12) 'Unit or Avg' right-justified, 150(15) 'Gross' right-justified, /01 'Grp', 05 'Item Nbr', 26 'Nbr', 34 'Nbr', 42 'Name', 57 'Nbr', 68 'Date', 79(12) 'Quantity' right-justified, 92(15) 'Price' right-justified, 108(12) 'Price' right-justified, 121(15) 'Cost' right-justified, 137(12) 'Cost' right-justified, 150(15) 'Profit' right-justified, 171 'GP%'.
FORMAT COLOR COL_POSITIVE ON INVERSE OFF. ULINE. ENDFORM.
*&---------------------------------------------------------------------* *& Form product_group_footer *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM material_group_footer. data: gross_profit like vbrp-kzwi2, gp_percent type p decimals 1, uprice type p decimals 5, ucost type p decimals 5. * calculate gross profit percent gross_profit = kzwi2_sum_grp - wavwr_sum_grp. gp_percent = ( gross_profit / kzwi2_sum_grp ) * hun. * calculate unit price uprice = kzwi2_sum_grp / fkimg_sum_grp. * calculate unit cost ucost = wavwr_sum_grp / fkimg_sum_grp. write:
REPORT ZEPS_ PROGRESS_POP . *************************************************** ******** * Devel oper : S. Sr i ni . * Locat i on : Chennai , * : Tami l Nadu, * : I ndi a. * Date : 03/ 09/ 2001. *************************************************** ******** dat a: val t ype i . dat a event( 6) t ype c. val = 0. do 4 ti mes. val
= val + 25.
CALL FUNCTI ON ' EPS_PROGRESS_POPUP' EXPORTI NG BTN_TXT = ' CANCEL' CURVAL_G2 = VAL LAYOUT = ' 1' MAXVAL_G2 = ' 100' POPUP_LI NK = ' ASYNC' POPUP_STAT = ' 1' POPUP_TI TLE = ' SAP' TEXT_1 = ' TEXT 1' TEXT_2 = ' TEXT 2' TEXT_3 = ' TEXT 3' TEXT_4 = ' TEXT 4' TEXT_G1 = ' TEXT G1' TEXT_G2 = ' TEXT G2' TI TLE_ G2 = ' TI TLE G2 ' WI NI D = 100. I F SY- SUBRC <> 0. MESSAGE I D SY- MSGI D TYPE SY- MSGTY NUMBER SY- MSGNO WI TH SY- MSGV1 SY- MSGV2 SY- MSGV3 SY- MSGV4. ENDI F. ENDDO. PERFORM CLOSEGRAPH. *************************************************** ********* FORM CLOSEGRAPH. CALL FUNCTI ON ' PROGRESS_POPUP' EXPORTI NG STAT = ' 2' WI NI D = 100. CALL FUNCTI ON ' GRAPH_DI ALOG' EXPORTI NG CLOSE = ' X' . ENDFORM. *************************************************** ********
7.10.10 Change IDoc status to error status and send to workf low REPORT ZS7BM000007 message- i d ZS7 .
*__________________________________________________ ____________________ */ Program Name: Process i nvoi ce I Docs wi t h Goods Recei pt */ Descri pt i on : Thi s progr amchecks al l I NVOI C MM I Docs i n status 64 * and 66 t o det ermi ne i f t hey have been r ecei ved. Those * I Docs ol der t han 10 days t hat have st i l l not been * goods r ecei pt ed are gi ven err or st atus 51. */ Tr ansact i on : N/ A - r un vi a schedul ed j ob *__________________________________________________ ____________________ t abl es : edi dc , mkpf , ekpo, r bkp, e1edk01, e1edka1, e1edk02, e1edp02. dat a: i edi dc l i ke edi dc occur s 1 wi t h header l i ne, dat a_r ec l i ke edi dd occur s 1 wi t h header l i ne. dat a: c_docnum( 16) t ype c, c_mbl nr ( 10) t ype c, c_i nvoi c(10) t ype c, rc( 1) t ype c, l ead_ t i me l i k e l f m1- pl i f z , gr _qt y l i ke mseg- erf mg, t est _dat e l i ke sy-dat um, gr _r equi r ed l i ke ekpo-webr e, po_number ( 10) t ype n, po_l i neno l i ke ekpo-ebel p, n_vend( 10) t ype n, vendor _ i d l i ke l f a1- l i f nr . dat a: begi n of i t ab_gr occur s 0, mbl nr l i ke mkpf - mbl nr, bwart l i ke mseg- bwart , erf mg l i ke mseg- erf mg, end of i t ab_gr . const ant s: * name of cont ai ner el ement ( worki t emobj ect i d) C_ELEMENT_WI _OBJ _I D LI KE SWCONT- ELEMENT VALUE ' _ WI _ OBJ ECT_I D' , * name of cont ai ner el ement ( Number Pl usEvent code) C_EL EMENT_ NO_PLUS_ I NFO LI KE SWCONT- ELEMENT VALUE ' Number Pl usEvent code' . r anges: r _status for edi dc-st at us. TYPE- POOLS: * general i doc type pool TI DOC. *************************************************** ********************* * I NCLUDES * *************************************************** ********************* * i ncl ude f or workf l ow programmi ng I NCLUDE . *************************************************** ********************* * I NNI TI ALI ZATI ON * *************************************************** ********************* i ni t i al i z at i on. * creat e I Doc status sel ect i on t abl e. c l ear r _ s t at us . r e f r es h r _ s t at u s. MOVE: ' ' ' APPEND MOVE: ' APPEND
EQ' TO I' TO 64' TO r _st at us. 66' TO r _st at us.
r _st atus- OPTI ON, r _status-SI GN, r _st atus- LOW.
"equal s "i ncl ude
r _s t at us- LOW.
*************************************************** ********************* * START- OF- SELECTI ON *************************************************** *********************
s t ar t - of - s el ec t i on. sel ect * f rom edi dc i nt o t abl e i edi dc wher e st atus i n r_ st atus and di rect = ' 2' and "i nbound mest yp = ' I NVOI C' and mescod = ' MM' . l oop at i edi dc. c l ear r c .
CALL FUNCTI ON ' EDI _DOCUMENT_ OPEN_FOR_READ' EXPORTI NG DOCUMENT_ NUMBER = i edi dc- docnum I MPORTI NG I DOC_CONTROL = I EDI DC EXCEPTI ONS DOCUMENT_FOREI GN_ LOCK = 01 DOCUMENT_ NOT_ EXI ST = 02 DOCUMENT_ NUMBER_I NVALI D = 03 ERROR_MESSAGE = 04 OTHERS = 05.
I F NOT SY- SUBRC I S I NI TI AL. c_docnum = i edi dc- docnum. s hi f t c _ doc num l ef t del et i ng l eadi ng ' 0' . * ' Cannot open I NVOI C I Doc & f or Goods Recei pt processi ng' message w025 wi t h c_ docnum. cont i nue. ENDI F.
*
* *
* *
*
cal l f unct i on ' EDI _SEGMENTS_GET_ALL' expor t i ng document _number = i edi dc- docnum t abl es i doc_cont ai ners = dat a_rec except i ons document _number _i nval i d = 1 end_of _document =2 ot her s = 3. i f not s y- s ubr c i s i ni t i al . CALL FUNCTI ON ' EDI _ DOCUMENT_ CLOSE_ READ' EXPORTI NG DOCUMENT_ NUMBER = i edi dc- docnum I MPORTI NG I DOC_ CONTROL = i edi dc c_docnum = i edi dc- docnum. s hi f t c _ doc num l ef t del et i ng l eadi ng ' 0' . ' Cannot r etr i eve data f or I NVOI C I Doc & ( Goods Recei pt pr ocessi ng) ' message w030 wi t h c_ docnum. cont i nue. el s e. CALL FUNCTI ON ' EDI _ DOCUMENT_ CLOSE_ READ' EXPORTI NG DOCUMENT_ NUMBER = i edi dc- docnum I MPORTI NG I DOC_CONTROL = i edi dc. I f t hi s i s a change or modi f y I Doc, change status t o 51 (err or) . One & onl y one K01 segment s houl d exi st r ead tabl e data_r ec wi t h key segnam = ' E1EDK01' . i f sy- s ubr c i s i ni t i al . move dat a_r ec- sdat a t o e1edk01. case e1edk01- act i on. when ' 000' . "ori gi nal dat a OK - do not hi ng when ' 002' . "modi f i ed dat a ' I nvoi ce & - I Doc f or Revi ew Onl y' perf orm i doc_st atus_update usi ng ' 51' ' 028' ' Modi f i cat i on' ' ' . when ' 002' . "modi f i ed dat a ' I nvoi ce & - I Doc f or Revi ew Onl y' perf orm i doc_st atus_update usi ng ' 51' ' 028' ' Canc el l at i on' ' ' . endcase. endi f .
check r c i s i ni t i al . * get t he vendor no. cl ear vendor_i d. l oop at dat a_r ec wher e segnam = ' E1EDKA1' . move dat a_r ec- sdat a t o e1edka1. check: e1edka1-parvw = ' LF' , e1edka1- par t n co ' 0123456789' , e1edka1- part n <> ' ' . n_vend = e1edka1- par t n. vendor_i d = n_vend. endl oop. * i f t hi s i s a new I Doc, check t o make sure i t even needs t he GR t est cl ear gr _requi red. l oop at dat a_r ec wher e segnam = ' E1EDP02' . move dat a_r ec- sdat a t o e1edp02. check: e1edp02- qual f = ' 001' , e1edp02- bel nr <> ' ' , e1edp02- zei l e <> ' ' . * Not e t hat a mi ssi ng PO number / l i ne number i s NOT an er r or her e * t he I Doc wi l l err or i n the st andar d SAP pr ocessi ng i n RBDAPP01 shi f t e1edp02- bel nr l ef t del et i ng l eadi ng ' 0' . cl ear : po_number , po_l i neno. i f e1edp02- bel nr co ' 0123456789' . po_number = e1edp02- bel nr. endi f . i f e1edp02- zei l e co ' 0123456789' . po_l i neno = e1edp02- zei l e. endi f . sel ect si ngl e webr e f r omekpo i nt o gr _r equi r ed wher e ebel n = po_number and ebel p = po_l i neno. i f ( s y- s ubr c i s i ni t i al and gr _ r e qui r e d = ' X' ) . exi t . endi f . endl oop. " E1EDP02 segment s * i f any l i ne i t em on thi s i nvoi ce r equi res a goods r ecei pt , cont i nue * r ecei pt eval uati on. Ot her wi se, st atus t he I Doc to go to st andar d SAP * pr ocessi ng. ( Assumpti on i s made that i f an I Doc has st at us 66, t he GR * f l ag was t ur ned "on" at some poi nt and has si nce been r emoved. ) i f gr _requi red i s i ni t i al . "no goods recei pt requi r ed i f i edi dc - s t at us = ' 66' . * ' Goods Recei pt no l onger r equi r ed' per f or m i doc _ st at u s_ updat e us i ng ' 64' ' 026' ' ' ' ' . endi f . cont i nue. "next I Doc endi f . * Shoul d be onl y one K02, but l oop j ust i n case. . . l oop at dat a_r ec wher e segnam = ' E1EDK02' . move dat a_r ec- sdat a t o e1edk02. i f e1edk02- qual f = ' 009' . * i f an i nvoi ce al ready exi sts f or t hi s ref. no. , gi ve t he I Doc * an error status sel ect si ngl e bel nr f rom r bkp i nt o rbkp- bel nr wher e xbl nr = e1edk02-bel nr ( 16) and bl ar t = ' KR' "i nvoi ce and s t bl g = ' ' . " no r e ver s al i f s y- s ubr c i s i ni t i al . *' I nvoi ce & al ready exi sts f or ref . no. &' c _ i nvoi c = r b kp- bel nr . s hi f t c _i nvoi c l ef t del et i ng l eadi ng ' 0' . perf orm i doc_st atus_update usi ng ' 51' ' 027' c_i nvoi c e1edk02- bel nr ( 16) . exi t . "exi t l oop on dat a recs for t hi s I Doc endi f . c l ear : i t a b_ gr , gr _ q t y. r e f r es h: i t a b_ gr . sel ect a~mbl nr b~bwar t b~er f mg i nt o cor respondi ng fi el ds of t abl e i t ab_gr f r om mkpf as a i nner j oi n mseg as b on a~mbl nr = b~mbl nr wher e a~vgart = ' WE' " goods r ecei pt f or PO and a~bl art = ' WE' "goods r ecei pt and a~xbl nr = e1edk02- bel nr( 16) . l oop at i t ab_ gr .
case i t ab_gr- bwart . when ' 101' . "r ecei pt gr_qty = gr_ qt y + i t ab_gr- er f mg. when ' 102' . "r ever sal gr_qty = gr_ qt y - i t ab_gr- er f mg. endcase. endl oop. * i f no goods r ecei pt i f gr _ q t y <= 0. case i edi dc- status. * i f new I Doc, status to ' 66' when ' 64' . * ' Wai t i ng f or Goods Recei pt ' per f or m i doc _ st a t u s_ updat e us i ng ' 66' ' 022' ' ' ' ' . * i f r epr ocessed I Doc, check l ength of del ay and st atus t o 51 * ( l at e r e cei pt ) i f > 10 days . when ' 66' . cl ear l ead_t i me. sel ect si ngl e pl i f z fr om l f m1 i nt o l ead_t i me where l i f nr = vendor _i d and ekor g = ' 7100' . i f l ead_ t i me i s i ni t i al . l ead_t i me = 10. endi f . t est_dat e = i edi dc- credat + l ead_t i me. **TEST ** i f t est_dat e > sy- dat um. **TEST i f t est _date <= sy-dat um. * ' Goods Recei pt Over due' per f or m i doc _ st a t us _ updat e us i ng ' 51' ' 024' ' ' ' ' . el s e. * do nothi ng - I Doc stays i n stat us 66 and gets t ested f or GR i n next * j ob run endi f . endcase. el se. "goods recei pt exi st s * i f t hi s i s a repr ocess of an I Doc for whi ch a goods recei pt now * exi st s, gi ve t he I Doc st atus 64, so i t i s processed by RBDAPP01 * i n t he next j ob st ep. i f i edi dc- s t at us = ' 66' . c_mbl nr = mkpf - mbl nr. s hi f t c _ mbl nr l ef t del et i ng l eadi ng ' 0' . * ' Goods Recei pt f ound for r ef . no. &' per f or m i doc_st at us_updat e usi ng ' 64' ' 023' e1edk02- bel nr ( 16) ' ' . endi f . endi f . el se. "wr ong K02 qual i f i er * do nothi ng - I Doc wi l l t r y t o post and be handl ed manual l y endi f . " QUALF=' 009' endl oop. "dat a_rec endi f . "successf ul r et r i eval of I Doc data segment s > dat a_r ec endl oop.
"i edi dc
end- of - s el ec t i on. *----------------------------------------------------------------------* FORM I DOC_STATUS_UPDATE * Cr eat es st atus r ecords f or t he sel ect ed I Docs. *----------------------------------------------------------------------FORM I DOC_STATUS_UPDATE usi ng val ue( i _s t at ) val ue( i _msgno) val ue( i _msgv1) val ue(i _msgv2) . t abl es: edi _ds, t ede2. DATA: MESS l i ke EDI MESSAGE. dat a: l _commi t _count er i nbsync t _ coupl e_t o_pr ocess
LI KE edi gl odat a- comcount val ue ' 00000001' , LI KE edi gl odat a- i nbsync, LI KE edi i nbound OCCURS 0 WI TH HEADER LI NE.
CALL FUNCTI ON ' EDI _DOCUMENT_ OPEN_FOR_PROCESS'
EXPORTI NG DOCUMENT_ NUMBER I MPORTI NG I DOC_CONTROL EXCEPTI ONS DOCUMENT_FOREI GN_ LOCK DOCUMENT_ NOT_ EXI ST DOCUMENT_ NUMBER_I NVALI D ERROR_MESSAGE OTHERS
= i edi dc- docnum = I EDI DC = = = = =
01 02 03 04 05.
I F NOT SY- SUBRC I S I NI TI AL. c_docnum = i edi dc- docnum. s hi f t c _ doc num l ef t del et i ng l eadi ng ' 0' . * ' Cannot open I NVOI C I Doc & f or Goods Recei pt processi ng' message w025 wi t h c_ docnum. r c = ' X' . exi t . ENDI F. CLEAR EDI _DS. EDI _ DS- DOCNUM EDI _DS- STATUS EDI _DS- REPI D EDI _DS- TABNAM EDI _ DS- MANDT EDI _DS- STAMQU EDI _DS- STAMI D EDI _ DS- STAMNO EDI _DS- STAPA1 EDI _DS- STAPA2 GET TI ME. EDI _ DS- LOGDAT EDI _DS- LOGTI M
= = = = = = = = = =
i edi dc- DOCNUM. i _st at. ' ZS7BM000007' . ' EDI _DS' . SY- MANDT. ' SAP' . ' ZS7' . i _ msgno. i _msgv1. i _msgv2.
= SY- DATUM. = SY- UZEI T.
CALL FUNCTI ON ' EDI _DOCUMENT_STATUS_SET' EXPORTI NG DOCUMENT_ NUMBER = i edi dc- DOCNUM I DOC_STATUS = edi _ds I MPORTI NG I DOC_ CONTROL = i edi dc EXCEPTI ONS DOCUMENT_ NUMBER_ I NVALI D =1 OTHER_FI ELDS_I NVALI D =2 STATUS_I NVALI D =3 OTHERS =4 . I F NOT SY- SUBRC I S I NI TI AL. c_docnum= i edi dc- docnum. s hi f t c _ doc num l ef t del et i ng l eadi ng ' 0' . * I Doc no. & f ai l ed st atus update t o & message w021 wi t h c_docnum i _s t at . ENDI F. CALL FUNCTI ON ' EDI _DOCUMENT_ CLOSE_ PROCESS' EXPORTI NG DOCUMENT_ NUMBER = i edi dc- DOCNUM. i f i _st at = ' 51' . cl ear : t _coupl e_t o_process. r ef r esh: t _coupl e_t o_process. sel ect si ngl e * f r omt ede2 i nt o t ede2 wher e evcode = ' I NVL' . i f sy- s ubr c i s i ni t i al . t _coupl e_t o_process( 16) = i edi dc- docnum. t _coupl e_t o_pr ocess+16( 138) = t ede2. append t _coupl e_t o_pr ocess. PERFORM anal yzi ng_event_ cr eat e TABLES t _coupl e_t o_pr ocess USI NG l _commi t _count er i nbsync. i f sy- s ubr c i s i ni t i al .
MESS- MSGI D = ' ZS7' . MESS- MSGTY = ' E' . MESS- MSGNO = i _ msgno. MESS- MSGV1 = i _ msgv1. MESS- MSGV2 = i _ msgv2. CALL FUNCTI ON ' I DOC_ERROR_WORKFLOW_START' EXPORTI NG DOCNUM =0 EVENTCODE = ' EDI M' MESS = mess STATUSMESS = mess EXCEPTI ONS NO_ ENTRY_I N_TEDE5 =1 ERROR_I N_START_ WORKFLOW =2 OTHERS = 3. COMMI T WORK. endi f . " l i nk c r eat e d endi f . "t ede2 f ound endi f . * Set r et ur n code to st op furt her pr ocessi ng of t hi s I Doc r c = ' X' . ENDFORM. *----------------------------------------------------------------------* FORM ANALYZI NG_EVENT_CREATE * Cr eat es l i nk bet ween I Doc and workf l ow cont ai ner . * SAP code st ol en f r om LEDI NF01 *----------------------------------------------------------------------FORM anal yzi ng_event_ cr eat e TABLES t _c oupl e_t o_pr ocess_i n STRUCTURE edi i nbound USI NG commi t _count er_ i n LI KE edi gl odat a- comcount st art _r ecf b_synchr on_i n LI KE edi gl odata- i nbsync. * l oc al var i abl es DATA: * i nst ance t hat i s creat ed l _obj ect TYPE swc_obj ect , * obj ect key, e. g I Doc number l _obj ect _key LI KE swot obj i d- obj key, * i d of wf event l _event _i d LI KE swedumevi d-evti d, * st at us recor d f or case of er r or l _st atus_recor d TYPE t i doc_st at us_r ecor d_ext , * f l ag i ndi cat i ng whet her subscri bed task i s st ar t ed synchr onousl y l _st art _r ecf b_synchr on LI KE swef l ags- syncf l ag VALUE ' ' , * i doc number ( needed because of t ype checki ng) l _i doc_number LI KE edi dc- docnum. * l ocal const ant s CONSTANTS: * obj ect t ype ' I DOC' c_obj ect _t ype LI KE swet ypecou- obj t ype VALUE ' I DOCI NVOI C' , * name of event t o be cr eated c_ i dc_ evt LI KE swet ypecou- event VALUE ' I NPUTERROROCCURREDMM' . i f t _ c oupl e_ t o_ pr oc es s_ i n[ ] i s i ni t i al . COMMI T WORK. CALL FUNCTI ON ' DEQUEUE_ALL' . CLEAR commi t _c ount er _i n. exi t . endi f . * cast l _start _r ecf b_synchr on = start _r ecf b_synchron_i n. * decl ar ati on of cont ai ner swc_cont ai ner l _t _ev_cont ai ner . * i ni t i al i z e c ont a i ner swc_cl ear _cont ai ner l _t _ev_cont ai ner . * dequeue al l i docs at t he same t i me
LOOP AT t _coupl e_t o_process_i n. * cast l _i doc_number = t _coupl e_to_pr ocess_i n( 16) . CALL FUNCTI ON ' EDI _DOCUMENT_ DEQUEUE_ LATER' EXPORTI NG docnum = l _i doc_number EXCEPTI ONS OTHERS = 0. ENDLOOP. * get f i r st i doc number i n t abl e i n or der t o cr eat e an obj ect READ TABLE t _coupl e_t o_pr ocess_ i n I NDEX 1. * set obj ect key i n var i abl e of cor r ect t ype ( cast i ng) l _obj ect_key = t _coupl e_t o_pr ocess_i n( 16) . * cr eate an obj ect , i . e. an I Doc swc_creat e_obj ect l _obj ect c_obj ect _t ype l _obj ect _key. * f i l l c ont a i ner : wor k i t e m obj ec t i d ( i doc ) swc_set _el ement l _t _ev_cont ai ner "EC * c_el ement _wi _obj _i d "EC * l _obj ect. "EC * * f i l l cont ai ner : Number Pl usEvent code ( t abl e of coupl es) swc_set _t abl e l _t _ev_cont ai ner c_el ement _no_pl us_i nfo t _coupl e_t o_process_i n. * f i r e event t hat wi l l t r i gger t he i doc i nbound pr ocessi ng CALL FUNCTI ON ' SWE_EVENT_CREATE' EXPORTI NG obj t ype = c_obj ect _t ype obj key = l _obj ect_key event = c_i dc_evt * CREATOR =' ' * START_WI TH_DELAY =' ' st ar t _r ecf b_synchr on = l _st ar t _r ecf b_synchr on I MPORTI NG event _i d = l _event _i d TABLES event _cont ai ner = l _t _ev_cont ai ner EXCEPTI ONS obj t ype_not_ f ound =1 OTHERS = 2. IF ( sy- subrc <> 0 ) * event was not cr eat ed => err or handl i ng for t hi s i doc (EDI M) OR ( l _event _i d = 0 ) . * st op processi ng, no commi t MESSAGE I D ' E0' TYPE ' A' NUMBER ' 374' WI TH l _st at us_r ecor d- docnum c_i dc_evt RAI SI NG event _cr eat e_f ai l ed. ELSE. * do commi t and r eset count er * t he commi t wi l l get t he i docs t o t he dat abase and at t he same t i me * act i vat e t he event t hat was created COMMI T WORK. * dequeue al l unprocessed I Docs to avoi d l og- overf l ow CALL FUNCTI ON ' DEQUEUE_ALL' . CLEAR commi t _c ount er _i n. * r eset t abl e of i docs that need t o be pr ocessed CLEAR t_ coupl e_t o_pr ocess_i n. REFRESH t _coupl e_t o_process_i n. ENDI F. ENDFORM.
* Functi on : Up/ Downl oad ABAP r eport s compl et e wi t h t ext s * *----------------------------------------------------------------------* * Change Log : * * J ul y 5, 1999 * * - Combi ned exi st i ng programs t hat di d t he upl oad and downl oad i nto* * - one program. * * - Changed f ormat t hat the r eport s are saved i n t o be compat i bl e * * wi t h Wol f gang Mor gent hal er ' s upl oad/ downl oad progr am( YSTRASN00 * * at www. ant arcon. de) . Maj or di f f erences bet ween t hi s program and* * Wol f gang' s are: * - t hi s pr ogr amdoes not update TRDI R wi t h t he * * TRDI R ent r i es t hat are i n t he pr ogr amupl oaded. I nstead, * * cur r ent user s st at s are used. * * - t h i s pr o gr a m a l l ows s el ec t i on of r e por t s f r o m a l i s t or * * a si ngl e r eport can be t uped i n and upl oaded * * - t hi s program al so updat es TADI R so t hat a devel opment cl ass* * i s assi gned t o t he pr ogr am * * - t hi s pr ogr am checks t o see i f t he pr ogr amal r eady has a * * TRDI R ent r y, and i f i t does, warns t he user * * - t hi s pr ogr am wi l l save/ r est or e t he pr ogr am documenati on t oo* * * * * * * *----------------------------------------------------------------------* REPORT ZKBPROGS NO STANDARD PAGE HEADI NG LI NE-SI ZE 255. *----------------------------------------------------------------------* * Decl are Database Obj ect s * *----------------------------------------------------------------------* t abl es : DOKI L, TRDI R. *----------------------------------------------------------------------* * Const ant s * CONSTANTS: MC_TRDI R_ I DENTI FI ER( 72) TYPE C VALUE ' %&%& RDI R' , MC_REPORT_I DENTI FI ER( 72) TYPE C VALUE ' %&%& REPO' , MC_TEXT_I DENTI FI ER( 72) TYPE C VALUE ' %&%& TEXP' , MC_THEAD_ I DENTI FI ER( 72) TYPE C VALUE ' %&%& HEAD' , MC_DOC_I DENTI FI ER( 72) TYPE C VALUE ' %&%& DOKL' , MC_TRDI R_ SHORT( 4) TYPE C VALUE ' RDI R' , MC_REPORT_SHORT( 4) TYPE C VALUE ' REPO' , MC_TEXT_SHORT( 4) TYPE C VALUE ' TEXP' , MC_THEAD_ SHORT( 4) TYPE C VALUE ' HEAD' , MC_DOC_SHORT( 4) TYPE C VALUE ' DOKP' . *----------------------------------------------------------------------* *----------------------------------------------------------------------* * Decl are Modul e l evel data st r uct ur es * *----------------------------------------------------------------------* DATA: BEGI N OF MTAB_ PROGRAM_ SOURCE OCCURS 0, LI NE(72) TYPE C, END OF MTAB_ PROGRAM_SOURCE. DATA: MTAB_PROGRAM_TRDI R LI KE TRDI R OCCURS 0 WI TH HEADER LI NE. DATA: MTAB_ PROGRAM_TEXTS L I KE TEXTPOOL OCCURS 0 WI TH HEADER LI NE. DATA: MSTR_THEAD LI KE THEAD. DATA: BEGI N OF MTAB_PROGRAM_ FI LE OCCURS 0, LI NE(275) TYPE C, END OF MTAB_PROGRAM_FI LE. DATA: BEGI N OF MTAB_DI RECTORY OCCURS 0, NAME LI KE TRDI R- NAME, DESC( 72) TYPE C, SAVENAME LI KE RLGRAP- FI LENAME, END OF MTAB_DI RECTORY. DATA: BEGI N OF MTAB_ PROGRAM_ DOCUMENTATI ON OCCURS 0, LI NE(255) TYPE C, END OF MTAB_ PROGRAM_DOCUMENTATI ON. *----------------------------------------------------------------------* * Sel ecti on Scr een * *----------------------------------------------------------------------* *- - Opti ons f or upl oad/ downl oad of programs SELECTI ON- SCREEN BEGI N OF BLOCK FRM_ OPTI ONS WI TH FRAME TI TLE TEXT- UDL. PARAMETERS: RB_DOWN RADI OBUTTON GROUP UDL DEFAULT ' X' . " Downl oad r epor t s SELECTI ON- SCREEN BEGI N OF BLOCK FRM_ TRDI R WI TH FRAME TI TLE TEXT- DI R. SELECT- OPTI ONS: S_NAME FOR TRDI R- NAME, " Pr ogr am Name
S_SUBC
FOR TRDI R- SUBC " Pr ogr am Type DEFAULT ' F' OPTI ON EQ SI GN E, " Excl ude Funct i ons by def aul t S_CNAM FOR TRDI R- CNAM " Cr eat ed by DEFAULT SY- UNAME, S_UNAM FOR TRDI R- UNAM, " Las t Changed by S_CDAT FOR TRDI R- CDAT, " Cr eat i on dat e S_UDAT FOR TRDI R- UDAT. " Las t updat e dat e SELECTI ON- SCREEN END OF BLOCK FRM_TRDI R. *- - Opti ons f or upl oadi ng pr ogr ams PARAMETERS: RB_UP RADI OBUTTON GROUP UDL. " Upl oad r epor t s SELECTI ON- SCREEN BEGI N OF BLOCK FRM_ UPLOAD WI TH FRAME TI TLE TEXT- UPL. SELECTI ON- SCREEN BEGI N OF L I NE. SELECTI ON- SCREEN COMMENT 1( 29) TEXT- SNG. PARAMETERS: RB_FI LE RADI OBUTTON GROUP HOW DEFAULT ' X' . SELECTI ON- SCREEN COMMENT 33( 42) TEXT- FNA. SELECTI ON- SCREEN END OF LI NE. PARAMETERS: RB_L I ST RADI OBUTTON GROUP HOW. SELECTI ON- SCREEN END OF BLOCK FRM_UPLOAD. SELECTI ON- SCREEN END OF BLOCK FRM_OPTI ONS. *- - Opti ons f or up/ downl oadi ng programs SELECTI ON- SCREEN BEGI N OF BLOCK FRM_ FI LEN WI TH FRAME TI TLE TEXT- FI L. PARAMETERS: RB_DOS RADI OBUTTON GROUP FI L DEFAULT ' X' , " Save t o l ocal RB_UNI X RADI OBUTTON GROUP FI L, " Save t o UNI X P_PATH LI KE RLGRAP- FI LENAME " Pat h t o save f i l es t o DEFAULT ' c: \ t emp\ ' . SELECTI ON- SCREEN END OF BLOCK FRM_FI LEN. AT SEL ECTI ON- SCREEN ON VALUE- REQUEST FOR S_NAME- LOW. CALL FUNCTI ON ' F4_ PROGRAM' EXPORTI NG OBJ ECT = S_NAME- LOW SUPPRESS_SELECTI ON = ' X' I MPORTI NG RESULT = S_NAME- LOW EXCEPTI ONS OTHERS = 1. AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR S_NAME- HI GH. CALL FUNCTI ON ' F4_ PROGRAM' EXPORTI NG OBJ ECT = S_NAME- HI GH SUPPRESS_SELECTI ON = ' X' I MPORTI NG RESULT = S_NAME- HI GH EXCEPTI ONS OTHERS = 1. AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR S_ UNAM- LOW. PERFORM GET_ NAME USI NG ' S_ UNAM- LOW' CHANGI NG S_ UNAM- LOW. AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR S_UNAM- HI GH. PERFORM GET_ NAME USI NG ' S_UNAM- HI GH' CHANGI NG S_ UNAM- HI GH. AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR S_ CNAM- LOW. PERFORM GET_ NAME USI NG ' S_ CNAM- LOW' CHANGI NG S_ CNAM- LOW. AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR S_CNAM- HI GH. PERFORM GET_ NAME USI NG ' S_CNAM- HI GH' CHANGI NG S_CNAM- HI GH. TOP- OF- PAGE. I F RB_ LI ST = ' X' . FORMAT COLOR COL_HEADI NG. NEW- LI NE. WRI TE: AT 3 TEXT- H01, AT 15 TEXT- H03. FORMAT COLOR OFF . ENDI F. AT LI NE- SELECTI ON. CHECK RB_LI ST = ' X' . " onl y do i n l i st mode READ LI NE SY- CUROW FI ELD VALUE MTAB_DI RECTORY- SAVENAME. *- - Read f i l e i nt o an i nt ernal t abl e PERFORM READ_REPORT_FROM_DI SK TABLES MTAB_PROGRAM_ FI LE USI NG MTAB_DI RECTORY- SAVENAME. *- - Spl i t t abl e i nt o TADI R ent r y, repor t l i nes, and report t ext PERFORM SPLI T_I NCOMI NG_ FI LE TABLES MTAB_ PROGRAM_ FI LE MTAB_ PROGRAM_ SOURCE
MTAB_ PROGRAM_ TEXTS MTAB_ PROGRAM_ DOCUMENTATI ON CHANGI NG TRDI R MSTR_THEAD.
*- - Save al l of t he data PERFORM I NSERT_ NEW_REPORT TABLES MTAB_PROGRAM_SOURCE MTAB_ PROGRAM_TEXTS MTAB_ PROGRAM_DOCUMENTATI ON USI NG TRDI R MSTR_THEAD. *----------------------------------------------------------------------* * St ar t of pr ocessi ng * *----------------------------------------------------------------------* START- OF- SELECTI ON. FORMAT COLOR COL_ NORMAL. I F RB_DOWN = ' X' . PERFORM DOWNLOAD_REPORTS. ELSEI F RB_UP = ' X' . PERFORM UPLOAD_REPORTS. ENDI F. END- OF- SELECTI ON. I F RB_DOWN = ' X' . CONCATENATE P_ PATH ' di r ec t or y. t x t ' I NTO P_PATH. PERFORM SAVE_TABLE_ TO_FI LE TABLES MTAB_DI RECTORY USI NG P_PATH. ENDI F. *---------------------------------------------------------------------* * FORM UPLOAD_ REPORTS * *---------------------------------------------------------------------* FORM UPLOAD_REPORTS. *- - Can upl oad a r epor t s ent er ed i n sel ect i on cri t er i a or * - - s el ec t f r o m a l i s t . L i s t c an be f r o m i ndex. t x t i n s ame di r e ct or y *- - ( creat ed by t he downl oad) or by readi ng t he f i r st l i ne of each f i l e * - - i n t h e di r e ct o r y. I F RB_ FI L E = ' X' . " Upl oad s i ngl e pr o gr a m f r o m a f i l e *- - Read f i l e i nt o an i nt ernal t abl e PERFORM READ_ REPORT_FROM_DI SK TABLES MTAB_PROGRAM_FI LE USI NG P_PATH. *- - Spl i t t abl e i nt o TADI R ent r y, repor t l i nes, and report t ext PERFORM SPLI T_ I NCOMI NG_FI LE TABLES MTAB_ PROGRAM_ FI LE MTAB_ PROGRAM_ SOURCE MTAB_ PROGRAM_ TEXTS MTAB_ PROGRAM_ DOCUMENTATI ON CHANGI NG TRDI R MSTR_THEAD. *- - Save al l of t he data PERFORM I NSERT_NEW_REPORT TABLES MTAB_ PROGRAM_ SOURCE MTAB_ PROGRAM_ TEXTS MTAB_ PROGRAM_ DOCUMENTATI ON USI NG TRDI R MSTR_THEAD. ELSEI F RB_LI ST = ' X' . " Show l i st f or user t o choose f r om *- - get l i st of r eport names/ descri pt i ons fr om di r ectory text CONCATENATE P_ PATH ' di r ec t or y. t x t ' I NTO P_PATH. PERFORM READ_ REPORT_FROM_DI SK TABLES MTAB_DI RECTORY USI NG P_PATH. SORT MTAB_DI RECTORY. *- - Wr i t e out l i st of report names/ descri pt i ons LOOP AT MTAB_DI RECTORY. WRI TE: / MTAB_DI RECTORY- NAME UNDER TEXT- H01, MTAB_DI RECTORY- DESC UNDER TEXT- H03, MTAB_DI RECTORY- SAVENAME. ENDLOOP. *- - Pr ocess user sel ect i ons f or r eport s to upl oad. ENDI F. ENDFORM. " upl oad_r eport s *---------------------------------------------------------------------* * FORM DOWNLOAD_ REPORTS * *---------------------------------------------------------------------* * From t he user sel ect i ons, get al l pr ogr ams t hat meet t he * * cri t er i a, and save t hem i n f t ab_pr ogr am_di r ect ory. * * Al so save t he r epor t t o di sk. *
*---------------------------------------------------------------------* FORM DOWNLOAD_ REPORTS. DATA: LC_FULL_ FI LENAME LI KE RLGRAP- FI LENAME. *- - The t abl e i s put i nt o an i nt ernal t abl e because t he pr ogr am wi l l *- - abend i f mul t i pl e tr ansf er s t o a dataset occur wi t hi n a SELECT/ *- - ENDSELCT ( t est ed on 3. 1H) SELECT * FROM TRDI R I NTO TABLE MTAB_ PROGRAM_ TRDI R WHERE NAME I N S_ NAME AND SUBC I N S_ SUBC AND CNAM I N S_CNAM AND UNAM I N S_UNAM AND CDAT I N S_ CDAT AND UDAT I N S_UDAT. LOOP AT MTAB_PROGRAM_TRDI R. *- - Cl ear out t ext and sour ce code t abl es CLEAR: MTAB_PROGRAM_FI LE, MTAB_ PROGRAM_SOURCE, MTAB_ PROGRAM_TEXTS, MTAB_ PROGRAM_DOCUMENTATI ON. REFRESH: MTAB_PROGRAM_FI LE, MTAB_ PROGRAM_SOURCE, MTAB_ PROGRAM_TEXTS, MTAB_ PROGRAM_DOCUMENTATI ON. *- - Get t he r epor t READ REPORT MTAB_ PROGRAM_TRDI R- NAME I NTO MTAB_ PROGRAM_ SOURCE. *- - Get t he text f or t he report READ TEXTPOOL MTAB_ PROGRAM_ TRDI R- NAME I NTO MTAB_ PROGRAM_TEXTS. *- - Get t he document ati on f or t he report CLEAR DOKI L. SELECT * UP TO 1 ROWS FROM DOKI L WHERE I D = ' RE' AND OBJ ECT = MTAB_PROGRAM_TRDI R- NAME AND LANGU = SY- LANGU AND TYP = ' E' ORDER BY VERSI ON DESCENDI NG. ENDSELECT. *- - Document at i on exi st s f or t hi s obj ect I F SY- SUBRC = 0. CALL FUNCTI ON ' DOCU_READ' EXPORTI NG ID = DOKI L- I D LANGU = DOKI L- LANGU OBJ ECT = DOKI L- OBJ ECT TYP = DOKI L- TYP VERSI ON = DOKI L- VERSI ON I MPORTI NG HEAD = MSTR_ THEAD TABLES LI NE = MTAB_ PROGRAM_ DOCUMENTATI ON EXCEPTI ONS OTHERS = 1. ENDI F. *- - Put t he repor t code and texts i nt o a si ngl e fi l e *- - Put t he i dent i f i er l i ne i n so t hat t he start of t he TRDI R l i ne *- - i s marked CONCATENATE MC_TRDI R_I DENTI FI ER MTAB_ PROGRAM_ TRDI R- NAME I NTO MTAB_ PROGRAM_ FI LE- LI NE. APPEND MTAB_PROGRAM_FI LE. *- - Add t he TRDI R l i ne MTAB_ PROGRAM_ FI LE- LI NE = MTAB_PROGRAM_ TRDI R. APPEND MTAB_PROGRAM_FI LE. *- - Put t he i dent i f i er l i ne i n so t hat t he start of t he repor t code *- - i s marked CONCATENATE MC_REPORT_I DENTI FI ER MTAB_ PROGRAM_TRDI R- NAME I NTO MTAB_PROGRAM_FI LE- LI NE. APPEND MTAB_PROGRAM_FI LE. *- - Add t he report code LOOP AT MTAB_ PROGRAM_ SOURCE. MTAB_ PROGRAM_FI LE = MTAB_ PROGRAM_ SOURCE. APPEND MTAB_PROGRAM_FI LE. ENDLOOP.
* - - Put t he i dent i f i er l i ne i n s o t h at t h e s t a r t of t h e r e por t t e xt *- - i s marked CONCATENATE MC_TEXT_I DENTI FI ER MTAB_ PROGRAM_TRDI R- NAME I NTO MTAB_PROGRAM_FI LE- LI NE. APPEND MTAB_PROGRAM_FI LE. *- - Add t he repor t t exts LOOP AT MTAB_ PROGRAM_ TEXTS. MTAB_PROGRAM_FI LE = MTAB_PROGRAM_ TEXTS. APPEND MTAB_PROGRAM_FI LE. ENDLOOP. *- - Put t he i dent i f i er l i ne i n so t hat t he st ar t of t he THEAD r ecor d *- - i s marked CONCATENATE MC_THEAD_ I DENTI FI ER MTAB_ PROGRAM_TRDI R- NAME I NTO MTAB_PROGRAM_FI LE- LI NE. APPEND MTAB_PROGRAM_FI LE. MTAB_PROGRAM_ FI LE = MSTR_THEAD. APPEND MTAB_PROGRAM_FI LE. * - - Put t he i dent i f i er l i ne i n s o t h at t h e s t a r t of t h e r e por t *- - document at i on i s marked CONCATENATE MC_DOC_I DENTI FI ER MTAB_ PROGRAM_TRDI R- NAME I NTO MTAB_PROGRAM_FI LE- LI NE. APPEND MTAB_PROGRAM_FI LE. *- - Add t he r eport document at i on LOOP AT MTAB_ PROGRAM_ DOCUMENTATI ON. MTAB_ PROGRAM_FI LE = MTAB_ PROGRAM_ DOCUMENTATI ON. APPEND MTAB_PROGRAM_FI LE. ENDLOOP. *- - Make t he f ul l y pat hed f i l ename t hat r eport wi l l be saved t o CONCATENATE P_ PATH MTAB_ PROGRAM_TRDI R- NAME ' . t xt ' I NTO LC_ FULL_ FI LENAME. PERFORM SAVE_TABLE_ TO_FI LE TABLES MTAB_PROGRAM_FI LE USI NG LC_FULL_ FI LENAME. *- - Wr i t e out message wi t h Program Name/ Descr i pti on READ TABLE MTAB_ PROGRAM_ TEXTS WI TH KEY I D = ' R' . I F SY- SUBRC = 0. MTAB_DI RECTORY- NAME = MTAB_PROGRAM_TRDI R- NAME. MTAB_DI RECTORY- DESC = MTAB_PROGRAM_TEXTS- ENTRY. MTAB_ DI RECTORY- SAVENAME = LC_FULL_ FI LENAME. APPEND MTAB_DI RECTORY. WRI TE: / MTAB_PROGRAM_ TRDI R- NAME, MTAB_PROGRAM_ TEXTS- ENTRY( 65) COLOR COL_ HEADI NG. ELSE. MTAB_DI RECTORY- NAME = MTAB_PROGRAM_TRDI R- NAME. MTAB_DI RECTORY- DESC = ' No descr i pti on avai l abl e' . MTAB_ DI RECTORY- SAVENAME = LC_FULL_ FI LENAME. APPEND MTAB_DI RECTORY. WRI TE: / MTAB_PROGRAM_ TRDI R- NAME. ENDI F. ENDLOOP. ENDFORM. " BUI LD_PROGRAM_ DI RECTORY *---------------------------------------------------------------------* * FORM SAVE_TABLE_TO_F I LE * *---------------------------------------------------------------------* * ... ... .. * *---------------------------------------------------------------------* * - - > FTAB_TABLE * * - - > F_FI LENAME * *---------------------------------------------------------------------* FORM SAVE_TABLE_ TO_FI LE TABLES F TAB_ TABLE USI NG F_ FI LENAME. I F RB_DOS = ' X' . " Save f i l e t o pr esent at i on ser ver CALL FUNCTI ON ' WS_ DOWNLOAD' EXPORTI NG FI LENAME = F_ FI LENAME FI LETYPE = ' ASC' TABLES DATA_TAB = FTAB_TABLE EXCEPTI ONS OTHERS = 4. I F SY- SUBRC NE 0. WRI TE: / ' Er r or openi ng dat aset ' COLOR COL_NEGATI VE, F_ FI LENAME COLOR COL_ NEGATI VE.
ENDI F. ELSE. " Save f i l e t o appl i cat i on ser ver OPEN DATASET F_FI LENAME FOR OUTPUT I N TEXT MODE. I F SY- SUBRC = 0. LOOP AT FTAB_TABLE. TRANSFER FTAB_ TABLE TO F_ FI LENAME. I F SY- SUBRC NE 0. WRI TE: / ' Er r or wr i t i ng recor d to f i l e; ' COLOR COL_NEGATI VE, F_ FI LENAME COLOR COL_ NEGATI VE. ENDI F. ENDLOOP. ELSE. WRI TE: / ' Er r or openi ng dat aset ' COLOR COL_NEGATI VE, F_ FI LENAME COLOR COL_ NEGATI VE. ENDI F. ENDI F. " End RB_DOS ENDFORM. " SAVE_ PROGRAM *---------------------------------------------------------------------* * FORM READ_REPORT_FROM_DI SK * *---------------------------------------------------------------------* * Read r eport i nt o i nt er nal t abl e. Can r ead f r om l ocal or * * r emot e comput er * *---------------------------------------------------------------------* FORM READ_REPORT_FROM_ DI SK TABLES FTAB_TABLE USI NG F_ FI LENAME. DATA: LC_MESSAGE( 128) TYPE C. CLEAR FTAB_TABLE. REFRESH FTAB_TABLE. I F RB_DOS = ' X' . TRANSLATE F_ FI LENAME USI NG ' / \ ' . " cor r ect sl ash f or Dos PC f i l e CALL FUNCTI ON ' WS_ UPLOAD' EXPORTI NG FI LENAME = F_ FI LENAME FI LETYPE = ' ASC' TABLES DATA_TAB = FTAB_TABLE EXCEPTI ONS CONVERSI ON_ ERROR = 1 FI LE_ OPEN_ERROR =2 FI LE_ READ_ERROR =3 I NVALI D_ TABLE_ WI DTH = 4 I NVALI D_TYPE =5 NO_ BATCH =6 UNKNOWN_ERROR =7 OTHERS = 8. I F SY- SUBRC >< 0. WRI TE: / ' Err or r eadi ng f i l e f r oml ocal PC' COLOR COL_NEGATI VE. ENDI F. ELSEI F RB_UNI X = ' X' . TRANSLATE F_ FI LENAME USI NG ' \ / ' . " cor r ect sl ash f or uni x OPEN DATASET F_FI LENAME FOR I NPUT MESSAGE LC_MESSAGE I N TEXT MODE. I F SY- SUBRC = 0. DO. READ DATASET F_ FI LENAME I NTO FTAB_TABLE. I F SY- SUBRC = 0. APPEND FTAB_TABLE. ELSE. EXI T. ENDI F. ENDDO. CLOSE DATASET F_ FI LENAME. ELSE. WRI TE: / ' Er r or r eadi ng fi l e f r om r emote comput er ' COLOR COL_ NEGATI VE, / LC_MESSAGE, / F_FI LENAME. SY- SUBRC = 4. ENDI F. ENDI F. ENDFORM. " READ_REPORT_ FROM_ DI SK *---------------------------------------------------------------------* * FORM SPLI T_I NCOMI NG_FI LE * *---------------------------------------------------------------------* * ... ... .. * *---------------------------------------------------------------------*
* - - > FTAB_PROGRAM_FI LE * * - - > FTAB_PROGRAM_SOURCE * * --> ` * * - - > FTAB_PROGRAM_TEXTS * *---------------------------------------------------------------------* FORM SPLI T_I NCOMI NG_ FI LE TABLES FTAB_PROGRAM_FI LE STRUCTURE MTAB_ PROGRAM_FI LE FTAB_ PROGRAM_SOURCE STRUCTURE MTAB_ PROGRAM_SOURCE FTAB_PROGRAM_TEXTS STRUCTURE MTAB_ PROGRAM_TEXTS FTAB_ PROGRAM_DOCUMENTATI ON STRUCTURE MTAB_ PROGRAM_DOCUMENTATI ON CHANGI NG FSTR_ TRDI R FSTR_THEAD. DATA: LC_DATATYPE( 4) TYPE C, " Type of dat a, REPO, TEXP, RDI R LC_PROGRAM_FI LE LI KE MTAB_PROGRAM_FI LE. LOOP AT FTAB_PROGRAM_FI LE. LC_PROGRAM_FI LE = FTAB_PROGRAM_FI LE. CASE LC_PROGRAM_ FI LE( 9) . WHEN MC_ TRDI R_ I DENTI FI ER. LC_DATATYPE = MC_TRDI R_SHORT. WHEN MC_REPORT_I DENTI FI ER. LC_ DATATYPE = MC_REPORT_SHORT. WHEN MC_TEXT_I DENTI FI ER. LC_DATATYPE = MC_TEXT_SHORT. WHEN MC_DOC_I DENTI FI ER. LC_ DATATYPE = MC_DOC_SHORT. WHEN MC_THEAD_ I DENTI FI ER. LC_ DATATYPE = MC_THEAD_ SHORT. WHEN OTHERS. " Act ual content s of r eport , t r di r , or t ext CASE LC_DATATYPE. WHEN MC_TRDI R_SHORT. FSTR_ TRDI R = FTAB_PROGRAM_FI LE. WHEN MC_REPORT_ SHORT. FTAB_ PROGRAM_ SOURCE = FTAB_ PROGRAM_ FI LE. APPEND F TAB_PROGRAM_SOURCE. WHEN MC_TEXT_ SHORT. FTAB_PROGRAM_ TEXTS = FTAB_PROGRAM_FI LE. APPEND FTAB_PROGRAM_TEXTS. WHEN MC_THEAD_ SHORT. FSTR_THEAD = FTAB_PROGRAM_FI LE. WHEN MC_DOC_SHORT. FTAB_ PROGRAM_ DOCUMENTATI ON = FTAB_ PROGRAM_FI LE. APPEND FTAB_ PROGRAM_DOCUMENTATI ON. ENDCASE. ENDCASE. ENDLOOP. ENDFORM. " SPLI T_I NCOMI NG_FI LE *---------------------------------------------------------------------* * FORM I NSERT_ NEW_REPORT * *---------------------------------------------------------------------* * ... ... .. * *---------------------------------------------------------------------* * - - > FTAB_PROGRAM_SOURCE * * - - > FTAB_PROGRAM_TEXTS * * - - > F_TRDI R * *---------------------------------------------------------------------* FORM I NSERT_ NEW_REPORT TABLES FTAB_PROGRAM_SOURCE STRUCTURE MTAB_ PROGRAM_SOURCE FTAB_PROGRAM_TEXTS STRUCTURE MTAB_ PROGRAM_ TEXTS FTAB_ PROGRAM_DOCUMENTATI ON STRUCTURE MTAB_ PROGRAM_ DOCUMENTATI ON USI NG FSTR_TRDI R LI KE TRDI R FSTR_THEAD LI KE MSTR_THEAD. DATA: LC_OBJ _ NAME LI KE E071- OBJ _NAME, LC_LI NE2( 40) TYPE C, LC_ANSWER( 1) TYPE C. *- - read t r di r t o see i f t he report al r eady exi sts, i f i t does, pr ompt *- - user t o overwri t e or abort . SELECT SI NGLE * FROM TRDI R WHERE NAME = FSTR_TRDI R- NAME. I F SY- SUBRC = 0. " Al r eady exi st s CONCATENATE ' want t o over wr i t e r epor t ' FSTR_TRDI R- NAME
I NTO LC_LI NE2 SEPARATED BY SPACE. CONCATENATE L C_L I NE2 '?' I NTO LC_LI NE2. CALL FUNCTI ON ' POPUP_ TO_ CONFI RM_ STEP' EXPORTI NG DEFAULTOPTI ON = ' N' TEXTLI NE1 = ' The sel ect ed r epor t al r eady exi st s, do you' TEXTLI NE2 = LC_LI NE2 TI TEL = ' Repor t al r eady exi st s' CANCEL_ DI SPLAY = SPACE I MPORTI NG ANSWER = LC_ANSWER EXCEPTI ONS OTHERS = 1. ELSE. LC_ANSWER = ' J ' . ENDI F. I F LC_ANSWER = ' J ' . *- - Cr eat e t he TADI R ent r y. ( TRDI R ent r y cr eat ed by I NSERT REPORT) LC_OBJ _ NAME = TRDI R- NAME. CALL FUNCTI ON ' TR_ TADI R_ POPUP_ENTRY_E071' EXPORTI NG WI _E071_PGMI D = ' R3TR' WI _ E071_OBJ ECT = ' PROG' WI _ E071_OBJ _NAME = LC_OBJ _NAME WI _ TADI R_DEVCLASS = ' $TMP' EXCEPTI ONS EXI T =3 OTHERS = 4. I F SY- SUBRC = 0. *- - Cr eat e Report I NSERT REPORT FSTR_ TRDI R- NAME FROM FTAB_ PROGRAM_SOURCE. *- - Cr eat e Texts I NSERT TEXTPOOL FSTR_TRDI R- NAME FROM FTAB_ PROGRAM_TEXTS LANGUAGE SY- LANGU. *- - Save Document at i on CALL FUNCTI ON ' DOCU_UPDATE' EXPORTI NG HEAD = FSTR_ THEAD STATE = ' A' TYP = ' E' VERSI ON = ' 1' TABLES LI NE = FTAB_PROGRAM_ DOCUMENTATI ON EXCEPTI ONS OTHERS = 1. ELSE. WRI TE: / ' Er r or updat i ng t he TADI R ent r y' COLOR COL_NEGATI VE, ' Pr ogr am' COLOR COL_ NEGATI VE I NTENSI FI ED OFF, FSTR_TRDI R- NAME, ' was not l oaded i nt o SAP. ' COLOR COL_ NEGATI VE I NTENSI FI ED OFF. ENDI F. ELSE. WRI TE: / FSTR_TRDI R- NAME COLOR COL_ NEGATI VE, ' was not upl oaded i nto SAP. Act i on cancel l ed by user ' COLOR COL_ NEGATI VE I NTENSI FI ED OFF. ENDI F. ENDFORM. " I NSERT_ NEW_ REPORT *---------------------------------------------------------------------* * FORM GET_ NAME * *---------------------------------------------------------------------* * ... ... .. * *---------------------------------------------------------------------* * - - > VALUE( F_FI ELD) * * - - > F_NAME * *---------------------------------------------------------------------* FORM GET_ NAME USI NG VALUE( F_ FI ELD) CHANGI NG F_ NAME. DATA: LTAB_FI ELDS LI KE DYNPREAD OCCURS 0 WI TH HEADER LI NE, LC_PROG LI KE D020S- PROG, LC_DNUM LI KE D020S- DNUM. TRANSLATE F_ FI ELD TO UPPER CASE. r e f r e sh l t a b_ f i el ds . LTAB_FI ELDS- FI ELDNAME = F_FI ELD. append l t ab_f i el ds. LC_PROG = SY- REPI D .
LC_DNUM = SY- DYNNR . CALL FUNCTI ON ' DYNP_ VALUES_READ' EXPORTI NG DYNAME = LC_ PROG DYNUMB = LC_DNUM TABLES dynpf i el ds = l t a b_ f i el ds EXCEPTI ONS OTHERS = 01. r ead t abl e l t ab_f i el ds i ndex 1. I F SY- SUBRC EQ 0. F_ NAME = LTAB_FI ELDS- FI ELDVALUE. r e f r e sh l t a b_ f i el ds . ENDI F. CALL FUNCTI ON ' F4_USER' EXPORTI NG OBJ ECT = F_ NAME I MPORTI NG RESULT = F_ NAME. ENDFORM. " GET_NAME %&%& TEXPZKBPROGS I DI R Fi l e Downl oad Opt i ons ( Fi l e Sel ect i on) €{{{ I FI L Fi l e Opt i ons €{{{ I FNA Enter f i l ename bel ow ( under Fi l e Opti ons) *{{{ I H01 Pr og Name „{{{ I H03 Progr amDescri pt i on „{{{ I SNG Upl oad a si ngl e f i l e #{{{ I UDL Upl oad t o SAP/ Downl oad f r om SAP €{{{ I UPL Fi l e Upl oad Opt i ons „{{{ R Backup/ Rest ore program sour ce code wi t h t ext s - {{{ SP_PATH Pat h t o save pr ogr ams t o {{{ SRB_DOS Fi l es on l ocal comput er #{{{ SRB_DOWN Downl oad Pr ogr ams {{{ SRB_FI LE Upl oad a si ngl e f i l e {{{ SRB_LI ST Sel ect pr ogr am( s) f r om a l i st %{{{ SRB_UNI X Fi l es on r emot e comput er " {{{ SRB_UP Upl oad Pr ogr ams t o SAP - {{{ SS_CDAT {{{ SS_CNAM {{{ SS_ NAME {{{ SS_SUBC {{{ SS_ UDAT {{{ SS_UNAM User I D
Dat e Cr eat ed Cr eat ed by User I D Pr ogr am Name Pr ogr am Type Dat e Changed Last Changed by
*********************************************************** * Column type P not supported. *********************************************************** TABLES dd02l. DATA: zx030l LIKE x030l, p_number TYPE i, tablefound TYPE i. DATA: colorval TYPE i. DATA: packval TYPE p, totalrows TYPE n. DATA: w_area1(5000) TYPE c,charval(20) TYPE c. DATA: tablen TYPE i VALUE 255. DATA: BEGIN OF htmlview OCCURS 0, htmlcode(500) TYPE c, END OF htmlview. DATA BEGIN OF zdfies OCCURS 1000. INCLUDE STRUCTURE dfies. DATA END OF zdfies. DATA: BEGIN OF flditab OCCURS 0, fldname(11) TYPE c, END OF flditab. ************** PARAMETERS: tabname LIKE dd02l-tabname OBLIGATORY. ************** htmlview-htmlcode = 'Table Browser'. APPEND htmlview. htmlview-htmlcode = ' Table View : '. APPEND htmlview. htmlview-htmlcode = tabname. APPEND htmlview. htmlview-htmlcode = '
'. APPEND htmlview. *********************************************** PERFORM check-table-class. PERFORM read-direct-table. PERFORM downloadhtml. PERFORM showhtml. ******************************************** FORM check-table-class. tablefound = -1. SELECT * FROM dd02l WHERE tabname EQ tabname. IF dd02l-tabclass CS 'TRANSP' OR dd02l-tabclass CS 'POOL' OR dd02l-tabclass CS 'CLUSTER '. tablefound = 1. EXIT. ENDIF. ENDSELECT. IF tablefound < 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH 'Table Not Found.... or Table Class Not in "TRANSP","POOL", "CLUSTER"'. STOP. ENDIF. ENDFORM. ************************************************************************ FORM read-direct-table. DATA: offs TYPE i. DATA: len2(5) TYPE n. DATA: anz_numb TYPE i. PERFORM gettableinfo USING tabname. htmlview-htmlcode = '
'. APPEND htmlview. colorval = 1. SELECT COUNT(*) FROM (tabname) INTO totalrows. WRITE :/ totalrows.
anz_numb = 0. SELECT * FROM (tabname) INTO w_area1. ADD 1 TO anz_numb. IF anz_numb GT 100. " U can alter the Hits, now Max. is 100 EXIT. ENDIF. IF colorval > 0 . htmlview-htmlcode = '
'. APPEND htmlview. ELSE. htmlview-htmlcode = '
'. APPEND htmlview. ENDIF. colorval = colorval * -1 . ************* LOOP AT zdfies. charval = w_area1+zdfies-offset(zdfies-intlen). CASE zdfies-inttype. WHEN 'P'. * PACKVAL = W_AREA1+ZDFIES-OFFSET(ZDFIES-INTLEN). * CHARVAL = PACKVAL. ENDCASE. PERFORM htmlfield USING w_area1+zdfies-offset(zdfies-intlen). ENDLOOP. ************* htmlview-htmlcode = '
'. APPEND htmlview. CLEAR: w_area1. ENDSELECT. htmlview-htmlcode = ''. APPEND htmlview. ENDFORM. **************************************************************** FORM downloadhtml. CALL FUNCTION 'WS_DOWNLOAD' EXPORTING filename = 'C:\TABLEVIEW.HTM' TABLES data_tab = htmlview. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. *************************************************************** FORM showhtml. CALL FUNCTION 'WS_EXECUTE' EXPORTING commandline = 'c:\tableview.htm' program = 'C:\PROGRA~1\INTERN~1\IEXPLORE.EXE'. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. ************************************************************************ FORM gettableinfo USING tname. CALL FUNCTION 'GET_FIELDTAB' EXPORTING langu only tabname withtext IMPORTING header TABLES fieldtab EXCEPTIONS internal_error no_texts_found table_has_no_fields table_not_activ CASE sy-subrc. WHEN 0. LOOP AT zdfies.
= = = =
sy-langu space tname 'X'
= zx030l = zdfies = = = =
01 02 03 04.
ENDLOOP. WHEN OTHERS. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-subrc. ENDCASE. ENDFORM. ******************************************************** FORM htmlfield USING name TYPE c. htmlview-htmlcode = '
7.10.13 Tree reports REPORT ZIB_EXP_TREE_REP_SAMPLE LINE-COUNT 65 LINE-SIZE 80 NO STANDARD PAGE HEADING. ************************************************************************ * Author: Igor Barbaric * Expandable hierarchy tree report sample - very easy to build an * include program for universal usage! Consists of two main forms and * a sample tree. * Forms: * - "print_tree" prints the tree to the list out of * the given internal table; items may be mixed in any order * - "expand_collapse" - maintains the internal table in such way that * the selected branch is expanded or collapsed ********************************************************************* DATA: BEGIN OF ITEMS OCCURS 100, ID(10), PARENT_ID(10), TEXT(20), SYMBOL, END OF ITEMS, TABIX_STACK LIKE SY-TABIX OCCURS 10 WITH HEADER LINE, ITEMS_SHOW LIKE ITEMS OCCURS 100 WITH HEADER LINE. INCLUDE . * append sample items (mixed order) PERFORM APPEND_ITEM USING: "no. par. no. title '1' '' 'Food', '2' '' 'Drinks', '12' '9' 'Jack Daniels', '17' '11' 'Bosch', '3' '' 'Tools', '4' '1' 'Meat', '16' '11' 'Metabo', '5' '1' 'Chocolate', '6' '2' 'Alcoholic', '8' '4' 'Pork', '10' '5' 'Milka', '11' '3' 'Drills', '13' '9' 'Jim Beam', '7' '4' 'Beef', '14' '2' 'Non-alcoholic', '35' '31' 'Teran', '9' '6' 'Whiskey', '15' '14' 'Coca-cola', '18' '6' 'Wine', '28' '18' 'Croatia', '33' '28' 'Slavonia', '34' '28' 'Istria', '29' '18' 'Hungary', '30' '29' 'Tokaj', '19' '33' 'Enjingi', '20' '33' 'Zdjelarevic', '22' '19' 'Riesling', '23' '19' 'Chardonnay', '24' '20' 'Riesling', '32' '31' 'Malvazija', '25' '20' 'Merlot',
'31' '34'
'Tomasevic'.
* show initial list (items with level 0 - parentless items) LOOP AT ITEMS WHERE PARENT_ID = ''. MOVE-CORRESPONDING ITEMS TO ITEMS_SHOW. ITEMS_SHOW-SYMBOL = '+'. APPEND ITEMS_SHOW. ENDLOOP. PERFORM PRINT_TREE TABLES ITEMS_SHOW. * at line-selection - when the node is opened/closed or item double-clk AT LINE-SELECTION. READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS_SHOW-ID. "see 'hide' IF SY-SUBRC = 0. "item has children - expand or collapse SY-LSIND = 0. PERFORM EXPAND_COLLAPSE USING ITEMS_SHOW-ID. PERFORM PRINT_TREE TABLES ITEMS_SHOW. ELSE. "item has NO children - perform some action READ TABLE ITEMS WITH KEY ID = ITEMS_SHOW-ID. WRITE: 'Action performed on item "' NO-GAP, ITEMS-TEXT NO-GAP, '", id.', ITEMS-ID. ENDIF. * form print_tree FORM PRINT_TREE TABLES ITEMS STRUCTURE ITEMS. DATA: V_TABIX LIKE SY-TABIX, START_TABIX LIKE SY-TABIX, V_LEVEL LIKE SY-TFILL, V_OFFSET TYPE I, V_ID LIKE ITEMS-ID, V_PARENT_ID LIKE ITEMS-PARENT_ID, V_PARENT_ID_FOR_VLINE LIKE ITEMS-PARENT_ID, V_PREV_LEVEL TYPE I, V_ITEMS_COUNT LIKE SY-TFILL, V_VLINES_STRING(200). CHECK NOT ITEMS[] IS INITIAL. SORT ITEMS BY PARENT_ID ID. READ TABLE ITEMS INDEX 1. V_PARENT_ID = ITEMS-PARENT_ID. START_TABIX = 1. REFRESH TABIX_STACK. DO. LOOP AT ITEMS FROM START_TABIX. V_TABIX = START_TABIX = SY-TABIX. "remember current index V_ID = ITEMS-ID. V_PARENT_ID_FOR_VLINE = ITEMS-PARENT_ID. * decrease level and exit loop if parent not the same as previous IF ITEMS-PARENT_ID NE V_PARENT_ID. PERFORM READ_FROM_STACK CHANGING START_TABIX. "level = NoOfRecs READ TABLE ITEMS INDEX START_TABIX. V_PARENT_ID = ITEMS-PARENT_ID. ADD 1 TO START_TABIX. "next loop starts from parent index + 1 * clear vline IF V_LEVEL > 1. V_OFFSET = 2 + ( V_LEVEL - 2 ) * 3. IF V_LEVEL = 1. V_OFFSET = 1. ENDIF. V_VLINES_STRING+V_OFFSET = ' '. ENDIF. EXIT. ENDIF. V_PARENT_ID = ITEMS-PARENT_ID. * write item FORMAT COLOR OFF. DESCRIBE TABLE TABIX_STACK LINES V_LEVEL."level is no of StackRecs WRITE: / V_VLINES_STRING. V_OFFSET = V_LEVEL * 3. IF V_LEVEL NE 0. IF V_PREV_LEVEL < V_LEVEL. WRITE: AT V_OFFSET '|', / ''. WRITE: / V_VLINES_STRING. ENDIF. V_OFFSET = V_LEVEL * 3. WRITE AT V_OFFSET '|--'. ENDIF. V_OFFSET = V_OFFSET + 3. CASE ITEMS-SYMBOL.
WHEN '+'. WRITE AT V_OFFSET SYM_PLUS_FOLDER AS SYMBOL COLOR 4 INTENSIFIED HOTSPOT. WHEN '-'. WRITE AT V_OFFSET SYM_MINUS_FOLDER AS SYMBOL COLOR 4 INTENSIFIED HOTSPOT. WHEN OTHERS. FORMAT COLOR 5. ENDCASE. WRITE: ITEMS-TEXT. V_PREV_LEVEL = V_LEVEL. HIDE: ITEMS-ID. ADD 1 TO V_ITEMS_COUNT. READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS-ID. * increase level and exit loop if item has children IF SY-SUBRC = 0. START_TABIX = SY-TABIX. APPEND V_TABIX TO TABIX_STACK. "level is no of recs in stack V_PARENT_ID = ITEMS-PARENT_ID. * set vline V_TABIX = V_TABIX + 1. READ TABLE ITEMS INDEX V_TABIX. V_OFFSET = 2 + ( V_LEVEL - 1 ) * 3. IF V_LEVEL > 0. IF ITEMS-PARENT_ID = V_PARENT_ID_FOR_VLINE AND SY-SUBRC = 0. V_VLINES_STRING+V_OFFSET = '|'. ELSE. V_VLINES_STRING+V_OFFSET = ' '. ENDIF. ENDIF. EXIT. ENDIF. * at last - decrease level AT LAST. * clear vline IF V_LEVEL > 1. V_OFFSET = 2 + ( V_LEVEL - 2 ) * 3. IF V_LEVEL = 1. V_OFFSET = 1. ENDIF. V_VLINES_STRING+V_OFFSET = ' '. ENDIF. " next loop starts from parent index, not parent index + 1 " because of different parents level will decrease anyway PERFORM READ_FROM_STACK CHANGING START_TABIX. APPEND START_TABIX TO TABIX_STACK. "must return index to stack ENDAT. ENDLOOP. DESCRIBE TABLE ITEMS. IF START_TABIX > SY-TFILL OR V_ITEMS_COUNT >= SY-TFILL. EXIT. ENDIF. ENDDO. ENDFORM. * form expand_collapse FORM EXPAND_COLLAPSE USING VALUE(V_ID). DATA: V_NO_MORE_ORPHANS, ITEMS_TEMP LIKE ITEMS OCCURS 100 WITH HEADER LINE. DELETE ITEMS_SHOW WHERE PARENT_ID = V_ID. "try to collapse IF SY-SUBRC = 0. "succesfull first collapse DO. "cascade collapse - delete 'orphans' that are left REFRESH ITEMS_TEMP. MOVE ITEMS_SHOW[] TO ITEMS_TEMP[]. SORT ITEMS_TEMP BY ID. V_NO_MORE_ORPHANS = 'X'. LOOP AT ITEMS_SHOW WHERE PARENT_ID NE ''. READ TABLE ITEMS_TEMP WITH KEY ID = ITEMS_SHOW-PARENT_ID BINARY SEARCH TRANSPORTING NO FIELDS. IF SY-SUBRC NE 0. "no parent - it's an orphan CLEAR V_NO_MORE_ORPHANS. DELETE ITEMS_SHOW. ENDIF. ENDLOOP. IF V_NO_MORE_ORPHANS = 'X'. EXIT. ENDIF. ENDDO. ITEMS_SHOW-SYMBOL = '+'. MODIFY ITEMS_SHOW TRANSPORTING SYMBOL WHERE ID = V_ID. ELSE. "unsuccessfull collapse - expand ITEMS_SHOW-SYMBOL = '-'. MODIFY ITEMS_SHOW TRANSPORTING SYMBOL WHERE ID = V_ID.
LOOP AT ITEMS WHERE PARENT_ID = V_ID. "show children APPEND ITEMS TO ITEMS_SHOW. ENDLOOP. LOOP AT ITEMS_SHOW WHERE PARENT_ID = V_ID. "check grandchildren READ TABLE ITEMS WITH KEY PARENT_ID = ITEMS_SHOW-ID. IF SY-SUBRC = 0. ITEMS_SHOW-SYMBOL = '+'. ELSE. ITEMS_SHOW-SYMBOL = ''. ENDIF. MODIFY ITEMS_SHOW. ENDLOOP. ENDIF. ENDFORM. * form append_item FORM APPEND_ITEM USING VALUE(ID) VALUE(PARENT_ID) VALUE(TEXT). ITEMS-ID = ID. ITEMS-PARENT_ID = PARENT_ID. ITEMS-TEXT = TEXT. APPEND ITEMS. ENDFORM. * form read_from_stack FORM READ_FROM_STACK CHANGING TABIX LIKE SY-TABIX. DESCRIBE TABLE TABIX_STACK. CHECK SY-TFILL NE 0. READ TABLE TABIX_STACK INDEX SY-TFILL. TABIX = TABIX_STACK. DELETE TABIX_STACK INDEX SY-TFILL. ENDFORM.
7.10.14 Shell List Report off a table - NAST REPORT znast. *** Table Definitions *** TABLES: nast. *** TYPE DEFINITIONS *** TYPES: BEGIN OF itab_data_structure, kappl LIKE nast-kappl, "Application objky LIKE nast-objky, "Key kschl LIKE nast-kschl, "Output type parnr LIKE nast-parnr, "Partner erdat LIKE nast-erdat, "Creation date usnam LIKE nast-usnam, "User name vstat LIKE nast-vstat. "Status TYPES: END OF itab_data_structure. TYPES: BEGIN OF itab_data_structure2, objky LIKE nast-objky, "Key docnum LIKE edidc-docnum, "Idoc Number mestyp LIKE edidc-mestyp. "Message type TYPES: END OF itab_data_structure2.
*** INTERNAL TABLE DEFINITIONS *** DATA: itab_data TYPE itab_data_structure OCCURS 0 WITH HEADER LINE, itab_data2 TYPE itab_data_structure2 OCCURS 0 WITH HEADER LINE, itab_linked_idocs LIKE sww_contob OCCURS 5 WITH HEADER LINE, t_roles LIKE relroles OCCURS 5 WITH HEADER LINE. *** DATA DEFINITIONS DATA: field_name(30), t_kschl(4), t_kunnr(10), t_object LIKE borident.
"Check for line selection on field "Output type "Customer number
*** Selection screen *** SELECTION-SCREEN BEGIN OF BLOCK g1 WITH SELECT-OPTIONS: s_kappl FOR nast-kappl, s_objky FOR nast-objky, s_kschl FOR nast-kschl, s_parnr FOR nast-parnr,
FRAME TITLE text-000. "Application "Key "Output type "Partner
s_erdat s_usnam s_vstat SELECTION-SCREEN END OF
FOR nast-erdat, "Creation date FOR nast-usnam, "User name FOR nast-vstat. "Status BLOCK g1.
SELECTION-SCREEN BEGIN OF BLOCK g2 WITH FRAME TITLE text-001. PARAMETERS: r_kappl RADIOBUTTON GROUP r1, r_objky RADIOBUTTON GROUP r1, r_kschl RADIOBUTTON GROUP r1, r_parnr RADIOBUTTON GROUP r1, r_erdat RADIOBUTTON GROUP r1, r_usnam RADIOBUTTON GROUP r1, r_vstat RADIOBUTTON GROUP r1. SELECTION-SCREEN END OF BLOCK g2. SELECTION-SCREEN BEGIN OF BLOCK g3 WITH FRAME TITLE text-002. PARAMETERS: c_idoc AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN END OF BLOCK g3. *** Initialization *** INITIALIZATION. * Default dates MOVE 'I' TO s_erdat-sign. MOVE 'BT' TO s_erdat-option. MOVE sy-datum TO s_erdat-high. SUBTRACT 7 FROM sy-datum. MOVE sy-datum TO s_erdat-low. APPEND s_erdat. * Default Status MOVE 'I' TO s_vstat-sign. MOVE 'NE' TO s_vstat-option. MOVE '1' TO s_vstat-low. APPEND s_vstat. * Default Output MOVE 'I' TO s_kschl-sign. MOVE 'EQ' TO s_kschl-option. MOVE 'ZBA0' TO s_kschl-low. APPEND s_kschl. MOVE 'ZBA1' TO s_kschl-low. APPEND s_kschl. MOVE 'ZBA2' TO s_kschl-low. APPEND s_kschl. MOVE 'ZP00' TO s_kschl-low. APPEND s_kschl. MOVE 'ZAVA' TO s_kschl-low. APPEND s_kschl. MOVE 'ZD00' TO s_kschl-low. APPEND s_kschl. START-OF-SELECTION. REFRESH: itab_data, itab_data2. SELECT * FROM nast WHERE kappl IN s_kappl AND objky IN s_objky AND kschl IN s_kschl AND parnr IN s_parnr AND erdat IN s_erdat AND usnam IN s_usnam AND vstat IN s_vstat. itab_data-kappl = nast-kappl. itab_data-objky = nast-objky. itab_data-kschl = nast-kschl. itab_data-parnr = nast-parnr. itab_data-erdat = nast-erdat. itab_data-usnam = nast-usnam. itab_data-vstat = nast-vstat. APPEND itab_data. ENDSELECT. IF sy-subrc <> 0. MESSAGE i999(b1) WITH 'No records in that range!'.
ELSE. IF c_idoc = 'X'. CLEAR: itab_data2. LOOP AT itab_data. itab_data2-objky = itab_data-objky. CASE itab_data-kschl. WHEN 'ZD00'. "Invoice READ TABLE itab_data2 WITH KEY objky = itab_data-objky. CHECK sy-subrc <> 0. REFRESH: t_roles. t_object-objkey = itab_data-objky. t_object-objtype = 'VBRK'. CALL FUNCTION 'SREL_GET_NEXT_RELATIONS' EXPORTING object = t_object TABLES roles = t_roles EXCEPTIONS internal_error = 1 no_logsys = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE i999(b1) WITH 'Could not execute linked docs FM:' itab_data-objky. ELSE. LOOP AT t_roles WHERE objtype = 'IDOC'. itab_data2-docnum = t_roles-objkey. SELECT SINGLE mestyp FROM edidc INTO itab_data2-mestyp WHERE docnum = t_roles-objkey. APPEND itab_data2. ENDLOOP. ENDIF. WHEN 'ZAVA'. "Delivery READ TABLE itab_data2 WITH KEY objky = itab_data-objky. CHECK sy-subrc <> 0. REFRESH: t_roles. t_object-objkey = itab_data-objky. t_object-objtype = 'LIKP'. CALL FUNCTION 'SREL_GET_NEXT_RELATIONS' EXPORTING object = t_object TABLES roles = t_roles EXCEPTIONS internal_error = 1 no_logsys = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE i999(b1) WITH 'Could not execute linked docs FM:' itab_data-objky. ELSE. LOOP AT t_roles WHERE objtype = 'IDOC'. itab_data2-docnum = t_roles-objkey. SELECT SINGLE mestyp FROM edidc INTO itab_data2-mestyp WHERE docnum = t_roles-objkey. APPEND itab_data2. ENDLOOP. ENDIF. WHEN 'ZBA0' OR 'ZBA1' OR 'ZBA2'. "Orders READ TABLE itab_data2 WITH KEY objky = itab_data-objky. CHECK sy-subrc <> 0. REFRESH: t_roles. t_object-objkey = itab_data-objky. t_object-objtype = 'BUS2032'. CALL FUNCTION 'SREL_GET_NEXT_RELATIONS' EXPORTING
AT LINE-SELECTION. GET CURSOR FIELD field_name. CASE field_name. WHEN 'ITAB_DATA2-DOCNUM' OR 'ITAB_DATA2-MESTYP'. "IDoc number CALL FUNCTION 'EDI_DOCUMENT_DATA_DISPLAY' EXPORTING docnum = itab_data2-docnum EXCEPTIONS no_data_record_found = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE i999(b1) WITH 'Could not display IDoc:' itab_data2-docnum. ENDIF. CLEAR: itab_data2-docnum. WHEN 'ITAB_DATA-OBJKY'. "Order number t_kschl = sy-lisel+34(4). CASE t_kschl. WHEN 'ZAVA'. "Delivery SET PARAMETER ID 'VL' FIELD itab_data-objky. CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN. WHEN 'ZBA0' OR 'ZBA1' OR 'ZBA2'. "Sales Order SET PARAMETER ID 'AUN' FIELD itab_data-objky. CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN. WHEN 'ZP00'. "Scheduling Agreement SET PARAMETER ID 'LPN' FIELD itab_data-objky. CALL TRANSACTION 'VA33' AND SKIP FIRST SCREEN. WHEN 'ZD00'. "Invoice SET PARAMETER ID 'VF' FIELD itab_data-objky. CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN. WHEN OTHERS. MESSAGE i999(b1) WITH 'Unrecognized Output Type!'. ENDCASE. WHEN 'ITAB_DATA-PARNR'. "Customer number t_kunnr = sy-lisel+39(10). SET PARAMETER ID 'KUN' FIELD itab_data-parnr. CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN OTHERS. MESSAGE i999(b1) WITH 'Please click the Doc or Partner #.'. ENDCASE. CLEAR: t_kunnr, t_kschl, field_name. *&---------------------------------------------------------------------* *& Form print_itab_data *&---------------------------------------------------------------------* * Print out ITAB_DATA *----------------------------------------------------------------------* * -->T_ITAB_DATA Internal Table Data *----------------------------------------------------------------------* FORM print_itab_data TABLES t_itab_data STRUCTURE itab_data t_itab_data2 STRUCTURE itab_data2. FORMAT COLOR COL_HEADING. WRITE: / 'App', 5 'Document Number', 35 'Type', 40 'Partner',
51 'Created on', 62 'Created by', 75 'Status'. FORMAT COLOR OFF. LOOP AT t_itab_data. FORMAT COLOR COL_NORMAL. WRITE: /1 t_itab_data-kappl, t_itab_data-objky, t_itab_data-kschl, t_itab_data-parnr, t_itab_data-erdat, t_itab_data-usnam. HIDE: t_itab_data-objky, t_itab_data-parnr. IF t_itab_data-vstat = '0'. "Not processed FORMAT COLOR COL_TOTAL. WRITE: t_itab_data-vstat, 'Not processed'. FORMAT COLOR OFF. ELSEIF t_itab_data-vstat = '1'. "Processed FORMAT COLOR COL_POSITIVE. WRITE: t_itab_data-vstat, 'Processed'. FORMAT COLOR OFF. ELSE. "Incorrectly Processed FORMAT COLOR COL_NEGATIVE. WRITE: t_itab_data-vstat, 'Incorrectly processed'. FORMAT COLOR OFF. ENDIF. IF c_idoc = 'X'. LOOP AT t_itab_data2 WHERE objky = t_itab_data-objky. WRITE:/ t_itab_data2-docnum, t_itab_data2-mestyp. HIDE t_itab_data2-docnum. ENDLOOP. ENDIF. ENDLOOP. ENDFORM.
" print_itab_data
7.10.15 ALV Report REPORT sy-repid. *----------------------------------------------------------------------*/ Description :This program creates an ALV report for Daily Cash * Receipts for a selected date range. *----------------------------------------------------------------------* Global data declaration TYPE-POOLS: slis. * Global structure of list TYPES: BEGIN OF i_cust_invoices, "This is a temp-table where SELECT "data is to be stored. bkpf LIKE bkpf, "Acct Doc Header structure bseg LIKE bseg, "Acct Doc Segment struc kna1 LIKE kna1, "Customer Master struc skat LIKE skat, "Chart of Accts struc END OF i_cust_invoices.
TABLES: bkpf, bseg, kna1, skat.
"TABLES: def of Database tables.
*/ Selection and Input Parameters SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME. SELECT-OPTIONS: s_belnr s_budat s_blart SELECTION-SCREEN END OF
DATA:
FOR bseg-belnr, FOR bkpf-budat, FOR bkpf-blart BLOCK block1.
"Acct Doc number "Doc Posting Date DEFAULT 'DZ'. "Document Type
gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: DATA: DATA:
gt_outtab TYPE i_cust_invoices OCCURS 0 WITH HEADER LINE. g_repid LIKE sy-repid. i_bkpf TYPE bkpf OCCURS 0 WITH HEADER LINE.
* Initialization fieldcatalog INITIALIZATION. g_repid = sy-repid. PERFORM fieldcat_init USING gt_fieldcat[]. * Start of Selection START-OF-SELECTION. * Data selection PERFORM select_data TABLES gt_outtab. * Display list END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_callback_program = g_repid it_fieldcat = gt_fieldcat[] TABLES t_outtab = gt_outtab. *----------------------------------------------------------------------* Forms *----------------------------------------------------------------------* Initialization fieldcatalog DEFINITION OF HEADING. * Fieldnames and ref_fieldnames MUST be UPPER CASE !! FORM fieldcat_init USING rt_fieldcat TYPE slis_t_fieldcat_alv. DATA: ls_fieldcat TYPE slis_fieldcat_alv. DATA: pos TYPE i VALUE 1. CLEAR ls_fieldcat. ls_fieldcat-col_pos = pos. ls_fieldcat-fieldname = 'BKPF-BUDAT'. ls_fieldcat-ref_fieldname = 'BUDAT'. ls_fieldcat-ref_tabname = 'BKPF'. ls_fieldcat-key = 'X'. APPEND ls_fieldcat TO rt_fieldcat. CLEAR ls_fieldcat. pos = pos + 1. ls_fieldcat-col_pos = pos. ls_fieldcat-fieldname = 'BSEG-BELNR'. ls_fieldcat-ref_fieldname = 'BELNR'. ls_fieldcat-ref_tabname = 'BSEG'. APPEND ls_fieldcat TO rt_fieldcat. CLEAR ls_fieldcat. pos = pos + 1. ls_fieldcat-col_pos = pos. ls_fieldcat-fieldname = 'BSEG-HKONT'. ls_fieldcat-ref_fieldname = 'HKONT'. ls_fieldcat-ref_tabname = 'BSEG'. APPEND ls_fieldcat TO rt_fieldcat. CLEAR ls_fieldcat. pos = pos + 1. ls_fieldcat-col_pos = pos. ls_fieldcat-fieldname = 'BSEG-KOSTL'. ls_fieldcat-ref_fieldname = 'KOSTL'. ls_fieldcat-ref_tabname = 'BSEG'. APPEND ls_fieldcat TO rt_fieldcat. CLEAR ls_fieldcat. pos = pos + 1. ls_fieldcat-col_pos ls_fieldcat-fieldname
* Data selection FORM select_data TABLES rt_outtab LIKE gt_outtab[]. DATA: l_name LIKE tline-tdline. * IF s_hkont IS INITIAL. SELECT
bukrs belnr blart budat usnam xblnr waers kursf INTO CORRESPONDING FIELDS OF TABLE i_bkpf FROM bkpf WHERE belnr IN s_belnr AND blart IN s_blart AND budat IN s_budat. LOOP AT i_bkpf. SELECT hkont kostl belnr gjahr buzei bschl shkzg dmbtr wrbtr sgtxt kunnr INTO (bseg-hkont, bseg-kostl, bseg-belnr, bseg-gjahr, bseg-buzei, bseg-bschl, bseg-shkzg, bseg-dmbtr, bseg-wrbtr, bseg-sgtxt, bseg-kunnr) FROM bseg WHERE belnr EQ i_bkpf-belnr. CLEAR: KNA1, skat. SELECT SINGLE * FROM skat WHERE SPRAS EQ SY-LANGU AND KTOPL EQ '7100' AND SAKNR = bseg-hkont.
"ska1, skb1 account # stored in SAKNR. "in BSEG, account # stored in HKONT. if bseg-SHKZG eq 'H'. multiply : bseg-wrbtr by -1, bseg-dmbtr by -1. endif. MOVE-CORRESPONDING: i_bkpf TO rt_outtab-bkpf, bseg TO rt_outtab-bseg, skat TO rt_outtab-skat.
SELECT SINGLE name1 INTO rt_outtab-kna1-name1 FROM KNA1 WHERE kunnr = rt_outtab-bseg-kunnr.
7.10.16 SAP Generated report \ Dialog Program REPORT AQA0SYSTQV000005ZMATCOST====== LI NE- SI ZE 253 NO STANDARD PAGE HEADI NG LI NE- COUNT 000( 001) . I NCLUDE . I NCLUDE . SELECTI ON- SCREEN: BEGI N OF BLOCK PROG WI TH FRAME TI TLE TEXT- F58.
TABLES MAKT. TABLES T001. TABLES MBEW. DATA %COUNT- MBEW( 4) TYPE X. DATA %LI NR- MBEW( 2) . DATA: BEGI N OF %J OI NWA, MBEW LI KE MBEW, MAKT LI KE MAKT, END OF %J OI NWA. TABLES AQLDB. I NCLUDE RSAQEXCD. DATA: BEGI N OF %ST_ LI STE OCCURS 100, HEAD( 1) , TAB( 3) , LI NE(6) TYPE N, CONT( 1) TYPE N, FI NT( 1) , FI NV( 1) , FCOL( 1) TYPE N, TEXT( 0253) , END OF %ST_ LI STE. DATA DATA DATA DATA DATA DATA DATA DATA
%DATA_ SELECTED( 1) . %GLFRAME( 1) VALUE ' X' . %UFLAG( 1) . %USTFLAG( 1) . %GRST_TEXT( 255) . %GLLI NE TYPE I . %TABI X LI KE SY- TABI X. %PRFLAG( 1) TYPE X VALUE ' 02' .
DATA %PERC( 4) TYPE P DECI MALS 3. DATA %P100( 4) TYPE P DECI MALS 3 VALUE ' 100. 000' . DATA %RANGCT TYPE I . DATA %RANGCC( 8) . SELECT- OPTI ONS SP$00001 FOR MBEW- MATNR MEMORY I D MAT. SELECT- OPTI ONS SP$00003 FOR MAKT- MAKTX. SELECTI ON- SCREEN SKI P 1. SELECTI ON- SCREEN: BEGI N OF BLOCK DI RECT WI TH FRAME TI TLE TEXT- F59. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %ALV RADI OBUTTON GROUP FUNC USER- COMMAND OUTBUT DEFAULT ' X' . SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F72 FOR FI ELD %ALV. PARAMETERS: %ALVL TYPE SLI S_VARI . SELECTI ON- SCREEN: PUSHBUTTON 72( 4) PB%EXCO USER- COMMAND EXPCOL. SELECTI ON- SCREEN: END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %NOFUNC RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F66 FOR FI ELD %NOFUNC MODI F I D OLD. PARAMETERS: %TVI EW RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 34( 26) TEXT- F68 FOR FI ELD %TVI EW MODI F I D OLD, END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %GRAPH RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F61 FOR FI ELD %GRAPH MODI F I D OLD. PARAMETERS: %TEXT RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 34( 26) TEXT- F69 FOR FI ELD %TEXT MODI F I D OLD, END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %ABC RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F70 FOR FI ELD %ABC MODI F I D OLD. PARAMETERS: %EXCEL RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 34( 26) TEXT- F60 FOR FI ELD %EXCEL MODI F I D OLD, END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE.
PARAMETERS: %EI S RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F63 FOR FI ELD %EI S MODI F I D OLD. SELECTI ON- SCREEN: END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %XI NT RADI OBUTTON GROUP FUNC MODI F I D XI N. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F73 FOR FI ELD %XI NT MODI F I D XI N. PARAMETERS: %XI NTK( 30) LOWER CASE MODI F I D XI N. SELECTI ON- SCREEN: END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %DOWN RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F64 FOR FI ELD %DOWN MODI F I D OLD. PARAMETERS: %PATH( 132) LOWER CASE MODI F I D OLD. SELECTI ON- SCREEN: END OF LI NE. SELECTI ON- SCREEN: BEGI N OF LI NE. PARAMETERS: %SAVE RADI OBUTTON GROUP FUNC MODI F I D OLD. SELECTI ON- SCREEN: COMMENT 4( 26) TEXT- F62 F OR FI ELD %SAVE MODI F I D OLD. PARAMETERS: %LI STI D( 40) LOWER CASE MODI F I D OLD. SELECTI ON- SCREEN: END OF LI NE. SELECTI ON- SCREEN: END OF BLOCK DI RECT. SELECTI ON- SCREEN: END OF BLOCK PROG. DATA: BEGI N OF %G00 OCCURS 100, MBEW- MATNR LI KE MBEW- MATNR, MAKT- MAKTX LI KE MAKT- MAKTX, MBEW- VERPR LI KE MBEW- VERPR, T001- WAERS- 0103 LI KE T001- WAERS, MBEW- PEI NH LI KE MBEW- PEI NH, END OF %G00. DATA: BEGI N OF %%G00, MBEW- MATNR( 018) , MAKT- MAKTX( 040) , MBEW- VERPR( 015) , T001- WAERS- 0103 LI KE T001- WAERS, MBEW- PEI NH( 006) , END OF %%G00. DATA %ZNR TYPE I . DATA %LZNR TYPE I VALUE 99999. FI ELD- GROUPS HEADER. DATA %GROUP01. DATA %%MAKT- MAKTX L I KE MAKT- MAKTX. DATA %%%MAKT- MAKTX( 1) . DATA %GROUP0101. FI ELD- GROUPS %FG01. DATA %ANY- 01. CONTROLS TVI EW100 TYPE TABLEVI EW USI NG SCREEN 100. AT SELECTI ON- SCREEN . PERFORM ALVL_ CHECK( RSAQEXCE) USI NG %ALVL ' G00' . PERFORM TESTMODE( RSAQEXCE) . PERFORM CHECK_EXPCOL( RSAQEXCE) USI NG %ALV. AT SEL ECTI ON- SCREEN ON VALUE- REQUEST FOR %ALVL . PERFORM ALVL_ VALUE_REQUEST( RSAQEXCE) USI NG %ALVL ' G00' . AT SELECTI ON- SCREEN ON VALUE- REQUEST FOR %XI NTK . PERFORM XI NT_VALUE_REQUEST( RSAQEXCE) . AT SELECTI ON- SCREEN OUTPUT . PERFORM RI NI T( RSAQBRST) . PERFORM SET_ EXPCOL( RSAQEXCE) USI NG %ALV PB%EXCO. PERFORM ALVL_ SET_ I NVI SI BLE( RSAQEXCE) . PERFORM SET_ XI NT_ PARAMS( RSAQEXCE) . I NI TI ALI ZATI ON. PERFORM I NI T_XI NT( RSAQEXCE) . PERFORM SET_ WWW_FLAGS( RSAQEXCE) . START- OF- SELECTI ON. I NSERT MAKT- MAKTX I NTO HEADER. I NSERT %COUNT- MBEW I NTO HEADER.
%DI ACT = SPACE. %BATCH = SY- BATCH. I F %BATCH <> SPACE. I F %EI S <> SPACE. %DI ACT = ' E' . NEW- PAGE PRI NT ON DESTI NATI ON ' NULL ' NO DI ALOG LI NE- SI ZE 0253 LI NE- COUNT 0065. ENDI F. I F %ALV <> SPACE. %DI ACT = ' V' . %ALV_LAYOUT = %ALVL. NEW- PAGE PRI NT ON DESTI NATI ON ' NULL ' NO DI ALOG LI NE- SI ZE 0253 LI NE- COUNT 0065. ENDI F. I F %SAVE <> SPACE. %DI ACT = ' S' . NEW- PAGE PRI NT ON DESTI NATI ON ' NULL ' NO DI ALOG LI NE- SI ZE 0253 LI NE- COUNT 0065. ENDI F. ELSEI F %CALLED_BY_WWW <> SPACE. %DI ACT = SPACE. ELSEI F %CALL ED_BY_WWW_ ALV <> SPACE. %DI ACT = ' V' . ELSE. I F %SAVE <> SPACE. %DI ACT = ' S' . ENDI F. I F %XI NT <> SPACE. %DI ACT = ' I ' . ENDI F. I F %TVI EW<> SPACE. %DI ACT = ' T' . ENDI F. I F %ALV <> SPACE. %DI ACT = ' V' . ENDI F. I F %DOWN <> SPACE. %DI ACT = ' D' . ENDI F. I F %EI S <> SPACE. %DI ACT = ' E' . ENDI F. I F %GRAPH <> SPACE. %DI ACT = ' G' . ENDI F. I F %EXCEL <> SPACE. %DI ACT = ' X' . ENDI F. I F %TEXT <> SPACE. %DI ACT = ' W' . ENDI F. I F %ABC <> SPACE. %DI ACT = ' A' . ENDI F. I F %DI ACT <> SPACE AND %DI ACT <> ' S' AND %DI ACT <> ' W' . NEW- PAGE PRI NT ON DESTI NATI ON ' NULL ' NO DI ALOG LI NE- SI ZE 0253 LI NE- COUNT 0065. ENDI F. %PATHNAME = %PATH. I F %DI ACT = ' I ' . %FUNCTI ONKEY = %XI NTK. ENDI F. I F %DI ACT = ' V' . %ALV_LAYOUT = %ALVL. ENDI F. ENDI F. FREE MEMORY I D ' AQLI STDATA' . I F %MEMMODE <> SPACE. I F %BATCH <> SPACE. NEW- PAGE PRI NT ON DESTI NATI ON ' NULL ' NO DI ALOG LI NE- SI ZE 0253 LI NE- COUNT 0065. ENDI F. %DI ACT = ' 1' . ENDI F. %TI TEL = ' ' . I F SY- SUBTY O %PRFLAG AND %TI TEL = SPACE. NEW- PAGE WI TH- TI TLE. ENDI F. %TVSI ZE = 0200. %PLI NE = 1. %PZGR = 1. %FI RST = ' X' . PERFORM %OUTPUT. %FI RST = SPACE. I F %DI ACT <> SPACE AND %DI ACT <> ' S' . NEW- PAGE PRI NT OFF. NEW- PAGE NO- HEADI NG NO- TI TLE. WRI TE SPACE. ELSE. PERFORM PF- STATUS( RSAQEXCE) USI NG ' XXX '. ENDI F. CLEAR: %TAB, %LI NE, %CONT. I F %DATA_ SELECTED = SPACE. I F %DI ACT = ' 1' . EXPORT EMPTY FROM %EMPTY TO MEMORY I D ' AQLI STDATA' . LEAVE. ELSE.
I F %BATCH = SPACE AND %CALLED_BY_ WWW = SPACE AND %CALLED_BY_ WWW_ ALV = SPACE. MESSAGE S260( AQ) . LEAVE LI ST- PROCESSI NG. ELSE. I F %CALL ED_ BY_WWW_ALV = SPACE. %DI ACT = SPACE. ENDI F. ENDI F. ENDI F. ENDI F. I F %DI ACT = ' S' . PERFORM %SAVE_LI ST. LEAVE LI ST- PROCESSI NG. ENDI F. I F %DI ACT = ' V' AND %BATCH <> SPACE. NEW- PAGE PRI NT ON. PERFORM %DOWNLOAD USI NG ' ALV' . LEAVE. ENDI F. I F %DI ACT = ' V' AND %CALLED_ BY_WWW_ALV <> SPACE. PERFORM %DOWNLOAD USI NG ' ALV' . LEAVE. ENDI F. I F %DI ACT = ' P' AND %BATCH <> SPACE. PERFORM %DOWNLOAD USI NG ' +DAT' . LEAVE LI ST- PROCESSI NG. ENDI F. I F %DI ACT = ' E' AND %BATCH <> SPACE. PERFORM %DOWNLOAD USI NG ' EI S' . LEAVE LI ST- PROCESSI NG. ENDI F. I F %DI ACT = ' 1' . PERFORM %DOWNLOAD USI NG ' +MEM' . LEAVE. ENDI F. I F %DI ACT = ' X' . SET USER- COMMAND ' XXL' . ELSEI F %DI ACT = ' W' . SET USER- COMMAND ' TEXT' . ELSEI F %DI ACT = ' V' . SET USER- COMMAND ' ALV' . ELSEI F %DI ACT = ' T' . SET USER- COMMAND ' VI EW' . ELSEI F %DI ACT = ' G' . SET USER- COMMAND ' GRAF' . ELSEI F %DI ACT = ' A' . SET USER- COMMAND ' ABCA' . ELSEI F %DI ACT = ' E' . SET USER- COMMAND ' EI S' . ELSEI F %DI ACT = ' D' . SET USER- COMMAND ' DOWN' . ELSEI F %DI ACT = ' I ' . SET USER- COMMAND ' XI NT' . ELSEI F %DI ACT = ' P' . SET USER- COMMAND ' +DAT' . ENDI F. TOP- OF- PAGE. PERFORM %TOP- OF- PAGE. END- OF- PAGE. PERFORM PAGE_FOOT( RSAQEXCE) . PERFORM %SAVE_PAGE. TOP- OF- PAGE DURI NG L I NE- SELECTI ON. PERFORM %TOP- OF- PAGE. AT USER- COMMAND. CASE SY- UCOMM. WHEN ' EXI T' . LEAVE. WHEN ' RETN' . PERFORM RETURN( RSAQEXCE) . WHEN ' CANC' . PERFORM RETURN( RSAQEXCE) .
WHEN ' WEI T' . PERFORM RETURN( RSAQEXCE) . WHEN ' I NHA' . PERFORM CATALOGUE( RSAQEXCE) . WHEN ' AUSL' . PERFORM PI CKUP( RSAQEXCE) . WHEN ' AUSW' . PERFORM PI CKUP( RSAQEXCE) . WHEN ' RCAA' . PERFORM RCHAI N( RSAQBRST) . WHEN ' RCAL' . PERFORM RCALL( RSAQBRST) . WHEN ' VGLI ' . PERFORM CHANGE( RSAQEXCE) . WHEN ' VGLE' . PERFORM CHANGE( RSAQEXCE) . WHEN ' TOTO' . PERFORM CHANGE( RSAQEXCE) . WHEN ' VSTA' . PERFORM CHANGE( RSAQEXCE) . WHEN ' VSTE' . PERFORM RETURN( RSAQEXCE) . WHEN ' SAVL' . PERFORM %SAVE_LI ST. WHEN ' ODRU' . PERFORM PRI NT_LI ST( RSAQEXCE) . WHEN ' COPA' . PERFORM PRI NT_COVER_ PAGE( RSAQEXCE) . WHEN ' TEXT' . PERFORM %DOWNLOAD USI NG ' TEXT' . WHEN ' ALV' . PERFORM %DOWNLOAD USI NG ' ALV' . WHEN ' VI EW' . PERFORM %VI EW. WHEN ' XXL' . PERFORM %DOWNLOAD USI NG ' XXL' . WHEN ' GRAF' . PERFORM %DOWNLOAD USI NG ' GRAF' . WHEN ' ABCA' . PERFORM %DOWNLOAD USI NG ' ABCA' . WHEN ' EI S' . PERFORM %DOWNLOAD USI NG ' EI S' . WHEN ' DOWN' . PERFORM %DOWNLOAD USI NG ' DOWN' . WHEN ' XI NT' . PERFORM %DOWNLOAD USI NG ' XI NT' . ENDCASE. CLEAR: %CLI NE, %ZGR. CLEAR: %TAB, %LI NE, %CONT. I F %DI ACT <> SPACE. LEAVE LI ST- PROCESSI NG. ENDI F. FORM %COMP_ LDESC. REFRESH %LDESC. REFRESH %GDESC. PERFORM LDESC( RSAQEXCE) USI NG ' G00010000X018 00 98' TEXT- A00 TEXT- B00 TEXT- H00 ' MBEW- MATNR' MBEW- MATNR ' MBEW- MATNR' . PERFORM LDESC( RSAQEXCE) USI NG ' G00020000X040 01 98' TEXT- A01 TEXT- B01 TEXT- H00 ' MAKT- MAKTX' MAKT- MAKTX ' MAKT- MAKTX' . PERFORM LDESC( RSAQEXCE) USI NG ' G00030062 015F 00 98' TEXT- A02 TEXT- B02 TEXT- H00 ' MBEW- VERPR' MBEW- VERPR ' MBEW- VERPR' . PERFORM LDESC( RSAQEXCE) USI NG ' G00040000 005W 00 98' TEXT- A03 TEXT- B03 TEXT- H00 ' T001- WAERS' T001- WAERS ' T001- WAERS- 0103' . PERFORM LDESC( RSAQEXCE) USI NG ' G00050084 006 00 98' TEXT- A04 TEXT- B04 TEXT- H00 ' MBEW- PEI NH' MBEW- PEI NH ' MBEW- PEI NH' . PERFORM GDESC( RSAQEXCE) USI NG ' G00' 5 20 ' ' ' ' ' X' . ENDFORM. FORM %OUTPUT. DESCRI BE TABLE %PRLI ST LI NES %MAX_PRLI ST. %HEAD = ' AAA' .
%KEYEMPTY = SPACE. NEW- PAGE. PERFORM %OUTPUT_ GL. PERFORM COMPLETE_ PAGE( RSAQEXCE) . %HEAD = ' ZZZ' . PERFORM LAST_ PTAB_ENTRY( RSAQEXCE) . NEW- PAGE. I F %KEYEMPTY <> SPACE. MESSAGE S894( AQ) . ENDI F. ENDFORM. FORM %TOP- OF- PAGE. I I I I
F F F F
SY- UCOMM = ' I NHA' . EXI T. ENDI F. SY- UCOMM = ' COPA' . EXI T. ENDI F. %HEAD = SPACE. EXI T. ENDI F. %HEAD = ' DDD' . PERFORM TVI EWPAGE( RSAQEXCE) . EXI T. ENDI F. I F %HEAD = ' GGG' . PERFORM PAGE( RSAQEXCE) USI NG ' G00' TEXT- GRL 252 %GLFRAME 001. SET L EFT SCROLL - BOUNDARY COLUMN 002. PERFORM SET_ SCROLL _BOUNDARY( RSAQEXCE) USI NG 002. I F %TOTO <> SPACE. EXI T. ENDI F. ELSE. CASE %HEAD. ENDCASE. ENDI F. ENDFORM. FORM %NEWLI NE. %UFLAG = SPACE. NEW- LI NE. WRI TE: ' | ' , 252 ' | ' . POSI TI ON 2. ENDFORM. FORM %SKI P USI NG COUNT. I F SY- LI NNO > 1. %UFLAG = SPACE. DO COUNT TI MES. NEW- LI NE. FORMAT RESET. WRI TE: ' | ' , 252 ' | ' . ENDDO. ENDI F. ENDFORM. FORM %ULI NE. I F %UFLAG = SPACE. I F SY-LI NNO > 1. ULI NE / 1(252) . ENDI F. %UFLAG = ' X' . ENDI F. ENDFORM. FORM %HI DE. I F %BATCH <> SPACE AND %DI ACT = ' S' . PERFORM HI DE( RSAQEXCE) . ELSE. HI DE: %TAB, %LI NE, %CONT. ENDI F.
ENDFORM. FORM %HI DE_COLOR. I F %BATCH <> SPACE AND %DI ACT = ' S' . PERFORM HI DE_COLOR( RSAQEXCE) . ELSE. HI DE: %FI NT, %FCOL. ENDI F. ENDFORM. FORM %RCALL USI NG NAME VALUE. FI ELD- SYMBOLS . ASSI GN ( NAME) TO . READ CURRENT LI NE FI ELD VALUE I NTO VALUE. I F SY- SUBRC <> 0. VALUE = SPACE. EXI T. ENDI F. I F VALUE = SPACE AND %TAB = ' G00' AND %LDESC- FCUR NA ' FM' . READ TABLE %G00 I NDEX %LI NE. I F SY- SUBRC = 0. ASSI GN COMPONENT %LDESC- FNAMEI NT OF STRUCTURE %G00 TO . I F SY- SUBRC = 0. WRI TE TO VALUE( %LDESC- FOLEN) . ENDI F. ENDI F. ENDI F. ENDFORM. FORM %SAVE_PAGE. I F %BATCH <> SPACE AND %DI ACT = ' S' . PERFORM SAVE_PAGE( RSAQEXCE) TABLES %ST_ LI STE. ENDI F. ENDFORM. FORM %REPLACE_VAR USI NG TEXT. FI ELD- SYMBOLS . ASSI GN TEXT+1( * ) TO . ENDFORM. FORM %SAVE_ LI ST. DATA: %SFLAG, QREPORT LI KE SY- REPI D. I F %DI ACT = ' S' . %SFLAG = ' X' . ENDI F. QREPORT = SY- REPI D. PERFORM SAVE_LI ST( RSAQEXCE) TABLES %ST_L I STE USI NG QREPORT %SFLAG %LI STI D. I F %QL_ I D <> SPACE. %DLFLAG = ' X' . %LI STSI ZE = 0253. PERFORM COMP_ SELECTI ON_SCREEN( RSAQEXCE) . EXPORT %ST_LI STE %PTAB %LDESC %GDESC %DLFL AG %LI STSI ZE %SELECTI ONS %G00 TO DATABASE AQLDB( AQ) I D %QL_ I D. ENDI F. ENDFORM. FORM %REFRESH. CASE %TAB. WHEN ' G00' . I MPORT %G00 FROM DATABASE AQLDB( AQ) I D %QL_ I D.
ENDCASE. ENDFORM. FORM %DOWNLOAD USI NG CODE. DATA: QREPORT LI KE SY- REPI D. PERFORM I NI T_ DOWNLOAD( RSAQEXCE) . QREPORT = SY- REPI D. CASE %TAB. WHEN ' G00' . PERFORM DOWNLOAD( RSAQEXCE) TABLES %G00 USI NG CODE QREPORT TEXT- GRL. WHEN OTHERS. MESSAGE S860( AQ) . ENDCASE. ENDFORM. FORM %SET_DATA CHANGI NG L_ LI NES TYPE I . I MPORT LDATA TO %G00 FROM MEMORY I D ' AQLI STDATA' . DESCRI BE TABLE %G00 LI NES L_ LI NES. FREE MEMORY I D ' AQLI STDATA' . ENDFORM. FORM %GET_DATA TABL ES DATATAB STRUCTURE %G00 USI NG FI RST TYPE I LAST TYPE I . APPEND LI NES OF %G00 FROM FI RST TO LAST TO DATATAB. ENDFORM. FORM %GET_ REF_TO_TABLE USI NG LI D LI KE RSAQLDESC- LI D REF_TO_I TAB TYPE REF TO DATA SUBRC LI KE SY- SUBRC. SUBRC = 0. CASE LI D. WHEN ' G00' . CREATE DATA REF_ TO_I TAB LI KE %G00[ ] . WHEN OTHERS. SUBRC = 4. MESSAGE S860( AQ) . ENDCASE. ENDFORM. FORM %VI EW. DATA: ANZ TYPE I , PROG LI KE SY- REPI D. PROG = SY- REPI D. PERFORM I NI T_ DOWNLOAD( RSAQEXCE) . CASE %TAB. WHEN ' G00' . PERFORM GENERATE_ VI EW_DYNPRO( RSAQEXCE) USI NG PROG TEXT- GRL. DESCRI BE TABLE %G00 LI NES ANZ. TVI EW100- LI NES = ANZ. PERFORM I NI T_ VI EW( RSAQEXCE) TABLES %G00 USI NG TVI EW100. CALL SCREEN 100. PERFORM RESET_ VI EW_DYNPRO( RSAQEXCE) . WHEN OTHERS. MESSAGE S860( AQ) . ENDCASE. ENDFORM. FORM %OUTPUT_GL. I F %MAX_PRLI ST <> 0.
READ TABLE %PRLI ST WI TH KEY TAB = ' GGG' . I F SY- SUBRC <> 0. EXI T. ENDI F. ENDI F. SET MARGI N 00. PERFORM COMPLETE_ PAGE( RSAQEXCE) . %NOCHANGE = SPACE. NEW- PAGE. %GLLI NE = 0. %TAB = ' G00' . %LI NE = 0. %CONT = ' 0' . %FI NT = SPACE. %FCOL = ' 0' . %HEAD = ' GGG' . %CLI NE = 0. %OUTFLAG = SPACE. %OUTCOMP = SPACE. %OUTTOTAL = SPACE. %RFLAG = ' AA' . I F %DI ACT <> SPACE AND %DI ACT NA ' SW' . WRI TE SPACE. ENDI F. FORMAT RESET. LOOP. %DATA_SELECTED = ' X' . AT %FG01. %ZNR = ' 01' . %ZGR = ' 01' . %CLI NE = %CLI NE + 1. %G00- MBEW- MATNR = MBEW- MATNR. %G00- MAKT- MAKTX = MAKT- MAKTX. %G00- MBEW- VERPR = MBEW- VERPR. %G00- T001- WAERS- 0103 = T001- WAERS. %G00- MBEW- PEI NH = MBEW- PEI NH. I F %FI RST <> SPACE. APPEND %G00. ENDI F. %GLLI NE = %GLLI NE + 1. %LZNR = %ZNR. I F %DI ACT <> SPACE AND %DI ACT NA ' SW' . CONTI NUE. ENDI F. PERFORM CHECK( RSAQEXCE) USI NG ' ' . I F %RFLAG = ' E' . EXI T. ENDI F. I F MAKT- MAKTX <> %%MAKT- MAKTX OR %%%MAKT- MAKTX = SPACE. %%MAKT- MAKTX = MAKT- MAKTX. %%%MAKT- MAKTX =' X' . ENDI F. I F %RFLAG( 1) = ' A' . FORMAT RESET. %FI NT = ' F' . %FCOL = ' 0' . FORMAT COLOR 2. %FCOL = ' 2' . PERFORM %NEWLI NE. WRI TE 002( 018) MBEW- MATNR. %LI NE = %GLLI NE. PERFORM %HI DE. %LI NE = 0. PERFORM %HI DE_ COLOR. WRI TE 021( 040) MAKT- MAKTX. WRI TE 062( 015) MBEW- VERPR CURRENCY T001- WAERS. WRI TE 078( 005) T001- WAERS. WRI TE 084( 006) MBEW- PEI NH. ENDI F. ENDAT. AT END OF MAKT- MAKTX. %ZGR = ' 01' . PERFORM CHECK( RSAQEXCE) USI NG ' X' . I F %RFLAG = ' E' . EXI T. ENDI F. ENDAT. ENDLOOP. %RFLAG = ' AA' . PERFORM %ULI NE. CLEAR: %CLI NE, %ZGR. ENDFORM.
MODULE %I NI T_VI EW OUTPUT.
CASE %TAB. WHEN ' G00' . PERFORM I NI T_PBO( RSAQEXCE) TABLES %G00 USI NG TVI EW100 ' X' . WHEN OTHERS. MESSAGE S860( AQ) . ENDCASE. ENDMODULE. MODULE %PBO_VI EW OUTPUT. CASE %TAB. WHEN ' G00' . PERFORM LOOP_ PBO( RSAQEXCE) TABLES %G00 USI NG %%G00 TVI EW100. ENDCASE. ENDMODULE. MODULE %PAI _VI EW I NPUT. CASE %TAB. WHEN ' G00' . PERFORM LOOP_ PAI ( RSAQEXCE) TABLES %G00 USI NG %%G00 TVI EW100. ENDCASE. ENDMODULE. MODULE %OKCODE_ VI EW I NPUT. CASE %TAB. WHEN ' G00' . PERFORM OKCODE( RSAQEXCE) TABLES %G00 USI NG TVI EW100. ENDCASE. ENDMODULE.
7.10.17 List of transactions report *----------------------------------------------------------------------* * REPORT Z_TRANSACTIONS * *----------------------------------------------------------------------* * TEXT ELEMENTS * ------------* Heading * Transaction code Text * * Selection texts * P_DNLD Download? * P_FILE Filename: * S_SPRSL Language: * S_TCODE Transaction Code: * * Text Symbols * 001 Transaction Selection * 002 Download Option * 003 Filename *----------------------------------------------------------------------* REPORT z_transactions. TABLES: tstct. TYPES: BEGIN OF itab_tx, tcode LIKE tstct-tcode, ttext LIKE tstct-ttext, END OF itab_tx. DATA: itab_tx tx itab_file p_file returncode filestring
TYPE TYPE LIKE LIKE LIKE TYPE
itab_tx OCCURS 0 WITH HEADER LINE, itab_tx, sval OCCURS 0 WITH HEADER LINE, rlgrap-filename, sy-subrc, string.
DATA: BEGIN OF fields OCCURS 2. INCLUDE STRUCTURE sval. DATA: END OF fields.
* text-001 = Transaction Selection SELECTION-SCREEN BEGIN OF BLOCK transx WITH FRAME TITLE text-001. SELECT-OPTIONS: s_tcode FOR tstct-tcode, s_sprsl FOR tstct-sprsl. SELECTION-SCREEN END OF BLOCK transx. * text-002 = Download Option SELECTION-SCREEN BEGIN OF BLOCK dld WITH FRAME TITLE text-002. PARAMETERS: p_dnld TYPE c AS CHECKBOX. SELECTION-SCREEN END OF BLOCK dld. AT SELECTION-SCREEN OUTPUT. p_file = 'C:\SAPTXlist.xls'. p_dnld = 'X'. MOVE 'I' TO s_sprsl-sign. MOVE 'EQ' TO s_sprsl-option. MOVE 'EN' TO s_sprsl-low. APPEND s_sprsl.
START-OF-SELECTION. REFRESH itab_tx. SELECT * FROM tstct INTO CORRESPONDING FIELDS OF TABLE itab_tx WHERE tcode IN s_tcode AND sprsl IN s_sprsl. IF sy-subrc <> 0. MESSAGE s265(sf). ELSE. SORT itab_tx BY tcode. LOOP AT itab_tx. WRITE: /1 itab_tx-tcode(20), AT 20 itab_tx-ttext. ENDLOOP. IF p_dnld = 'X'. CLEAR fields. fields-tabname = 'RLGRAP'. fields-fieldname = 'FILENAME'. fields-value = p_file. fields-field_attr = '00'. APPEND fields. CALL FUNCTION 'POPUP_GET_VALUES' EXPORTING popup_title = text-003 IMPORTING returncode = returncode TABLES fields = fields EXCEPTIONS error_in_fields = 1 OTHERS = 2. CHECK returncode EQ space. filestring = fields-value. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename write_field_separator TABLES data_tab EXCEPTIONS file_write_error no_batch gui_refuse_filetransfer invalid_type no_authority unknown_error header_not_allowed separator_not_allowed filesize_not_allowed header_too_long dp_error_create dp_error_send
dp_error_write = 13 unknown_dp_erro r = 14 access_denied = 15 dp_out_of_memor y = 16 disk_full = 17 dp_timeout = 18 file_not_found = 19 dataprovider_ex ception = 20 control_flush_e rror = 21 OTHERS = 22. IF sy-subrc <> 0. MESSAGE s999(b1) WITH 'File ' filestring ' NOT created!'. ELSE. MESSAGE s999(b1) WITH 'File ' filestring ' Created successfully!'. ENDIF. "Check on download success ENDIF. "Download ENDIF. "Check on selection
CHAPTER 8 BASIS ERRORS AND RESOLUTIONS 8.1
CANNOT CANNO T ACTIVATE A TABL E
Syntax error in SDCC, table inconsistency be tween ABAP Dictionary and the database, transport error 8 during the generation of ABAP Dictionary. When you call Transaction SDCC, a termination occurs due to a putative syntax error because a table is not known or active.When you check this with the ABAP dictionary (SE11), you notice, that the table is active or inactive, however it is not possible po ssible to activate it.The activation might terminate with the error message 'Inconsistency between ABAP Dictionary and database'.A check of the affected object also delivers this error. Proceed as follows: •
Log on as user DDIC
•
Call Transaction SE14
•
Enter the affected table name and
•
select EDIT
•
In the following screen, choose Table -> Reconstruct
•
Confirm the execution
•
Call Transaction SE11
•
Enter the affected table name
•
Display
•
Activate
If - after you chose EDIT -, the error message occurs that the table only exists on the database, you need to activate the source and the runtime object. •
•
Call Transaction SE37: -> Function module 'DD_TABL_ACTM' -> Single test Under import parameter MODE, enter the number 12 and under TABNAME the corresponding table name
•
-> Execute (F8) -> Export parameter ACT_RESULT must be 0
•
Call Transaction SE14 again as described above.
•
-> Extras -> Database object -> Check, as well as -> Extras -> Runtime object -> Check inconsistencies should no longer be contained.
If you cannot switch to the EDIT mode in Transaction SE14, which means no modifications are allowed in the customer system, then proceed as follows: •
Call function module 'DD_TABL_ACTM' as described above.
•
Then call Transaction SE14 again and verify that the table has been activated.
•
As a result, this ensures that the SDCC can be executed.
•
The menu options in Transaction SE14 are
•
•
-> Extras -> Database object -> Check, as well as -> Extras -> Runtime object -> Check inconsistencies should no longer be contained. If this is not the case, open a CSN message under the BC-DWB-DIC-ED component.