ABAP Program Tips v3 PDF
ABAP Program Tips v3 PDF
K. Wilson
http://www.sapgenie.com/abap
Table of Contents
CHAPTER 1
USEFUL TRANSACTIONS
1.1
EDI SPECIFIC TRANSACTIONS---------------3
1.1.1
SCHEDULING AGREEMENTS ....................... 3
1.2
MESSAGE CONTROL ----------------------------3
1.2.1
DELIVERY ................................................. 3
1.2.2
INVOICE .................................................... 3
1.2.3
ORDER RESPONSE .................................... 3
3.3.4
3.3.5
3.3.6
3.3.7
3.3.8
3.3.9
3.3.10
1.3
IDOC ADMINISTRATION-------------------------3
1.4
IDOC DEVELOPMENT----------------------------4
1.5
3.4
FILE PROCESSING ----------------------------- 23
3.4.1
DOWNLOADING TO EXCEL ....................... 23
3.4.2
FTP A FILE TO ANOTHER SERVER ............. 24
3.4.3
DATASET ............................................. 25
3.4.4
WS_DOWNLOAD................................. 26
3.4.5
GUI_DOWNLOAD WITH POPUP FILENAME
REQUEST 27
1.6
SALES-------------------------------------------------4
3.5
1.7
GENERAL --------------------------------------------4
1.7.1
COMMON TABLES ...................................... 5
CHAPTER 2
USEFUL PROGRAMS
2.1
FUNCTION MODULES ---------------------------7
2.1.1
USEREXIT_KOMKBV1_FILL. ................ 7
2.1.2
MASTER_IDOC_DISTRIBUTE .............. 7
2.1.3
IDOC_STATUS_WRITE_TO_DATABASE
7
2.1.4
IDOC_TYPE_COMPLETE_READ ......... 7
2.2
PROGRAMS --------------------------------------- 11
2.2.1
RHSOBJCH FIXES PD CONTROL TABLES
MISSING IN TX SWU3............................................. 11
2.2.2
RV80HGEN .......................................... 11
2.2.3
SCHEDULING OF SYSTEM MAINTENANCE JOBS .... 12
2.3
INCLUDES ----------------------------------------- 12
2.3.1
MBDCONWF IDOC DEFINITIONS ......... 12
2.4
FIELDS ---------------------------------------------- 12
CHAPTER 3
3.1
GENERAL PROGRAMMING
14
BAPIS ----------------------------------------------- 14
3.2
DIALOG PROGRAMMING --------------------- 14
3.2.1
PROCESS ON VALUE REQUEST F4 ......... 14
3.3
REPORTS ------------------------------------------ 15
3.3.1
REFRESHING DATA ON REPORTS ............. 15
3.3.2
TREE REPORTS ...................................... 16
3.3.3
INITIALIZING DATE RANGES ON SELECTIONOPTIONS 19
ABAP Programming Tips
MACROS ------------------------------------------- 28
3.6
SELECT STATEMENTS ----------------------- 29
3.6.1
JOINS ..................................................... 29
3.7
SAPSCRIPT --------------------------------------- 30
3.7.1
CHANGING THE SUBJECT FOR EMAIL ORDER
CONFIRMATIONS .................................................... 30
3.8
GENERAL------------------------------------------ 30
3.8.1
RETRIEVING THE EMAIL ADDRESS OF AN SAP
30
USER
3.8.2
EXECUTING A PROGRAM .......................... 31
3.8.3
CHANGING \ CREATING REQUIREMENTS ... 31
3.8.4
DISPLAYING TRANSACTION ...................... 31
3.8.5
GUI-STATUS .......................................... 31
3.8.6
DOCUMENT FLOW ................................... 32
3.8.7
MAINTAINING TRAILING SPACES WHEN
DOWNLOADING TO PC ........................................... 32
3.8.8
HIDING ABAP SOURCE CODE ................. 32
3.8.9
WHERE IN IMG IS A TABLE CONFIGURED .. 32
3.8.10 EDITOR TIPS (*EJECT AND *$*$) ............ 32
3.8.11 LIST OF WAYS TO TRANSPORT VARIANTS .. 33
3.8.12 CHECKING FOR BACKGROUND PROCESSING33
CHAPTER 4
4.1
34
CHAPTER 5
5.1
WORKFLOW PROGRAMS
36
TOP-OF-PAGE --------------------------------- 36
CHAPTER 6
OBJECT PROGRAMMING
38
Page 1 of 157
6.1
6.2
CHAPTER 9
INDEX
155
6.3
ALV GRID CONTROL--------------------------- 48
6.3.1
ADDING CUSTOM BUTTONS ON ALV GRID
CONTROLS ............................................................ 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---------------------------- 55
7.2
SENDING AN IDOC------------------------------ 55
7.3
7.4
7.5
READING AN IDOC ----------------------------- 56
7.5.1
EXAMPLE OPEN DOCUMENT FOR READ .. 56
7.6
7.7
7.8
7.9
RETURNING IDOCS LINKED TO
DOCUMENTS ---------------------------------------------- 59
7.9.1
* RETURN THE LIST OF IDOCS LINKED TO THE
DELIVERY 59
7.9.2
* RETURN THE LIST OF IDOCS LINKED TO THE
INVOICE 59
7.9.3
VERSION 4.6X ........................................ 59
7.10
EXAMPLES ------------------------------------- 61
7.10.1 WRITE IDOC STATUS ............................... 61
7.10.2 BDC PROCESSING & IDOC STATUS UPDATE61
7.10.3 MAILING IN SAP...................................... 63
7.10.4 PROGRAM EXAMPLE REPORT TO SHOW EDI
STATUS 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 DISPLAY108
7.10.10
CHANGE IDOC STATUS TO ERROR STATUS
AND SEND TO WORKFLOW .................................... 108
7.10.11
REPORT TO DOWNLOAD PROGRAMS ... 115
7.10.12
DISPLAY TABLE IN HTML ................... 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
PROGRAM 139
7.10.17
LIST OF TRANSACTIONS REPORT......... 150
CHAPTER 8
8.1
Page 2 of 157
1.1
VOE1
VOE2
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. 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 partner.
Create entries for each sold-to customer for which you will receive EDI 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 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.
1.2
NACE
MESSAGE CONTROL
Links to all the message control transactions via the application area
1.2.1 Delivery
V/36
VV21
VL71
1.2.2 Invoice
V/54
VV31
VF31
VV11
1.3
IDOC ADMINISTRATION
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
Page 3 of 157
WE60
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
WE31
Segment create
WE30
WE82
WE57
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
VA02
VA32
VA42
Contract change
VA22
Quotation change
VF02
VL02N
VF11
VF04
VL04
VKM3, VKM4
VKM1
VKM5
List of deliveries
VL06G
VL06P
VL09
VT02N
Change shipment
VT70
1.7
GENERAL
Delivery due list. Run the delivery due with your order number to create the delivery.
LT03
Create Transfer Order. EG. Warehouse: 101 and enter. Picking background. Save
VL02N
Delivery change.
MD04
SE38
SM01
Transaction list. Lock transactions in the system. Also a good tool to see what transactions are
available.
Page 4 of 157
SHDB
CMOD
User exit \ project tool. Coordinates your changes into projects for the purpose of activating all user
exits for a particular project. A user exit needs to be modified before it will work.
SE16
search_sap_menu
Delivery
Invoice
VBAK
LIKP
VBRK
Header
VBELN - SO
Header
Header
VBELN - Delivery
VBELN - Invoice
LIPS
VBRP
VBAP
Line item
VBELN - SO
PSONR - Line
VBEP
Line item
Line item
VBELN - Delivery
PSONR - Line
VBELN - Invoice
POSNR - Line
AUBEL/AUPOS - SO/line
VGBEL/VGBEL - Delivery/line
Schedule lines
M_VMVAA
PO -> SO View table
VBFA (Doc Flow), VBUK (Hdr status), VBUP(Line status)
BKPF (Accounting doc)
Table 1-A: Important SAP Tables
1.7.1.1 Basis
TSTCT
Transaction list
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
Release history
VBEP
VBLB
Page 5 of 157
Generated view
General data
KNVV
Sales data
Page 6 of 157
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..
ABAP_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
Page 7 of 157
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 file
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
ABAP Programming Tips
Page 8 of 157
Page 9 of 157
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.
ABAP Programming Tips
Page 10 of 157
2.2
PROGRAMS
RPR_ABAP_SOURCE_SCAN - Search ABAP code for a string. Has many more options for selecting the
ABAPs to search than RSRSCAN1 or RKCTSEAR.
RSBDCDRU - Prints the contents of a Batch Input session. No options for error transactions only.
RSBDCOS0 - Execute UNIX commands. Looks similar to the old SAPMSOS0 program that disappeared in 3.0
RSWBO060 - put objects into a request and transport it to any other system
RPUAUD00 - HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster.
RPUAUDDL - HR Report to delete audit data from the PCL4 Audit Cluster.
RPDTRA00 - List all HR transactions.
RHGRENZ0 - Delimit IT1000 and related 1001s. Program will delete any 1001 infotypes whose start date is
after the delimit date.
RHGRENZ2 - Delimit IT1001 only.
RHGRENZ1 - Extend the end date on delimited records. Very useful when you delimit a bunch of records
incorrectly, and need to change the end date.
Notes on HRGRENZ0/HRBRENZ2: RHGRENZ0/2 will abend if there are any inconsistencies between PD and PA (i.e.
people
in
a
different
controlling
area
than
the
position
they
belong
to).
Controlling area of a person is determined by the cost centre that a person's position is assigned to. When assigning a
person to a position, SAP checks to make sure that the Controlling area of the company that the person belongs to is the
same as that of the Cost centre that their position belongs to.
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.
ABAP Programming Tips
Page 11 of 157
2.3
INCLUDES
2.4
FIELDS
Field
Description
SPART
Division
VTWEG
Distribution Channel
VKORG
Sales Organization
VKGRP
Sales Group
AUART
Order Type
VKBUR
Sales Office
EKORG
Purchasing Organization
WERKS
Plant
BUKRS
Company Code
VBAK-VBELN
Order Number
LIKP-VBELN
Delivery Number
Page 12 of 157
VBRK-VBELN
Invoice Number
KUNNR
Customer Number
LIFNR
Vendor Number
MATNR
Material Number
KSCHL
Output Type
Page 13 of 157
BAPIS
3.2
DIALOG PROGRAMMING
Page 14 of 157
3.3
" source_help
INPUT
REPORTS
Page 15 of 157
EXCEPTIONS
NOT_FOUND
= 1
NO_REPORT
= 2
OTHERS
= 3
.
IF SY-SUBRC <> 0.
MESSAGE ID
SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3
ENDIF.
SUBMIT (SY-REPID)
WITH SELECTION-TABLE LO_SELTAB.
SY-MSGV4.
STEP TWO ADD THESE LINES OF CODE TO POPULATE THE INTERNAL TABLE
**** POPULATE DATA
REFRESH parent_stack. current = 0.
parent_stack = 0. APPEND parent_stack.
LOOP AT itab_data.
CASE itab_data-qualf.
WHEN 1.
New parent
current = current + 1.
PERFORM read_from_parent_stack CHANGING t_parent.
parent_stack = current. APPEND parent_stack.
PERFORM append_item USING current
t_parent
itab_xml_data.
WHEN 2.
End of current leg
current = current + 1.
PERFORM append_item USING current
t_parent
itab_xml_data.
perform delete_parent_stack.
WHEN 3.
Same level
current = current + 1.
PERFORM read_from_parent_stack CHANGING t_parent.
PERFORM append_item USING current
t_parent
itab_xml_data.
ENDCASE.
ENDLOOP.
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 LINE-SELECTION.
READ TABLE items WITH KEY parent_id = items_show-id. "see 'hide'
ABAP Programming Tips
Page 16 of 157
* 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.
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.
Page 17 of 157
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.
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.
ABAP Programming Tips
Page 18 of 157
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 read_from_parent_stack
FORM read_from_parent_stack CHANGING tabix LIKE sy-tabix.
DESCRIBE TABLE parent_stack.
CHECK sy-tfill NE 0.
READ TABLE parent_stack INDEX sy-tfill.
tabix = parent_stack.
ENDFORM.
*&
Form delete_parent_stack
*&---------------------------------------------------------------------*
form delete_parent_stack.
DESCRIBE TABLE parent_stack.
CHECK sy-tfill NE 0.
DELETE parent_stack INDEX sy-tfill.
endform.
" delete_parent_stack
Page 19 of 157
uline.
endform.
=
=
=
=
'RLGRAP'.
'FILENAME'.
'C:\TEST.XLS'.
'00'.
filestring = fields-value.
hide: .
endselect.
counter = sy-dbcnt + 7.
Cater for header lines
endform. " WRITE_REPORT
start-of-selection.
set pf-status 'STD'.
perform write_report.
Page 20 of 157
FIELD_NAME(30),
T_IDOC LIKE EDIDC-DOCNUM.
Page 21 of 157
3.3.10
"Material
"Vendor
"Plant
*--- SELECTION OPTIONS --------------------------------------SELECTION-SCREEN BEGIN OF BLOCK SO WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,"Sales order number
S_VBELND FOR LIKP-VBELN,"Delivery number
S_VBELNI FOR VBRK-VBELN,"Invoice number
S_VBELNP FOR VBKD-BSTKD."PO number
SELECTION-SCREEN END OF BLOCK SO.
'1'.
'0'.
"Delivery select
"1=Active, 0=Don't display
'0'.
"Invoice select
"1=Active, 0=Don't display
'0'.
"PO Select
"1=Active, 0=Don't display
"Delivery select
'0'.
'1'.
"Delivery select
"1=Active, 0=Don't display
'0'.
"Invoice select
"1=Active, 0=Don't display
'0'.
"PO Select
"1=Active, 0=Don't display
"Invoice select
'0'.
'0'.
"Delivery select
"1=Active, 0=Don't display
"Invoice select
Page 22 of 157
SCREEN-ACTIVE =
MODIFY SCREEN.
WHEN '004'.
SCREEN-ACTIVE =
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
WHEN 'ZEDI6P'.
LOOP AT SCREEN.
CASE SCREEN-GROUP4.
WHEN '001'.
SCREEN-ACTIVE =
MODIFY SCREEN.
WHEN '002'.
SCREEN-ACTIVE =
MODIFY SCREEN.
WHEN '003'.
SCREEN-ACTIVE =
MODIFY SCREEN.
WHEN '004'.
SCREEN-ACTIVE =
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDCASE.
3.4
'1'.
'0'.
"PO Select
"1=Active, 0=Don't display
"PO select
'0'.
'0'.
"Delivery select
"1=Active, 0=Don't display
'0'.
"Invoice select
"1=Active, 0=Don't display
'1'.
"PO Select
"1=Active, 0=Don't display
FILE PROCESSING
Page 23 of 157
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.
Page 24 of 157
3.4.3 DATASET
3.4.3.1 Example 1
*&---------------------------------------------------------------------*
*&
Form SENDTO_UNIX
*&---------------------------------------------------------------------*
FORM SENDTO_UNIX.
* open data set to transfer extract data
OPEN DATASET Z_FILE_NAME FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
* File could not be opened for writing
WRITE: / TEXT-006.
LI_WRITE_ERROR = 1.
EXIT.
ENDIF.
LOOP AT IT_PAYR.
TRANSFER IT_PAYR TO Z_FILE_NAME.
ENDLOOP.
* close dataset
CLOSE DATASET Z_FILE_NAME.
ABAP Programming Tips
Page 25 of 157
ENDFORM.
" SENDTO_UNIX
*&---------------------------------------------------------------------*
3.4.3.2 Example 2
OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE.
* if the timestamped file cannot be created, do not process the
* input file, because the input file is deleted after processing,
* and there would be no record of the data.
if not sy-subrc is initial.
*'ERROR opening file & for output'
close dataset infile.
message i033 with outfile.
continue. "process next vendor's file
endif.
do.
read dataset infile into izss7b20.
case sy-subrc.
when 0.
transfer izss7b20 to outfile.
if izss7b20-datacode = 'T'. "trailer rec
perform process_one_vendor using infile.
exit. "process next vendor's file
endif.
check izss7b20-datacode = 'D'. "data rec
move-corresponding uty_vendors to ie020.
move-corresponding izss7b20 to ie020.
when 4. "EOF
perform process_one_vendor using infile.
exit. "process next vendor's file
when others.
*ERROR reading dataset & on &
message w015 with infile sy-datum.
exit. "discontinue file reads
endcase.
enddo.
close dataset: infile, outfile.
delete dataset infile.
3.4.4 WS_DOWNLOAD
*** Internal table to be downloaded
data: begin of z_sales occurs 10000,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of z_sales.
data: begin of t_colnames occurs 10,
name(15),
end of t_colnames.
"Customer number
"Name
Page 26 of 157
TYPE string.
=
=
=
=
'RLGRAP'.
'FILENAME'.
p_file.
'00'.
= filestring
= ','
= itab_data
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Page 27 of 157
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception = 20
control_flush_error
= 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
3.5
MACROS
" add_comma
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.
ABAP Programming Tips
Page 28 of 157
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: create_string date 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.
Page 29 of 157
3.7
SAPSCRIPT
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&)
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
Page 30 of 157
read_db_directly
importing
user_address
user_usr03
exceptions
user_address_not_found
others
if sy-subrc = 0.
= ' '
= addr3_val
= usr03
= 1
= 2.
3.8.5 GUI-Status
ABAP Programming Tips
Page 31 of 157
BACK
%EX
RW
PRI
%SC
%SC+
P--
P-
P+
P++
To set the length of each record including your blanks add this code:
'0' '100'
Click on Customizing.
Click enter. Gives you IMG path(s) which lead to updating given table.
3.8.10
Page 32 of 157
*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
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
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
* Display the GUI status if run in foreground otherwise dont
if sy-subty = 4.
set pf-status 'GH'.
endif.
Page 33 of 157
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.
ABAP Programming Tips
Page 34 of 157
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_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
Page 35 of 157
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
*----------------------------------------------------------------------*
* 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
Page 36 of 157
Page 37 of 157
6.2
TREE REPORTS
CLASS 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
ABAP Programming Tips
Page 38 of 157
" 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.
"#EC NOTEXT
"#EC NOTEXT
"#EC NOTEXT
Page 39 of 157
item-font = cl_gui_list_tree=>item_font_prop.
item-text = 'Comment to SAPTROX1'.
APPEND item TO item_table.
"#EC NOTEXT
"#EC NOTEXT
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.
SELECTION SCREEN
*----------------------------------------------------------------------*
ABAP Programming Tips
Page 40 of 157
* 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.
ABAP Programming Tips
Page 41 of 157
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.
*
*
*
*
Page 42 of 157
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,
ABAP Programming Tips
Page 43 of 157
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.
ABAP Programming Tips
Page 44 of 157
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)
ABAP Programming Tips
Page 45 of 157
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.
ABAP Programming Tips
Page 46 of 157
ENDFORM.
" create_input_table
" init_data_2000
OUTPUT
" USER_COMMAND_2000
INPUT
SCREEN 2000
Page 47 of 157
6.3
See Development Class SLIS for example programs including drag and drop functionality.
DATA:
TYPE
TYPE
TYPE
TYPE
type
TYPE
TYPE
TYPE
TYPE
TYPE
slis_t_fieldcat_alv,
lvc_t_fcat,
slis_layout_alv,
lvc_s_layo,
disvariant,
slis_print_alv,
slis_t_sortinfo_alv,
slis_t_sp_group_alv,
slis_t_event,
slis_t_listheader.
Page 48 of 157
Page 49 of 157
"handle_user_command
Page 50 of 157
*----------------------------------------------------------------ENDCLASS.
*
* lcl_event_receiver (Implementation)
*===================================================================
PBO
process
MODULE
module
module
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.
*
*
*
*
*
*
*
*
Page 51 of 157
" create_container
OUTPUT
Page 52 of 157
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,
ABAP Programming Tips
Page 53 of 157
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
Page 54 of 157
CREATING AN IDOC
* Creating records
clear e1edp20.
idocdata-segnam = 'E1EDP20'.
e1edp20-edatu = ie020-sched_deliv_date.
e1edp20-wmeng = ie020-sched_qty.
idocdata-sdata = e1edp20.
idocdata-tabnam = idocdata-segnam.
seg_num = seg_num + 1.
idocdata-segnum = seg_num.
shift idocdata-segnum left deleting leading space.
append idocdata.
clear idocdata.
* Once IDoc detail is created
7.2
SENDING AN IDOC
= s_zordrsp_edidc
= 'BUS2032'
= itab_zordrsp_edidc
= itab_zordrsp_edidd
=
=
=
=
=
1
2
3
4
5.
IF sy-subrc <> 0.
return_code = 2.
WRITE: /1 'ZORDRSP IDoc not created'.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE: /1 'IDoc: ', itab_zordrsp_edidc-docnum, ' created'.
HIDE itab_zordrsp_edidc-docnum.
ENDIF.
7.3
CHANGING AN IDOC
Page 55 of 157
IMPORTING
IDOC_CONTROL
EXCEPTIONS
DOCUMENT_NUMBER_INVALID
OTHER_FIELDS_INVALID
STATUS_INVALID
OTHERS
.
= iedidc
=
=
=
=
1
2
3
4
7.4
7.5
READING AN IDOC
Page 56 of 157
exceptions
document_number_invalid = 1
end_of_document
= 2
others
= 3.
if not sy-subrc is initial.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER
= iedidc-docnum
IMPORTING
IDOC_CONTROL
= iedidc
7.6
DISPLAYING AN IDOC
7.7
TYPE-POOLS:
* general idoc type pool
TIDOC.
7.8
Page 57 of 157
c_object_type
l_object_key
c_idc_evt
' '
' '
l_start_recfb_synchron
l_event_id
l_t_ev_container
1
2.
IF
( sy-subrc <> 0 )
* event was not created => error handling for this idoc (EDIM)
OR ( l_event_id = 0 ).
* stop processing, no commit
MESSAGE ID
'E0'
TYPE
'A'
NUMBER '374'
ABAP Programming Tips
Page 58 of 157
WITH
l_status_record-docnum
c_idc_evt
RAISING event_create_failed.
ELSE.
* do commit and reset counter
* the commit will get the idocs to the database and at the same time
* activate the event that was created
COMMIT WORK.
* dequeue all unprocessed IDocs to avoid log-overflow
CALL FUNCTION 'DEQUEUE_ALL'.
CLEAR commit_counter_in.
* reset table of idocs that need to be processed
CLEAR
t_couple_to_process_in.
REFRESH t_couple_to_process_in.
ENDIF.
ENDFORM.
7.9
" ANALYZING_EVENT_CREATE
Page 59 of 157
This note describes in which relations the objects in the IDoc processing are saved.
This know-how is a prerequisite in order to effectively find a special object whose link
was saved during the IDoc processing.
All relationships types defined in the SAP System can be found in table VRBRELTYP.
From the IDoc base, the following essential relationships have been defined:
IDC0 - Application document and outbound IDoc are related
IDC1 - Inbound IDoc and application document are related
IDC3 - Inbound IDoc and its original IDoc are related (while editing)
IDC4 - Inbound IDoc and outbound IDoc of the sending system are related (for R/3 R/3 link)
IDC7 - Outbound IDoc and its original IDoc are related (while editing)
IDC8 - Inbound IDoc and transaction ID (of tRFC) are related
IDCA - Outbound IDoc and transaction ID (of tRFC) are related
In order to read relationships use SREL_GET_NEXT_RELATIONS. Generally, you need to
transfer the BOR object (triple: object key, object type an logical system) for which you
want to read the relationships to this function module.
In order to find a special link you should know in which relationship the link was saved
and whether the BOR object was saved into role A or into role B.
For individual relationship types you can find this information also in table VRBRELTYP.
For the relationship types described above, the object named first is always in role A and
the second object is always in role B.
Example: Searching the outbound IDoc of the sending system for an inbound IDoc which was
generated via an R/3 - R/3 communication. The example source code represents the
correction.
The internal table will then contain an entry from which you can read the following
information:
The fields OBJKEY_A, OBJTYPE_A and LOGSYS_A contain all transferred values of the object
for whose link you are searching - this object occurs in role A.
The field RELTYPE contains the value 'IDC4' - since we only searched for this.
The fields OBJKEY_B, OBJTYPE_B and LOGSYS_B contain all values of the searched linked
object - this searched object occurs in role B.
That is: the field OBJKEY_B contains the IDoc number of the sending system, the field
OBJTYPE_B should contain the value 'IDOC' and the field LOGSYS_B should contain the
sending logical system.
Example
* find the outbound-IDoc of the sending system for an inbound-IDoc,
* which was created during R/3 - R/3 - communication
report test.
data: object1 like borident.
data: begin of links occurs 0.
include structure relgraphlk.
data: end of links.
object1-objkey = '0000000000004711'."IDOC-Nummer of the inbound-IDoc
object1-objtype = 'IDOC'.
object1-logsys = 'TTTCLNT999'.
" << own logical system
CALL FUNCTION 'SREL_GET_NEXT_RELATIONS'
*
*
*
*
*
*
*
EXPORTING
OBJECT
ROLETYPE
RELATIONTYPE
MAX_HOPS
INCL_APPLRELS
EXCL_ROLES
EXCL_RELATIONS
TABLES
LINKS
ROLES
APPLLINKS
EXCEPTIONS
=
=
=
=
=
=
=
object1
'IDC4'
1
' '
= links
=
=
Page 60 of 157
OTHERS
*
*
*
*
*
*
*
*
= 4.
7.10 EXAMPLES
7.10.1
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'.
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
**********************************************************************
*---- Data definition ------------------------------------------------DATA: BEGIN OF BDCDATA OCCURS 5.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
DATA: C_TCODE LIKE BKPF-TCODE VALUE 'FB01'.
DATA BEGIN OF MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF MESSTAB.
ABAP Programming Tips
Page 61 of 157
**********************************************************************
*---- Call transaction -----------------------------------------------FORM Main_Program
REFRESH BDCDATA.
PERFORM APPEND_BDC USING 'SAPMF05A' '0100' '
' '
'.
PERFORM APPEND_BDC USING '
' '
' 'BKPF-BLDAT' '09031998'.
PERFORM APPEND_BDC USING '
' '
' 'BDC_OKCODE' '/00'.
PERFORM APPEND_BDC USING 'SAPMF05A' '0300' '
' '
'.
PERFORM APPEND_BDC USING '
' '
' 'BSEG-WRBTR' '*'.
PERFORM APPEND_BDC USING '
' '
' 'BDC_OKCODE' 'BU'.
CALL TRANSACTION 'FB01' USING BDCDATA MODE 'N' UPDATE 'S'.
PERFORM UPDATE_IDOC_STATUS.
ENDFORM.
**********************************************************************
*--- Call transaction with errors to BDC ----------------------------REFRESH MESSTAB.
CALL TRANSACTION C_TCODE USING BDCDATA MODE 'N' UPDATE 'S'
MESSAGES INTO MESSTAB.
RETURN_CODE = SY-SUBRC.
IF RETURN_CODE = 0.
LOOP AT MESSTAB.
IF MESSTAB-MSGTYP = 'E'.
RETURN_CODE = MESSTAB-MSGNR.
SY-MSGID = 'B1'.
SY-MSGNO = 999.
SY-MSGV1 = 'Error: Check BDC'.
ENDIF.
ENDLOOP.
ENDIF.
*--- Here we check the return code, if there was an error, we put the
*
transaction in a BDC session for the user to review and correct.
IF RETURN_CODE NE 0.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'ZKJW'
USER
= SY-UNAME
KEEP
= 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE
= C_TCODE
TABLES
DYNPROTAB = BDCDATA.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN
= 1
QUEUE_ERROR = 2
OTHERS
= 3.
ENDIF.
**********************************************************************
*--- Append BDCDATA internal table -----------------------------------FORM APPEND_BDC USING
VALUE(P_PROG)
VALUE(P_SCREEN)
VALUE(P_NAM)
VALUE(P_VAL).
CLEAR BDCDATA.
IF P_PROG NE SPACE.
BDCDATA-PROGRAM
BDCDATA-DYNPRO
BDCDATA-DYNBEGIN
BDCDATA-FNAM
BDCDATA-FVAL
ELSE.
BDCDATA-FNAM
BDCDATA-FVAL
ENDIF.
=
=
=
=
=
P_PROG.
P_SCREEN.
'X'.
P_NAM.
P_VAL.
= P_NAM.
= P_VAL.
APPEND BDCDATA.
Page 62 of 157
ENDFORM.
*&---------------------------------------------------------------------*
*&
Form UPDATE_IDOC_STATUS
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM UPDATE_IDOC_STATUS.
*--- Now we check the CALL TRANSACTION return code and set IDOC status
CLEAR IDOC_STATUS.
IF RETURN_CODE = 0.
WORKFLOW_RESULT = '0'.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
IDOC_STATUS-MSGTY = SY-MSGTY.
IDOC_STATUS-MSGID = SY-MSGID.
IDOC_STATUS-MSGNO = SY-MSGNO.
IDOC_STATUS-MSGV1 = SY-MSGV1.
IDOC_STATUS-MSGV2 = SY-MSGV2.
IDOC_STATUS-MSGV3 = SY-MSGV3.
IDOC_STATUS-MSGV4 = SY-MSGV4.
RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
ELSE.
WORKFLOW_RESULT = '99999'.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
IDOC_STATUS-MSGTY = SY-MSGTY.
IDOC_STATUS-MSGID = SY-MSGID.
IDOC_STATUS-MSGNO = SY-MSGNO.
IDOC_STATUS-MSGV1 = SY-MSGV1.
IDOC_STATUS-MSGV2 = SY-MSGV2.
IDOC_STATUS-MSGV3 = SY-MSGV3.
IDOC_STATUS-MSGV4 = SY-MSGV4.
RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
ENDIF.
APPEND IDOC_STATUS.
ENDFORM.
" UPDATE_IDOC_STATUS
7.10.3
Mailing in SAP
Page 63 of 157
Page 64 of 157
IF ZTAUD-MESTYP = SPACE.
CONTINUE.
ELSE.
IF T_ALE_ERR-STATUS = SPACE.
CONTINUE.
ELSE.
W_E1PRTOB = T_IDOC_DATA-SDATA.
T_ALE_ERR-DOCNUMRCV = W_E1PRTOB-DOCNUM.
APPEND T_ALE_ERR.
CLEAR T_ALE_ERR.
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
IF GLOBAL_SUBRC <> 0.
WORKFLOW_RESULT = 99999.
RETURN_VARIABLES-DOC_NUMBER = T_IDOC_CONTROL-DOCNUM.
RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
APPEND RETURN_VARIABLES.
ELSE.
WORKFLOW_RESULT = 0.
CLEAR IDOC_STATUS.
IDOC_STATUS-DOCNUM = T_IDOC_CONTROL-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-MSGTY = 'E'.
IDOC_STATUS-MSGID = 'B1'.
IDOC_STATUS-MSGNO = '999'.
IDOC_STATUS-MSGV1 = TEXT-014.
APPEND IDOC_STATUS.
CLEAR RETURN_VARIABLES.
RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = T_IDOC_CONTROL-DOCNUM.
APPEND RETURN_VARIABLES.
ENDIF.
ENDFUNCTION.
Page 65 of 157
ZTAUD
SUBRC
STRUCTURE ZTAUD
LIKE SY-SUBRC.
LIKE SOOD1,
SOLI-LINE,
EDIDC-STATUS,
SOOD-OBJTP.
" Functional
clear
x_objhead.
refresh x_objhead.
move 6 to raw_head-rawsiz.
move raw_head to x_objhead.
append x_objhead.
REFRESH X_OBJCONT.
CLEAR
X_OBJCONT.
MOVE H_TEXT TO X_OBJCONT.
APPEND X_OBJCONT.
CLEAR
X_OBJCONT.
APPEND X_OBJCONT.
SORT T_ALE_ERR.
LOOP AT T_ALE_ERR.
IF H_STATUS <> T_ALE_ERR-STATUS.
IF H_STATUS <> SPACE.
PERFORM ERROR_REPORT
TABLES X_OBJCONT
T_ALE_ERR_WA
USING H_STATUS
RECEIVING_SYSTEM
SENDING_SYSTEM.
CLEAR T_ALE_ERR_WA.
REFRESH T_ALE_ERR_WA.
ENDIF.
H_STATUS = T_ALE_ERR-STATUS.
ENDIF.
T_ALE_ERR_WA = T_ALE_ERR.
APPEND T_ALE_ERR_WA.
ENDLOOP.
IF SY-SUBRC = 0.
PERFORM ERROR_REPORT
TABLES X_OBJCONT
T_ALE_ERR_WA
USING H_STATUS
RECEIVING_SYSTEM
SENDING_SYSTEM.
CLEAR T_ALE_ERR_WA.
REFRESH T_ALE_ERR_WA.
ENDIF.
CLEAR
X_RECEIVERS.
REFRESH X_RECEIVERS.
MOVE ZTAUD-DLINAM TO X_RECEIVERS-RECNAM. " Distribution list
MOVE 'X'
TO X_RECEIVERS-SNDEX.
MOVE 'C'
TO X_RECEIVERS-RECESC.
APPEND X_RECEIVERS.
CLEAR: SY-MSGID.
CALL FUNCTION 'SO_OBJECT_SEND'
Page 66 of 157
EXPORTING
OBJECT_HD_CHANGE
OBJECT_TYPE
TABLES
OBJCONT
objhead
RECEIVERS
EXCEPTIONS
ACTIVE_USER_NOT_EXIST
COMMUNICATION_FAILURE
COMPONENT_NOT_AVAILABLE
FOLDER_NOT_EXIST
FOLDER_NO_AUTHORIZATION
FORWARDER_NOT_EXIST
NOTE_NOT_EXIST
OBJECT_NOT_EXIST
OBJECT_NOT_SENT
OBJECT_NO_AUTHORIZATION
OBJECT_TYPE_NOT_EXIST
OPERATION_NO_AUTHORIZATION
OWNER_NOT_EXIST
PARAMETER_ERROR
SUBSTITUTE_NOT_ACTIVE
SUBSTITUTE_NOT_DEFINED
SYSTEM_FAILURE
TOO_MUCH_RECEIVERS
USER_NOT_EXIST
X_ERROR
OTHERS
=
=
X_OBJECT_HD_CHANGE
X_OBJECT_TYPE
= X_OBJCONT
= x_objhead
= X_RECEIVERS
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21.
SUBRC = SY-SUBRC.
ENDFORM.
" SEND_SAP_MAIL
*&---------------------------------------------------------------------*
*&
Form ERROR_REPORT
*&---------------------------------------------------------------------*
FORM ERROR_REPORT
TABLES X_OBJCONT
STRUCTURE SOLI
T_ALE_ERR_WA STRUCTURE ALE_ERR_MESSAGE
USING H_STATUS
LIKE EDIDC-STATUS
RECEIVING_SYSTEM LIKE EDIDC-SNDPRN
SENDING_SYSTEM
LIKE EDIDC-RCVPRN.
DATA: H_TEXT
H_LINES(5)
LIKE SOLI-LINE,
TYPE C.
CLEAR X_OBJCONT.
APPEND X_OBJCONT.
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_OBJCONT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
DESCRIBE TABLE T_ALE_ERR_WA LINES H_LINES.
H_TEXT = TEXT-010.
REPLACE '&' WITH H_LINES INTO H_TEXT.
ABAP Programming Tips
Page 67 of 157
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
H_TEXT = TEXT-011.
REPLACE '&' WITH RECEIVING_SYSTEM INTO H_TEXT.
REPLACE '&' WITH SENDING_SYSTEM INTO H_TEXT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
LOOP AT T_ALE_ERR_WA.
H_TEXT = TEXT-012.
REPLACE '&' WITH T_ALE_ERR_WA-DOCNUMRCV INTO H_TEXT.
REPLACE '&' WITH T_ALE_ERR_WA-DOCNUMSND INTO H_TEXT.
X_OBJCONT = H_TEXT.
APPEND X_OBJCONT.
ENDLOOP.
ENDFORM.
7.10.4
" ERROR_REPORT
Includes: ZFORMS
*&---------------------------------------------------------------------*
*& Report Z_REPORT_ZTABLE
*
*&---------------------------------------------------------------------*
* Author: Kevin Wilson
Date: 15th September, 2000
* Detail: This program loops through the sales order table, taking
*
relevant data and storing it in the ZTABLE table. The
*
ZTABLE table stores the status of an order in the EDI
*
process.
*&---------------------------------------------------------------------*
REPORT Z_REPORT_ZTABLE LINE-SIZE 160.
*--- TABLE DEFINITIONS ------------------------------------------------TABLES: VBAK, VBAP, VBFA, VBPA, ZTABLE, EDIDC, EDIDD, EDID4, Z1824HD.
*--- INTERNAL TABLE DEFINITIONS ---------------------------------------* ITAB_SO_EXTRA stores the key of ITAB_SO as well as additional fields
* that may be required down the line. eg. Material number and billing
* block.
TYPES: BEGIN OF ITAB_SO_EXTRA_TYPE,
VBELN LIKE VBAK-VBELN,
"Sales Order #
BSTNK LIKE VBAK-BSTNK,
"PO #
POSNR LIKE VBAP-POSNR,
"Sales Order Line #
FAKSP LIKE VBAP-FAKSP,
"Line Item Billing block
MATNR LIKE VBAP-MATNR,
"Material number
END OF ITAB_SO_EXTRA_TYPE.
* Create an internal table to store the invoice numbers
* of those invoices that do not have INVOIC Idocs attached to them.
* i.e. The ZD01 output was not created for some reason.
TYPES: BEGIN OF TITAB_TYPE,
O810 LIKE ZTABLE-O810NO,
END OF TITAB_TYPE.
* Internal table definitions containing the data entries for ZTABLE
DATA: ITAB_SO LIKE ZTABLE OCCURS 20000 WITH HEADER LINE,
ITAB_SO_EXTRA TYPE ITAB_SO_EXTRA_TYPE
OCCURS 20000 WITH HEADER LINE.
* Internal table definitions containing invoice numbers that need to be
* saved in order to generate the ZD01 output.
DATA: TITAB TYPE TITAB_TYPE OCCURS 100 WITH HEADER LINE.
* Column names required for file download.
DATA: BEGIN OF T_COLNAMES OCCURS 10,
NAME(15),
"Column names for download
END OF T_COLNAMES.
*--- DATA DEFINITIONS -------------------------------------------------DATA: E1EDP26 TYPE E1EDP26,
E1EDP01 TYPE E1EDP01,
"Line item segment
T_POSNR LIKE VBAP-POSNR,
"Line item number
INVOICE_FLAG(1),
"Is there an invoice? Y/N
DELIVERY_FLAG(1),
"Is there a delivery? Y/N
FIELD_NAME(30),
"Check for line selection on field
ABAP Programming Tips
Page 68 of 157
Page 69 of 157
LOOP AT ITAB_SO.
* We need to see if the order we have is a CO. A order. A CO. A order
* is uniquely identified with Division = 12 and Order type = ZEDI
SELECT SINGLE SPART AUART FROM VBAK INTO (VBAK-SPART, VBAK-AUART)
WHERE VBELN = ITAB_SO-VBELN.
IF SY-SUBRC = 0.
* Check for CO. A order
IF VBAK-SPART = C_SPART_12 AND VBAK-AUART = C_AUART_ZEDI.
T_POSNR = ITAB_SO-POSNR DIV 10.
SELECT MATNR FAKSP FROM VBAP
INTO (ITAB_SO_EXTRA-MATNR,
ITAB_SO_EXTRA-FAKSP)
WHERE VBELN = ITAB_SO-VBELN AND
POSNR = T_POSNR.
ITAB_SO_EXTRA-VBELN = ITAB_SO-VBELN.
ITAB_SO_EXTRA-POSNR = ITAB_SO-POSNR.
ITAB_SO_EXTRA-BSTNK = ITAB_SO-BSTKD.
APPEND ITAB_SO_EXTRA.
ENDSELECT.
"Update extra details
ENDIF.
"Check for CO. A orders with DIV=12 & Ord Type=ZEDI
ENDIF. "Sy-subrc check on lookup for DIV and Ord Type
ENDLOOP.
"ITAB_SO internal table loop
* Print ITAB_SO and ITAB_SO_EXTRA contents
* customers not selected via the selection
PERFORM PRINT_ITAB
TABLES ITAB_SO
ITAB_SO_EXTRA.
ELSE.
"No
MESSAGE I999(B1) WITH TEXT-005. "No
ENDIF.
ENDIF.
* Loop through the internal table set up to store the invoice numbers
* of those invoices that do not have INVOIC Idocs attached to them.
PERFORM SAVE_BILLING_DOC TABLES TITAB.
END-OF-SELECTION.
* --- EVENT : AT LINE SELECTION --AT LINE-SELECTION.
* Return the field that the user clicked on
GET CURSOR FIELD FIELD_NAME.
CASE FIELD_NAME.
* Clicked on message from 824
WHEN 'ITAB_SO-I824810NOTE' OR 'ITAB_SO-I824856NOTE'.
IF T_IDOC <> ''.
IF T_STAT = 'R'.
* Return the full detail of the error using report Z_LIST_IDOC_824
SUBMIT Z_LIST_IDOC_824 WITH I_DOCN = T_IDOC AND RETURN.
ELSE.
MESSAGE I999(B1) WITH TEXT-013."IDoc not rejected
ENDIF.
ELSE.
MESSAGE I999(B1) WITH TEXT-012."No IDoc
ENDIF.
* Clicked on Invoice number
WHEN 'ITAB_SO-O810NO'.
IF ITAB_SO-O810NO <> ''.
SET PARAMETER ID 'VF' FIELD ITAB_SO-O810NO.
CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN. "View Invoice
ELSE.
MESSAGE I999(B1) WITH TEXT-008."Click on invoice
ENDIF.
* Clicked on delivery number
WHEN 'ITAB_SO-O856NO'.
IF ITAB_SO-O856NO <> ''.
SET PARAMETER ID 'VL' FIELD ITAB_SO-O856NO.
CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN. "View delivery
ELSE.
MESSAGE I999(B1) WITH TEXT-010."Click on Delivery
ENDIF.
* Clicked on Sales Order number
WHEN 'ITAB_SO-VBELN'.
SET PARAMETER ID 'AUN' FIELD ITAB_SO-VBELN.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN. "View Sales Order
* DESADV Idoc # clicked
ABAP Programming Tips
Page 70 of 157
WHEN 'ITAB_SO-O856DOCNUM'.
IF ITAB_SO-O856DOCNUM <> ''.
MOVE ITAB_SO-O856DOCNUM TO T_IDOC.
CALL FUNCTION 'EDI_DOCUMENT_DATA_DISPLAY'
"Dsiplay Idoc
EXPORTING
DOCNUM
= T_IDOC
TREE_DISPLAY
= 'Y'
EXCEPTIONS
NO_DATA_RECORD_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC <> 0.
MESSAGE I999(B1) WITH TEXT-007.
"Click on IDoc.
ENDIF.
ELSE.
MESSAGE I999(B1) WITH TEXT-007."Click on IDoc.
ENDIF.
* INVOIC Idoc # clicked
WHEN 'ITAB_SO-O810DOCNUM'.
IF ITAB_SO-O810DOCNUM <> ''.
MOVE ITAB_SO-O810DOCNUM TO T_IDOC.
CALL FUNCTION 'EDI_DOCUMENT_DATA_DISPLAY'
"Display an IDoc.
EXPORTING
DOCNUM
= T_IDOC
TREE_DISPLAY
= 'Y'
EXCEPTIONS
NO_DATA_RECORD_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC <> 0.
MESSAGE I999(B1) WITH TEXT-007.
"Click on IDoc.
ENDIF.
ELSE.
MESSAGE I999(B1) WITH TEXT-007."Click on IDoc.
ENDIF.
* ZAPPADV810 IDoc # clicked
WHEN 'ITAB_SO-I824810DOCNUM'.
IF ITAB_SO-I824810DOCNUM <> ''.
MOVE ITAB_SO-I824810DOCNUM TO T_IDOC.
CALL FUNCTION 'EDI_DOCUMENT_DATA_DISPLAY' "Display IDoc
EXPORTING
DOCNUM
= T_IDOC
TREE_DISPLAY
= 'Y'
EXCEPTIONS
NO_DATA_RECORD_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC <> 0.
MESSAGE I999(B1) WITH TEXT-007.
"Click on IDoc.
ENDIF.
ELSE.
MESSAGE I999(B1) WITH TEXT-007."Click on IDoc.
ENDIF.
* ZAPPADV856 IDoc # clicked
WHEN 'ITAB_SO-I824856DOCNUM'.
IF ITAB_SO-I824856DOCNUM <> ''.
MOVE ITAB_SO-I824856DOCNUM TO T_IDOC.
CALL FUNCTION 'EDI_DOCUMENT_DATA_DISPLAY' "Display IDoc
EXPORTING
DOCNUM
= T_IDOC
TREE_DISPLAY
= 'Y'
EXCEPTIONS
NO_DATA_RECORD_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC <> 0.
MESSAGE I999(B1) WITH TEXT-007.
"Click on IDoc.
ENDIF.
ELSE.
MESSAGE I999(B1) WITH TEXT-007."Click on IDoc.
ENDIF.
ENDCASE.
"Evaluation of field names
Include: ZFORMS
*----------------------------------------------------------------------*
***INCLUDE Z_FORMS .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
Form UPDATE_ITAB_SO
*&---------------------------------------------------------------------*
ABAP Programming Tips
Page 71 of 157
*
Loop through VBAP and update the table ZTABLE
*----------------------------------------------------------------------*
*
-->VBAK_VBELN Sales Order Number
*
-->VBAK_ERDAT Sales Order Date
*
-->VBAK_BSTNK Purchase Order Number
*----------------------------------------------------------------------*
FORM UPDATE_ITAB_SO USING VBAK_VBELN
VBAK_ERDAT
VBAK_BSTNK.
* --- LOCAL VARIABLES --DATA: T_POSNR
LIKE VBAP-POSNR,
T_VBELN_DOCNUM LIKE EDIDC-DOCNUM,
T_VBELN_DATE
LIKE EDIDC-CREDAT,
T_PRICE
LIKE ZTABLE-O810PRICE,
T_SEGNUM
LIKE EDID4-SEGNUM,
T_824_DOCNUM
LIKE EDIDC-DOCNUM,
T_824_NOTE
LIKE ZTABLE-I824856NOTE,
T_824_STAT
LIKE ZTABLE-I824856STAT,
T_824_DATE
LIKE EDIDC-CREDAT,
N1 TYPE I.
* --- LOCAL INTERNAL TABLES --DATA: ITAB_LINKED_IDOCS LIKE SWW_CONTOB OCCURS 5 WITH HEADER LINE.
* Initialization
CLEAR: ITAB_SO, ITAB_SO_EXTRA.
* Store Sales Order Header Data
MOVE: VBAK_VBELN TO ITAB_SO-VBELN,
VBAK_ERDAT TO ITAB_SO-DATUM,
VBAK_BSTNK TO ITAB_SO-BSTKD.
MOVE: VBAK_VBELN TO ITAB_SO_EXTRA-VBELN,
VBAK_BSTNK TO ITAB_SO_EXTRA-BSTNK.
* Get ship to customer number from VBPA
SELECT SINGLE KUNNR FROM VBPA INTO ITAB_SO-KUNNR
WHERE VBELN = VBAK_VBELN
AND
POSNR = '000000'
AND
PARVW = 'WE'.
"Ship to partner function
* Loop through the sales order line items.
SELECT * FROM VBAP WHERE VBELN = VBAK_VBELN.
T_POSNR = VBAP-POSNR * 10.
MOVE: T_POSNR TO ITAB_SO-POSNR.
MOVE: T_POSNR TO ITAB_SO_EXTRA-POSNR,
VBAP-FAKSP TO ITAB_SO_EXTRA-FAKSP,
"Billing block
VBAP-MATNR TO ITAB_SO_EXTRA-MATNR.
"Material #
*
Page 72 of 157
OBJECT_NOT_FOUND
= 1
NO_IDOCS_LINKED
= 2
OBJECT_TYPE_UNKNOWN = 3
INTERNAL_ERROR
= 4
OTHERS
= 5.
IF SY-SUBRC = 0.
CLEAR: T_VBELN_DOCNUM, T_824_DOCNUM.
CLEAR: T_VBELN_DATE, T_824_DATE.
* FILTER OUT ALL BUT THE LATEST IDOCS
PERFORM GET_IDOC_MESTYP TABLES ITAB_LINKED_IDOCS
USING 'LIKP' T_POSNR
CHANGING T_VBELN_DOCNUM
T_VBELN_DATE
T_824_STAT
T_824_NOTE
T_824_DATE
T_824_DOCNUM.
MOVE T_VBELN_DOCNUM TO ITAB_SO-O856DOCNUM.
MOVE T_VBELN_DATE
TO ITAB_SO-O856DATE.
MOVE T_824_DOCNUM
TO ITAB_SO-I824856DOCNUM.
MOVE T_824_STAT
TO ITAB_SO-I824856STAT.
MOVE T_824_NOTE
TO ITAB_SO-I824856NOTE.
MOVE T_824_DATE
TO ITAB_SO-I824856DATE.
REFRESH: ITAB_LINKED_IDOCS[], ITAB_LINKED_IDOCS.
CLEAR: ITAB_LINKED_IDOCS.
ELSE.
"No IDocs were linked to Delivery
MOVE '' TO ITAB_SO-O856DOCNUM.
MOVE '' TO ITAB_SO-O856DATE.
MOVE '' TO ITAB_SO-I824856DOCNUM.
MOVE 'N' TO ITAB_SO-I824856STAT.
MOVE 'No 824 received' TO ITAB_SO-I824856NOTE.
MOVE '' TO ITAB_SO-I824856DATE.
ENDIF.
ELSE.
"In case the delivery is not there...
MOVE '' TO ITAB_SO-O856DOCNUM.
MOVE '' TO ITAB_SO-O856DATE.
MOVE '' TO ITAB_SO-I824856DOCNUM.
MOVE 'N' TO ITAB_SO-I824856STAT.
MOVE 'No 824 received' TO ITAB_SO-I824856NOTE.
MOVE '' TO ITAB_SO-I824856DATE.
ENDIF.
WHEN 'M'.
"Invoice
INVOICE_FLAG = 'X'.
MOVE VBFA-VBELN TO ITAB_SO-O810NO.
IF ITAB_SO-O810NO <> ''.
* Return the list of IDocs linked to the invoice
CALL FUNCTION 'EDI_GET_LINKED_IDOCS'
EXPORTING
OBJTYPE
= 'VBRK'
OBJKEY
= ITAB_SO-O810NO
TABLES
LINKED_IDOCS
= ITAB_LINKED_IDOCS
EXCEPTIONS
OBJECT_NOT_FOUND
= 1
NO_IDOCS_LINKED
= 2
OBJECT_TYPE_UNKNOWN = 3
INTERNAL_ERROR
= 4
OTHERS
= 5.
IF SY-SUBRC = 0.
CLEAR: T_VBELN_DOCNUM, T_824_DOCNUM, T_824_NOTE, T_824_STAT.
CLEAR: T_VBELN_DATE, T_824_DATE.
* FILTER OUT ALL BUT THE LATEST IDOCS
PERFORM GET_IDOC_MESTYP TABLES ITAB_LINKED_IDOCS
USING 'VBRK' T_POSNR
CHANGING T_VBELN_DOCNUM
T_VBELN_DATE
T_824_STAT
T_824_NOTE
T_824_DATE
T_824_DOCNUM.
MOVE T_VBELN_DOCNUM TO ITAB_SO-O810DOCNUM.
MOVE T_VBELN_DATE
TO ITAB_SO-O810DATE.
MOVE T_824_DOCNUM
TO ITAB_SO-I824810DOCNUM.
MOVE T_824_STAT
TO ITAB_SO-I824810STAT.
ABAP Programming Tips
Page 73 of 157
MOVE T_824_NOTE
MOVE T_824_DATE
TO ITAB_SO-I824810NOTE.
TO ITAB_SO-I824810DATE.
''
'N'
'No
''
MOVE
MOVE
MOVE
MOVE
''
''
''
''
MOVE
MOVE
MOVE
MOVE
ENDIF.
''
'N'
'No
''
TO ITAB_SO-I824856DOCNUM.
TO ITAB_SO-I824856STAT.
824 received' TO ITAB_SO-I824856NOTE.
TO ITAB_SO-I824856DATE.
TO
TO
TO
TO
ITAB_SO-O810DOCNUM.
ITAB_SO-O810DATE.
ITAB_SO-O810PRICE.
ITAB_SO-O810NO.
TO ITAB_SO-I824810DOCNUM.
TO ITAB_SO-I824810STAT.
824 received' TO ITAB_SO-I824810NOTE.
TO ITAB_SO-I824810DATE.
"Subsequent documents
Page 74 of 157
Page 75 of 157
*
*
*
*
*
*
*
*
Page 76 of 157
EDIDC-DOCNUM,
Z1824HD,
Z1824TH,
Z1824DT,
Z1824TD,
EDID4-SEGNUM,
ZTABLE-I824856NOTE,
ZTABLE-I824856NOTE,
ZTABLE-I824856NOTE,
ZTABLE-I824856STAT,
"Header text
"Line item text
Page 77 of 157
ELSE.
"Found 824 for this line item
T_824_DOCNUM = EDIDC-DOCNUM.
T_824_DATE
= EDIDC-CREDAT.
ENDIF.
ENDSELECT.
ENDCASE.
ENDIF.
ENDLOOP.
WHEN 'VBRK'.
"Invoice
LOOP AT ITAB_LINKED_IDOCS WHERE OBJTYPE = 'IDOC'.
T_DOCNUM = ITAB_LINKED_IDOCS-OBJKEY.
SELECT SINGLE DOCNUM CREDAT MESTYP FROM EDIDC
INTO (EDIDC-DOCNUM,
EDIDC-CREDAT,
EDIDC-MESTYP)
WHERE DOCNUM = T_DOCNUM.
IF SY-SUBRC = 0.
CASE EDIDC-MESTYP.
WHEN 'INVOIC'.
"Outbound delivery
T_VBELN_DOCNUM = EDIDC-DOCNUM.
T_VBELN_DATE = EDIDC-CREDAT.
WHEN 'ZAPPADV810' OR 'ZAPPADV'. "824 Signal repsonse to 810
SELECT * FROM EDID4 WHERE DOCNUM = EDIDC-DOCNUM
AND SEGNAM
= 'Z1824DT'.
MOVE EDID4-SDATA TO Z1824DT.
IF Z1824DT-POLINE <> T_LINE. "Not relevant for this line
CONTINUE.
ELSE.
"Found 824 for this line item
T_824_DOCNUM = EDIDC-DOCNUM.
T_824_DATE
= EDIDC-CREDAT.
ENDIF.
ENDSELECT.
ENDCASE.
ENDIF.
ENDLOOP.
ENDCASE.
* Check status of the 824 IDocs
IF T_824_DOCNUM IS INITIAL.
"No 824 linked to Document
T_824_NOTE = 'No 824 received'.
T_824_STAT = 'N'.
ELSE.
SELECT SINGLE * FROM EDID4 WHERE DOCNUM = T_824_DOCNUM AND
SEGNAM = 'Z1824HD'.
IF SY-SUBRC = 0.
MOVE EDID4-SDATA TO Z1824HD.
CASE Z1824HD-ACKCODE.
WHEN 'TA'.
"Transaction accepted
H_MESSAGE = 'OK'.
L_MESSAGE = 'OK'.
T_STATUS
= 'A'.
WHEN 'TR'.
"Transaction rejected
* Header text
SELECT SINGLE * FROM EDID4 WHERE
DOCNUM = T_824_DOCNUM AND
SEGNAM = 'Z1824TH'.
IF SY-SUBRC = 0.
MOVE EDID4-SDATA TO Z1824TH.
H_MESSAGE = Z1824TH-LINE.
ELSE.
H_MESSAGE = 'No header error text segment Z1824TH'.
ENDIF.
"Search for Text header
SELECT * FROM EDID4 WHERE DOCNUM = T_824_DOCNUM AND
SEGNAM = 'Z1824DT'.
MOVE EDID4-SDATA TO Z1824DT.
IF Z1824DT-POLINE = T_LINE.
T_SEGNUM = EDID4-SEGNUM.
IF Z1824DT-ACKCODE = 'IA'. "Item accepted
L_MESSAGE = 'OK'.
T_STATUS
= 'A'.
EXIT.
ELSEIF Z1824DT-ACKCODE = 'IC'. "Item accepted but changed
T_STATUS
= 'C'.
* Line item text for that line item number
SELECT SINGLE * FROM EDID4 WHERE
DOCNUM = T_824_DOCNUM AND
ABAP Programming Tips
Page 78 of 157
Page 79 of 157
APPEND T_COLNAMES.
MOVE 'Delivery IDoc Number' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE 'Delivery Number' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Status for 856' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Date for 856' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 IDoc for 856' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Note for 856' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE 'Invoice Date' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE 'Invoice IDoc Number' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE 'Invoice Number' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE 'Invoice Price' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Status for 810' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Date for 810' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 IDoc for 810' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
MOVE '824 Note for 810' TO T_COLNAMES-NAME.
APPEND T_COLNAMES.
* Write data in internal table ITAB_SO to file specified in parameters
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME
= P_FILE
FILETYPE
= 'DAT'
TABLES
DATA_TAB
= ITAB_SO
FIELDNAMES
= T_COLNAMES
EXCEPTIONS
FILE_OPEN_ERROR
= 1
FILE_WRITE_ERROR
= 2
INVALID_FILESIZE
= 3
INVALID_TABLE_WIDTH
= 4
INVALID_TYPE
= 5
NO_BATCH
= 6
UNKNOWN_ERROR
= 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS
= 9.
IF SY-SUBRC = 0.
ELSEIF SY-SUBRC = 1.
MESSAGE I027(Z3) WITH P_FILE.
ELSEIF SY-SUBRC = 2.
MESSAGE I028(Z3) WITH P_FILE.
ELSEIF SY-SUBRC = 3.
MESSAGE I001(Z4) WITH P_FILE.
ELSEIF SY-SUBRC = 4.
MESSAGE I002(Z4) WITH P_FILE.
ELSEIF SY-SUBRC = 5.
MESSAGE I003(Z4) WITH P_FILE.
ELSEIF SY-SUBRC = 6.
MESSAGE I004(Z4) WITH P_FILE.
ELSEIF SY-SUBRC = 7.
MESSAGE I005(Z4) WITH P_FILE.
ELSEIF SY-SUBRC = 8.
MESSAGE I006(Z4) WITH P_FILE.
ELSE.
MESSAGE I007(Z4) WITH P_FILE.
ENDIF.
ENDFORM.
" DOWNLOAD_FILE
*&---------------------------------------------------------------------*
*&
Form SAVE_BILLING_DOC
*&---------------------------------------------------------------------*
* Loop through the internal table set up to store the invoice numbers
* of those invoices that do not have INVOIC Idocs attached to them.
* i.e. The ZD01 output was not created for some reason.
* By saving the invoice (which is what this program does) the output
ABAP Programming Tips
Page 80 of 157
* should be generated.
*----------------------------------------------------------------------*
*
-->TITAB Stores invoice numbers of those invoices that do not
*
have INVOIC IDocs linked to them.
*----------------------------------------------------------------------*
FORM SAVE_BILLING_DOC TABLES
TITAB STRUCTURE TITAB.
DATA: N TYPE I.
LOOP AT TITAB.
SUBMIT ZVF02SAVE WITH BILLING = TITAB-O810 AND RETURN.
MESSAGE I009(Z4) WITH TITAB-O810.
ENDLOOP.
IF SY-SUBRC = 0.
DESCRIBE TABLE TITAB LINES N.
MESSAGE I008(Z4) WITH N.
ENDIF.
ENDFORM.
" SAVE_BILLING_DOC
7.10.5
data:
INFILE
back_path(7)
info_no
offset
p01_ctr
seg_num
data:
data:
data:
data:
data:
data:
LIKE
type
like
like
like
like
default '/ftp/atac/in/'.
PATH-PATHEXTERN,
c value 'backup/',
ekpo-infnr,
sy-fdpos,
sy-index,
sy-index.
Page 81 of 157
qty_ordered
end of ie020.
like e1edp01-menge,
Page 82 of 157
Page 83 of 157
endif.
perform idoc_sched_segs.
save_po = ie020-po_number.
save_line = ie020-po_lineno.
save_vend_part = ie020-vendor_partno.
save_cust_part = ie020-cust_partno.
endloop.
perform idoc_mat_seg.
perform post_prev_idoc.
* File successfully processed: &
message s035 with infile.
ENDFORM.
" process_one_vendor
*&---------------------------------------------------------------------*
*&
Form convert_po_no
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM convert_po_no using value(infield)
changing po_number like ie020-po_number
po_line
like ie020-po_lineno.
data:
" convert_po_no
*&---------------------------------------------------------------------*
*&
Form convert_date
*&---------------------------------------------------------------------*
*
Convert yymmdd to ccyymmdd for SAP and
*
convert ship date to delivery date
*----------------------------------------------------------------------*
FORM convert_date USING value(DATE6)
value(DATE_TYPE)
value(i_ship_code)
CHANGING DATE8
ABAP Programming Tips
like IE020-SCHED_DATE
Page 84 of 157
SHIP_DAYS
like ie020-ship_days
DELIVERY_DATE like ie020-sched_deliv_date.
data:
cent(2) type c,
d_date type d.
" convert_date
*&---------------------------------------------------------------------*
*&
Form quantity_conversion
*&---------------------------------------------------------------------*
*
The quantities in the input file are implied 3-decimal,
*
so need to be converted into a "real" number.
*
Also, the unit of measure may be 'KP' indicating that the qty
*
is given in thousands.
*----------------------------------------------------------------------*
FORM convert_quantities USING value(i_UOM)
value(i_confirm_qty)
value(i_QTY_ORDERED)
CHANGING o_uom like iE020-UOM
o_confirm_qty like IE020-SCHED_QTY
o_qty_ordered like IE020-QTY_ORDERED.
constants: thou type p decimals 3 value '1000'.
data:
Page 85 of 157
o_confirm_qty = n_confirm_qty.
shift o_confirm_qty left deleting leading space.
else.
clear o_confirm_qty.
endif.
if not n_qty_ordered is initial.
o_qty_ordered = n_qty_ordered.
shift o_qty_ordered left deleting leading space.
else.
clear o_qty_ordered.
endif.
ENDFORM.
" convert_quantities
*&---------------------------------------------------------------------*
*&
Form idoc_header_segs
*&---------------------------------------------------------------------*
*
create internal table entries for PO header segments:
*
E1EDK01
*
E1EDK02
*----------------------------------------------------------------------*
FORM idoc_header_segs.
clear seg_num.
idocdata-segnam = 'E1EDK01'.
idocdata-sdata = e1edk01.
perform append_idoc_rec.
clear e1edk02.
idocdata-segnam = 'E1EDK02'.
e1edk02-qualf = '001'.
e1edk02-belnr = ie020-po_number.
idocdata-sdata = e1edk02.
perform append_idoc_rec.
ENDFORM.
" idoc_header_segs
*&---------------------------------------------------------------------*
*&
Form idoc_item_segs
*&---------------------------------------------------------------------*
*
create internal table entries for PO item header segments:
*
E1EDP01
*
E1EDP02
*----------------------------------------------------------------------*
FORM idoc_item_segs.
clear e1edp01.
idocdata-segnam = 'E1EDP01'.
e1edp01-menee = ie020-uom.
e1edp01-menge = ie020-qty_ordered.
idocdata-sdata = e1edp01.
perform append_idoc_rec.
clear e1edp02.
idocdata-segnam = 'E1EDP02'.
e1edp02-qualf = '001'.
e1edp02-belnr = ie020-po_number.
e1edp02-zeile = ie020-po_lineno.
idocdata-sdata = e1edp02.
perform append_idoc_rec.
idocdata-segnam = 'E1EDP02'.
clear e1edp02.
e1edp02-qualf = '002'.
e1edp02-belnr = ie020-slip_number.
e1edp02-datum = ie020-sched_date.
idocdata-sdata = e1edp02.
perform append_idoc_rec.
p01_ctr = p01_ctr + 1.
ENDFORM.
" idoc_item_segs
*&---------------------------------------------------------------------*
*&
Form idoc_sched_segs
*&---------------------------------------------------------------------*
*
create internal table entries for PO item schedule segments:
*
E1EDP20
ABAP Programming Tips
Page 86 of 157
*----------------------------------------------------------------------*
FORM idoc_sched_segs.
clear e1edp20.
idocdata-segnam = 'E1EDP20'.
e1edp20-edatu = ie020-sched_deliv_date.
e1edp20-wmeng = ie020-sched_qty.
idocdata-sdata = e1edp20.
perform append_idoc_rec.
ENDFORM.
" idoc_sched_segs
*&---------------------------------------------------------------------*
*&
Form idoc_mat_seg
*&---------------------------------------------------------------------*
*
create internal table entries for PO item material no. segments:
*
E1EDP19
*----------------------------------------------------------------------*
FORM idoc_mat_seg.
tables:
ekpo.
clear e1edp19.
idocdata-segnam = 'E1EDP19'.
e1edp19-qualf = '002'.
e1edp19-idtnr = save_vend_part.
e1edp19-mfrpn = save_cust_part.
idocdata-sdata = e1edp19.
perform append_idoc_rec.
clear e1edp19.
select single matnr from ekpo into e1edp19-idtnr
where ebeln = save_po and
ebelp = save_line.
if not e1edp19-idtnr is initial.
idocdata-segnam = 'E1EDP19'.
e1edp19-qualf = '001'.
idocdata-sdata = e1edp19.
perform append_idoc_rec.
endif.
ENDFORM.
" idoc_mat_seg
***********************************************************************
*&
Form post_prev_idoc
*&---------------------------------------------------------------------*
*
create a database idoc from the idocdata table and clear table.
*----------------------------------------------------------------------*
FORM post_prev_idoc.
clear e1eds01.
idocdata-segnam = 'E1EDS01'.
e1eds01-sumid = '001'.
e1eds01-summe = p01_ctr.
shift e1eds01-summe left deleting leading space.
idocdata-sdata = e1eds01.
perform append_idoc_rec.
CALL FUNCTION 'INBOUND_IDOC_PROCESS'
TABLES
IDOC_CONTROL
= iedidc
IDOC_DATA
= idocdata.
commit work.
refresh idocdata.
clear:
idocdata,
p01_ctr,
save_po,
save_line,
save_vend_part,
save_cust_part.
ENDFORM.
" post_prev_idoc
*&---------------------------------------------------------------------*
ABAP Programming Tips
Page 87 of 157
*&
Form append_idoc_rec
*&---------------------------------------------------------------------*
*
add a data record to the IDoc internal table
*----------------------------------------------------------------------*
FORM append_idoc_rec.
idocdata-tabnam = idocdata-segnam.
seg_num = seg_num + 1.
idocdata-segnum = seg_num.
shift idocdata-segnum left deleting leading space.
append idocdata.
clear idocdata.
ENDFORM.
7.10.6
" append_idoc_rec
data:
data:
data:
data:
data:
data:
data:
data:
Page 88 of 157
data:
" append_idoc_rec
Page 89 of 157
perform init_invoic.
concatenate 'SAP' sy-sysid(3) into: iedidc-sndpor, dedidc-sndpor.
loop at uty_vendors.
clear ie021. refresh ie021.
if not uty_vendors-name_abbr is initial.
* datafiles are received with naming convention:
* E020_<customer name abbreviation>_UTY
concatenate p_path 'E021_' uty_vendors-name_abbr '_UTY'
into infile.
if not sy-subrc is initial. "pathname too long
* Filename too long: &
message i016 with infile.
continue.
endif.
condense infile.
OPEN DATASET INFILE FOR INPUT IN TEXT MODE.
if not sy-subrc is initial.
*'Cannot open dataset & on &'
message i013 with infile sy-datum.
continue.
else.
concatenate p_path back_path 'E021_'
uty_vendors-name_abbr '_UTY' today
into outfile.
if not sy-subrc is initial. "pathname too long
* Filename too long: &
message i016 with outfile.
continue.
endif.
condense outfile.
OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE.
* if the datestamped file cannot be created, do not process the
* input file, because the input file is deleted after processing,
* and there would be no record of the data.
if not sy-subrc is initial.
*'ERROR opening file & for output'
close dataset infile.
message i033 with outfile.
continue. "process next vendor's file
endif.
do.
read dataset infile into izss7b21.
case sy-subrc.
when 0.
transfer izss7b21 to outfile.
if izss7b21-datacode = 'T'. "trailer rec
perform process_one_vendor using infile.
exit. "process next vendor's file
endif.
check: izss7b21-datacode = 'A'. "data rec
case izss7b21-status.
when ' '. "new
ie021-stat = '000'.
when 'M'. "modification
ie021-stat = '002'.
when 'D'. "deletion
ie021-stat = '003'.
endcase.
move-corresponding uty_vendors to ie021.
move-corresponding izss7b21 to ie021.
perform convert_po_no using izss7b21-pono_poline
changing ie021-po_number
ie021-po_lineno.
perform convert_dates using ie021-lifnr
izss7b21-etd
izss7b21-eta
izss7b21-ship_method
izss7b21-create_date
changing ie021-eta
ie021-ship_days.
perform quantity_conversion
using izss7b21-qty_uom
izss7b21-invoice_qty
ABAP Programming Tips
Page 90 of 157
izss7b21-unit_price
changing ie021-qty_uom
ie021-invoice_qty
izss7b21-line_amount.
perform money_conversion
using izss7b21-currency
izss7b21-unit_price
izss7b21-price_uom
izss7b21-line_amount
changing ie021-currency
ie021-price_uom
ie021-price_qty
ie021-unit_price
ie021-line_amount.
perform SAP_vendor_partno
changing ie021-cust_partno.
append ie021.
when 4. "EOF
perform process_one_vendor using infile.
exit. "process next vendor's file
when others.
*ERROR reading dataset & - &
message i015 with infile sy-datum.
exit.
endcase.
enddo.
close dataset: infile, outfile.
delete dataset infile.
endif.
endif.
endloop. "UTY_VENDORS
*&---------------------------------------------------------------------*
*&
Form process_one_vendor
*&---------------------------------------------------------------------*
*
Pre-processed records from one vendor file are now in the
*
internal table ie021 - ready to create IDocs
*----------------------------------------------------------------------*
FORM process_one_vendor using value(infile).
sort ie021 by invoice_no stat po_number po_lineno.
loop at ie021.
if ( ie021-invoice_no <> save_invoice or
ie021-stat <> save_stat ).
if sy-tabix > 1.
perform post_idocs using ie021-stat.
endif.
perform idoc_header_segs using ie021-stat.
endif.
if ( ie021-stat <> save_stat or
ie021-po_number <> save_po or
ie021-po_lineno <> save_line or
ie021-invoice_no <> save_invoice ).
if ( sy-tabix > 1 and
ie021-stat = '000' ).
perform idoc_poheader_segs.
endif.
endif.
perform idoc_item_segs using ie021-stat.
save_po = ie021-po_number.
save_line = ie021-po_lineno.
save_invoice = ie021-invoice_no.
save_stat = ie021-stat.
endloop.
perform post_idocs using ie021-stat.
* File successfully processed: &
message s035 with infile.
ENDFORM.
" process_one_vendor
*&---------------------------------------------------------------------*
*&
Form convert_po_no
*&---------------------------------------------------------------------*
*
Break the PO number & line field into separate fields
*----------------------------------------------------------------------*
FORM convert_po_no using value(infield)
changing po_number like ie021-po_number
ABAP Programming Tips
Page 91 of 157
ship_date type d.
*
*
*
*
Page 92 of 157
" convert_dates
*&---------------------------------------------------------------------*
*&
Form quantity_conversion
*&---------------------------------------------------------------------*
*
The quantities in the input file are implied 3-decimal,
*
so need to be converted into a "real" number.
*
Also, the unit of measure may be 'KP' indicating that the qty
*
is given in thousands.
*----------------------------------------------------------------------*
FORM quantity_conversion USING
value(i_UOM)
value(i_invoice_qty)
value(i_unit_price)
CHANGING o_uom like iE021-qty_UOM
o_invoice_qty like IE021-INVOICE_QTY
c_LINE_AMOUNT like izss7b21-line_amount.
data:
data:
data:
data:
data:
*
*
*
*
*
f_invoice_qty type f.
n_invoice_qty like lips-kcmeng.
f_unit_price type f.
f_line_amt type f.
n_line_amt0 type p decimals 0.
ENDFORM.
" quantity_conversion
*&---------------------------------------------------------------------*
*&
Form money_conversion
*&---------------------------------------------------------------------*
*
Add the implied decimals and store price-per qty, if
*
price per 1,000 is sent.
*----------------------------------------------------------------------*
FORM money_conversion USING
value(I_CURR)
value(i_UNIT_PRICE)
ABAP Programming Tips
Page 93 of 157
value(i_UOM)
value(i_LINE_AMOUNT)
CHANGING o_CURRENCY like ie021-currency
o_PRICE_UOM like ie021-price_uom
o_PRICE_QTY like ie021-price_qty
o_UNIT_PRICE like ie021-unit_price
o_LINE_AMOUNT like ie021-line_amount.
data:
* not all of the vendors send the currency code, so use the vendor
* master default
case i_curr(2).
when 'US'.
o_currency = 'USD'.
when 'JP'.
o_currency = 'JPY'.
when others.
o_currency = uty_vendors-waers.
endcase.
* unit price is implied 5-dec
if ( i_unit_price cn ' 0' and
i_unit_price co ' 0123456789' ).
n_unit_price = i_unit_price.
n_unit_price = n_unit_price / hun_thou.
endif.
* line price is implied 3-dec
if ( i_line_amount co ' 0123456789' and
i_line_amount cn ' 0' ).
n_line_amount = i_line_amount.
n_line_amount = n_line_amount / thou.
endif.
* 'KP' = price per thousand
if i_uom = 'KP'.
o_price_qty = '1000'.
else.
o_price_qty = '1'.
endif.
o_price_uom = 'PCE'.
if not n_unit_price is initial.
o_unit_price = n_unit_price.
shift o_unit_price left deleting leading space.
else.
clear o_unit_price.
endif.
if not n_line_amount is initial.
o_line_amount = n_line_amount.
shift o_line_amount left deleting leading space.
else.
clear o_line_amount.
endif.
ENDFORM.
" money_conversion
*&---------------------------------------------------------------------*
*&
Form SAP_vendor_partno
*&---------------------------------------------------------------------*
*
replace UTY part number sent by vendor with SAP material no.
*
from PO line item.
*----------------------------------------------------------------------*
FORM SAP_vendor_partno changing cust_partno like ie021-cust_partno.
tables: makt.
data: partno_sent like makt-maktx.
partno_sent = cust_partno.
clear: makt, cust_partno.
select single matnr from ekpo into cust_partno
where ebeln = ie021-po_number and
ebelp = ie021-po_lineno.
ABAP Programming Tips
Page 94 of 157
if sy-subrc is initial.
*compare material description to part number sent by vendor
select single maktx from makt into makt-maktx
where matnr = cust_partno.
if partno_sent <> makt-maktx.
* 'Part No. Mismatch: PO & - &, Part sent &, SAP mat.no. &'
message i031 with ie021-po_number ie021-po_lineno
partno_sent makt-maktx.
endif.
else. "PO line not found
*try to find SAP material number using 20-char catalog no. sent
select single matnr from makt into cust_partno
where maktx = partno_sent.
if not sy-subrc is initial.
* 'SAP material no. not found for & - PO & - &'
message i032 with partno_sent ie021-po_number ie021-po_lineno.
endif.
endif.
*if not found, IDoc will go to workflow for missing material no.
ENDFORM.
" SAP_vendor_partno
*&---------------------------------------------------------------------*
*&
Form idoc_header_segs
*&---------------------------------------------------------------------*
*
create internal table entries for header segments.
* DESADV:
*
E1EDK07
*
E1EDKA1
*
E1EDK03
*
E1EDK08
*
E1EDKA2
*
E1EDK06
* INVOIC:
*
E1EDK01
*
E1EDKA1(s)
*
E1EDK02
*
E1EDK03(s)
*----------------------------------------------------------------------*
FORM idoc_header_segs using value(desadv_ok).
* INVOIC
clear i_seg_num.
invoicdata-segnam = 'E1EDK01'.
e1edk01-action = ie021-stat.
if ie021-currency(2) = 'US'.
e1edk01-curcy = 'USD'.
else.
e1edk01-curcy = 'JPY'.
endif.
invoicdata-sdata = e1edk01.
append_idoc_rec invoicdata i.
clear e1edka1.
invoicdata-segnam = 'E1EDKA1'.
e1edka1-parvw = 'RE'.
e1edka1-partn = ie021-shipto_id.
invoicdata-sdata = e1edka1.
append_idoc_rec invoicdata i.
clear e1edka1.
invoicdata-segnam = 'E1EDKA1'.
e1edka1-parvw = 'LF'.
e1edka1-partn = ie021-lifnr.
e1edka1-lifnr = ie021-shipto_id.
invoicdata-sdata = e1edka1.
append_idoc_rec invoicdata i.
if not ie021-endcust_name is initial.
clear e1edka1.
invoicdata-segnam = 'E1EDKA1'.
e1edka1-parvw = 'WE'.
e1edka1-name1 = ie021-endcust_name.
invoicdata-sdata = e1edka1.
append_idoc_rec invoicdata i.
endif.
Page 95 of 157
clear e1edk02.
invoicdata-segnam = 'E1EDK02'.
e1edk02-qualf = '009'.
e1edk02-belnr = ie021-invoice_no.
invoicdata-sdata = e1edk02.
append_idoc_rec invoicdata i.
clear e1edk03.
invoicdata-segnam = 'E1EDK03'.
e1edk03-iddat = '012'.
e1edk03-datum = ie021-create_date.
invoicdata-sdata = e1edk03.
append_idoc_rec invoicdata i.
invoicdata-segnam = 'E1EDK03'.
e1edk03-iddat = '024'.
invoicdata-sdata = e1edk03.
append_idoc_rec invoicdata i.
check desadv_ok = '000'.
* DESADV
clear d_seg_num.
desadvdata-segnam = 'E1EDK07'.
e1edk07-action = ie021-stat.
e1edk07-bolnr = ie021-invoice_no.
desadvdata-sdata = e1edk07.
append_idoc_rec desadvdata d.
clear e1edka1.
desadvdata-segnam = 'E1EDKA1'.
desadvdata-sdata = e1edka1.
append_idoc_rec desadvdata d.
clear e1edk03.
desadvdata-segnam = 'E1EDK03'.
desadvdata-sdata = e1edk03.
append_idoc_rec desadvdata d.
clear e1edk08.
desadvdata-segnam = 'E1EDK08'.
e1edk08-vbeln = ie021-invoice_no.
e1edk08-traid = ie021-ship_id.
e1edk08-traty = ie021-ship_method.
desadvdata-sdata = e1edk08.
append_idoc_rec desadvdata d.
clear e1edka2.
desadvdata-segnam = 'E1EDKA2'.
desadvdata-sdata = e1edka2.
append_idoc_rec desadvdata d.
clear e1edk06.
desadvdata-segnam = 'E1EDK06'.
e1edk06-iddat = '025'. "document date
e1edk06-datum = ie021-create_date.
desadvdata-sdata = e1edk06.
append_idoc_rec desadvdata d.
if not ie021-eta is initial.
clear e1edk06.
desadvdata-segnam = 'E1EDK06'.
e1edk06-iddat = '001'. "delivery date
e1edk06-datum = ie021-eta.
desadvdata-sdata = e1edk06.
append_idoc_rec desadvdata d.
endif.
if not ie021-etd is initial.
clear e1edk06.
desadvdata-segnam = 'E1EDK06'.
e1edk06-iddat = '010'. "ship date
e1edk06-datum = ie021-etd.
desadvdata-sdata = e1edk06.
append_idoc_rec desadvdata d.
endif.
ENDFORM.
ABAP Programming Tips
" idoc_header_segs
Page 96 of 157
*&---------------------------------------------------------------------*
*&
Form idoc_poheader_segs
*&---------------------------------------------------------------------*
*
create internal table entries for DESADV PO/item segments
*
E1EDP07
*----------------------------------------------------------------------*
FORM idoc_poheader_segs.
*DESADV
clear e1edp07.
desadvdata-segnam = 'E1EDP07'.
e1edp07-bstnk = ie021-po_number.
e1edp07-posex = ie021-po_lineno.
desadvdata-sdata = e1edp07.
append_idoc_rec desadvdata d.
p07_ctr = p07_ctr + 1.
ENDFORM.
" idoc_poheader_segs
*&---------------------------------------------------------------------*
*&
Form idoc_item_segs
*&---------------------------------------------------------------------*
*
create internal table entries for PO item segments:
*
DESADV:
E1EDP09
*
INVOIC:
E1EDP01
Qtys
*
E1EDP02
ref nos. (PO number / line)
*
E1EDP19
part numbers
*
E1EDP26
amounts
*
E1EDP04
taxes
*----------------------------------------------------------------------*
FORM idoc_item_segs using value(desadv_ok).
data:
n_line_amt
type p decimals 3.
*INVOIC
clear e1edp01.
invoicdata-segnam = 'E1EDP01'.
e1edp01-menee = ie021-qty_uom.
e1edp01-menge = ie021-invoice_qty.
e1edp01-vprei = ie021-unit_price.
e1edp01-pmene = ie021-price_uom.
e1edp01-peinh = ie021-price_qty.
e1edp01-netwr = ie021-line_amount.
invoicdata-sdata = e1edp01.
append_idoc_rec invoicdata i.
clear e1edp02.
invoicdata-segnam = 'E1EDP02'.
e1edp02-qualf = '001'.
e1edp02-belnr = ie021-po_number.
e1edp02-zeile = ie021-po_lineno.
invoicdata-sdata = e1edp02.
append_idoc_rec invoicdata i.
clear e1edp19.
invoicdata-segnam = 'E1EDP19'.
e1edp19-qualf = '001'.
e1edp19-idtnr = ie021-cust_partno.
invoicdata-sdata = e1edp19.
append_idoc_rec invoicdata i.
clear e1edp19.
invoicdata-segnam = 'E1EDP19'.
e1edp19-qualf = '002'.
e1edp19-idtnr = ie021-vendor_partno.
invoicdata-sdata = e1edp19.
append_idoc_rec invoicdata i.
clear e1edp26.
invoicdata-segnam = 'E1EDP26'.
e1edp26-qualf = '003'.
e1edp26-betrg = ie021-line_amount.
invoicdata-sdata = e1edp26.
append_idoc_rec invoicdata i.
Page 97 of 157
" idoc_item_segs
***********************************************************************
*&
Form post_idocs
*&---------------------------------------------------------------------*
*
create database IDocs from the idocdata tables and clear tables.
*----------------------------------------------------------------------*
FORM post_idocs using value(desadv_ok).
*INVOIC
clear e1eds01.
invoicdata-segnam = 'E1EDS01'.
e1eds01-sumid = '010'.
e1eds01-summe = invoice_total.
e1eds01-waerq = ie021-currency.
shift e1eds01-summe left deleting leading space.
invoicdata-sdata = e1eds01.
append_idoc_rec invoicdata i.
CALL FUNCTION 'INBOUND_IDOC_PROCESS'
TABLES
IDOC_CONTROL
= iedidc
IDOC_DATA
= invoicdata.
commit work.
*DESADV
if desadv_ok = '000'.
clear e1eds02.
desadvdata-segnam = 'E1EDS02'.
e1eds02-sumid = '001'.
e1eds02-summe = p07_ctr.
shift e1eds02-summe left deleting leading space.
desadvdata-sdata = e1eds02.
append_idoc_rec desadvdata d.
CALL FUNCTION 'INBOUND_IDOC_PROCESS'
TABLES
IDOC_CONTROL
= dedidc
IDOC_DATA
= desadvdata.
commit work.
endif.
refresh: desadvdata,
invoicdata.
clear:
desadvdata,
invoicdata,
p07_ctr,
invoice_total,
save_stat,
save_po,
save_line,
ABAP Programming Tips
Page 98 of 157
save_invoice.
ENDFORM.
" post_idocs
*&---------------------------------------------------------------------*
*&
Form init_desadv
*&---------------------------------------------------------------------*
*
add a DESDAV control record and initialize fields
*----------------------------------------------------------------------*
FORM init_desadv.
clear dedidc. refresh dedidc.
* initialize control record:
move: '2'
to dedidc-direct,
'DESADV01' to dedidc-doctyp,
'DESADV'
to dedidc-mestyp,
'F'
to dedidc-std,
'E021'
to dedidc-stdmes,
'LS'
to dedidc-sndprt,
'TY_VENDORS' to dedidc-sndprn,
sy-datlo
to dedidc-credat,
sy-timlo
to dedidc-cretim.
append dedidc.
ENDFORM.
" init_desadv
*&---------------------------------------------------------------------*
*&
Form init_invoic
*&---------------------------------------------------------------------*
*
add a INVOIC control record and initialize fields
*----------------------------------------------------------------------*
FORM init_invoic.
clear iedidc. refresh iedidc.
* initialize control record:
move: '2'
to iedidc-direct,
'INVOIC01' to iedidc-doctyp,
'INVOIC'
to iedidc-mestyp,
'MM'
to iedidc-mescod,
'F'
to iedidc-std,
'E021'
to iedidc-stdmes,
'LS'
to iedidc-sndprt,
'TY_VENDORS' to iedidc-sndprn,
sy-datlo
to iedidc-credat,
sy-timlo
to iedidc-cretim.
append iedidc.
ENDFORM.
" init_invoic
7.10.7
List transactions
*----------------------------------------------------------------------*
*
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.
ABAP Programming Tips
Page 99 of 157
TYPE
TYPE
LIKE
LIKE
LIKE
TYPE
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
ABAP Programming Tips
= filestring
Page 100 of 157
write_field_separator
= ','
TABLES
data_tab
= itab_tx
EXCEPTIONS
file_write_error
= 1
no_batch
= 2
gui_refuse_filetransfer = 3
invalid_type
= 4
no_authority
= 5
unknown_error
= 6
header_not_allowed
= 7
separator_not_allowed
= 8
filesize_not_allowed
= 9
header_too_long
= 10
dp_error_create
= 11
dp_error_send
= 12
dp_error_write
= 13
unknown_dp_error
= 14
access_denied
= 15
dp_out_of_memory
= 16
disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception = 20
control_flush_error
= 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
7.10.8
S_DATE
S_cust
S_srep
S_MGRP
S_GPCT
FOR
FOR
FOR
FOR
FOR
vbrk-fkdat.
vbrk-kunag.
KNVP-kunn2.
VBRP-MATKL.
gpct.
type
type
type
type
type
type
type
type
type
type
c,
c,
c,
c,
c,
c,
c,
c,
c,
c.
" 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'.
ABAP Programming Tips
" 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.
" write_string
INITIALIZATION.
* load selection tables for invoice types
CLEAR:
r_atyp, r_vtyp.
REFRESH: r_atyp, r_vtyp.
r_atyp-SIGN
= 'I'.
r_atyp-OPTION = 'EQ'.
r_atyp-LOW = 'C'.
APPEND r_atyp.
r_atyp-LOW = 'E'.
APPEND r_atyp.
r_atyp-LOW = 'F'.
APPEND r_atyp.
r_atyp-LOW = 'H'.
APPEND r_atyp.
r_vtyp-SIGN
= 'I'.
r_vtyp-OPTION = 'EQ'.
r_vtyp-LOW = 'M'.
APPEND r_vtyp.
r_vtyp-LOW = 'N'.
APPEND r_vtyp.
r_vtyp-LOW = 'O'.
APPEND r_vtyp.
r_vtyp-LOW = 'S'.
APPEND r_vtyp.
"order
"sched. agree.
"sched. agree. w/ext.agent
"returns
"invoice
"invoice cancellation
"credit memo
"credit memo cancellation
AT SELECTION-SCREEN.
ABAP Programming Tips
date
date
cust
cust
srep
srep
mgrp
mgrp
gpct
gpct
I
E
I
E
I
E
I
E
I
E
E.
I.
E.
I.
E.
I.
E.
I.
E.
I.
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.
ABAP Programming Tips
************************************************************************
*
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.
write:
/79 '============',
92 '===============',
108 '============',
121 '===============',
137 '============',
150 '===============',
168 '======'.
/01 'Total for Material Group',
26 save_matkl,
79(12) FKIMG_SUM_GRP decimals 0,
92(15) KZWI2_SUM_GRP,
108(12) UPRICE,
121(15) WAVWR_SUM_GRP,
137(12) UCOST,
150(15) gross_profit,
166(8) gp_percent,
175
'%'.
uline.
clear: FKIMG_SUM_GRP,
KZWI2_SUM_GRP,
WAVWR_SUM_GRP.
ENDFORM.
" material_group_footer
*&---------------------------------------------------------------------*
*&
Form invoice_footer
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM material_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_mat - wavwr_sum_mat.
gp_percent = ( gross_profit / kzwi2_sum_mat ) * hun.
* calculate unit price
uprice = kzwi2_sum_mat / fkimg_sum_mat.
* calculate unit cost
ucost = wavwr_sum_mat / fkimg_sum_mat.
write:
/79
92
108
121
137
150
'------------',
'---------------',
'------------',
'---------------',
'------------',
'---------------',
168 '------'.
/01 'Subtotal for material',
23 save_matnr,
79(12) FKIMG_SUM_MAT decimals 0,
92(15) KZWI2_SUM_MAT,
108(12) UPRICE,
121(15) WAVWR_SUM_MAT,
137(12) UCOST,
150(15) gross_profit,
166(8) gp_percent,
175
'%'.
write:
clear: FKIMG_SUM_MAT,
KZWI2_SUM_MAT,
WAVWR_SUM_MAT.
ENDFORM.
7.10.9
" material_footer
REPORT ZEPS_PROGRESS_POP .
***********************************************************
* Developer
: S.Srini.
* Location
: Chennai,
*
: Tamil Nadu,
*
: India.
* Date
: 03/09/2001.
***********************************************************
data: val type i.
data event(6) type c.
val = 0.
do 4 times.
val
= val + 25.
*______________________________________________________________________
*/ Program Name: Process invoice IDocs with Goods Receipt
*/ Description : This program checks all INVOIC MM IDocs in status 64
*
and 66 to determine if they have been received. Those
*
IDocs older than 10 days that have still not been
*
goods receipted are given error status 51.
*/ Transaction : N/A - run via scheduled job
*______________________________________________________________________
tables: edidc,
mkpf,
ekpo,
rbkp,
e1edk01,
e1edka1,
e1edk02,
e1edp02.
data: iedidc
like edidc occurs 1 with header line,
data_rec like edidd occurs 1 with header line.
data: c_docnum(16) type c,
c_mblnr(10) type c,
c_invoic(10) type c,
rc(1)
type c,
lead_time
like lfm1-plifz,
gr_qty
like mseg-erfmg,
test_date
like sy-datum,
gr_required like ekpo-webre,
po_number(10)
type n,
po_lineno
like ekpo-ebelp,
n_vend(10)
type n,
vendor_id
like lfa1-lifnr.
data: begin of itab_gr occurs 0,
mblnr like mkpf-mblnr,
bwart like mseg-bwart,
erfmg like mseg-erfmg,
end of itab_gr.
constants:
* name of container element (workitem object id)
C_ELEMENT_WI_OBJ_ID
LIKE SWCONT-ELEMENT VALUE '_WI_OBJECT_ID',
* name of container element (NumberPlusEventcode)
C_ELEMENT_NO_PLUS_INFO
LIKE SWCONT-ELEMENT
VALUE 'NumberPlusEventcode'.
ranges: r_status for edidc-status.
TYPE-POOLS:
* general idoc type pool
TIDOC.
************************************************************************
* INCLUDES
*
************************************************************************
* include for workflow programming
INCLUDE <CNTN01>.
************************************************************************
* INNITIALIZATION
*
************************************************************************
initialization.
* create IDoc status selection table.
clear r_status. refresh r_status.
MOVE: 'EQ'
TO
'I'
TO
'64'
TO
APPEND r_status.
MOVE: '66'
TO
APPEND r_status.
r_status-OPTION,
r_status-SIGN,
r_status-LOW.
"equals
"include
r_status-LOW.
************************************************************************
* START-OF-SELECTION
************************************************************************
ABAP Programming Tips
start-of-selection.
select * from edidc into table iedidc
where status in r_status and
direct = '2' and
"inbound
mestyp = 'INVOIC' and
mescod = 'MM'.
loop at iedidc.
clear rc.
CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_READ'
EXPORTING
DOCUMENT_NUMBER
= iedidc-docnum
IMPORTING
IDOC_CONTROL
= IEDIDC
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK
= 01
DOCUMENT_NOT_EXIST
= 02
DOCUMENT_NUMBER_INVALID = 03
ERROR_MESSAGE
= 04
OTHERS
= 05.
IF NOT SY-SUBRC IS INITIAL.
c_docnum = iedidc-docnum.
shift c_docnum left deleting leading '0'.
* 'Cannot open INVOIC IDoc & for Goods Receipt processing'
message w025 with c_docnum.
continue.
ENDIF.
call function 'EDI_SEGMENTS_GET_ALL'
exporting
document_number
= iedidc-docnum
tables
idoc_containers
= data_rec
exceptions
document_number_invalid = 1
end_of_document
= 2
others
= 3.
if not sy-subrc is initial.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER
= iedidc-docnum
IMPORTING
IDOC_CONTROL
= iedidc
*
*
*
*
c_docnum = iedidc-docnum.
shift c_docnum left deleting leading '0'.
'Cannot retrieve data for INVOIC IDoc & (Goods Receipt processing)'
message w030 with c_docnum.
continue.
else.
CALL FUNCTION 'EDI_DOCUMENT_CLOSE_READ'
EXPORTING
DOCUMENT_NUMBER
= iedidc-docnum
IMPORTING
IDOC_CONTROL
= iedidc.
If this is a change or modify IDoc, change status to 51 (error).
One & only one K01 segment should exist read table data_rec with key segnam = 'E1EDK01'.
if sy-subrc is initial.
move data_rec-sdata to e1edk01.
case e1edk01-action.
when '000'. "original data
OK - do nothing
when '002'. "modified data
'Invoice & - IDoc for Review Only'
perform idoc_status_update using '51' '028'
'Modification' ' '.
when '002'. "modified data
'Invoice & - IDoc for Review Only'
perform idoc_status_update using '51' '028'
'Cancellation' ' '.
endcase.
endif.
check rc is initial.
* get the vendor no.
clear vendor_id.
loop at data_rec where segnam = 'E1EDKA1'.
move data_rec-sdata to e1edka1.
check: e1edka1-parvw = 'LF',
e1edka1-partn co ' 0123456789',
e1edka1-partn <> ' '.
n_vend = e1edka1-partn.
vendor_id = n_vend.
endloop.
* if this is a new IDoc, check to make sure it even needs the GR test
clear gr_required.
loop at data_rec where segnam = 'E1EDP02'.
move data_rec-sdata to e1edp02.
check: e1edp02-qualf = '001',
e1edp02-belnr <> ' ',
e1edp02-zeile <> ' '.
* Note that a missing PO number / line number is NOT an error here * the IDoc will error in the standard SAP processing in RBDAPP01
shift e1edp02-belnr left deleting leading '0'.
clear: po_number, po_lineno.
if e1edp02-belnr co ' 0123456789'.
po_number = e1edp02-belnr.
endif.
if e1edp02-zeile co ' 0123456789'.
po_lineno = e1edp02-zeile.
endif.
select single webre from ekpo into gr_required
where ebeln = po_number
and ebelp = po_lineno.
if ( sy-subrc is initial and gr_required = 'X' ).
exit.
endif.
endloop. "E1EDP02 segments
* if any line item on this invoice requires a goods receipt, continue
* receipt evaluation. Otherwise, status the IDoc to go to standard SAP
* processing. (Assumption is made that if an IDoc has status 66, the GR
* flag was turned "on" at some point and has since been removed.)
if gr_required is initial. "no goods receipt required
if iedidc-status = '66'.
* 'Goods Receipt no longer required'
perform idoc_status_update using '64' '026' ' ' ' '.
endif.
continue. "next IDoc
endif.
* Should be only one K02, but loop just in case...
loop at data_rec where segnam = 'E1EDK02'.
move data_rec-sdata to e1edk02.
if e1edk02-qualf = '009'.
* if an invoice already exists for this ref. no., give the IDoc
* an error status
select single belnr from rbkp into rbkp-belnr
where xblnr = e1edk02-belnr(16)
and blart = 'KR' "invoice
and stblg = ' '. "no reversal
if sy-subrc is initial.
*'Invoice & already exists for ref.no. &'
c_invoic = rbkp-belnr.
shift c_invoic left deleting leading '0'.
perform idoc_status_update using '51' '027'
c_invoic e1edk02-belnr(16).
exit. "exit loop on data recs for this IDoc
endif.
clear: itab_gr, gr_qty.
refresh: itab_gr.
select a~mblnr
b~bwart b~erfmg
into corresponding fields of table itab_gr
from mkpf as a
inner join mseg as b
on a~mblnr = b~mblnr
where a~vgart = 'WE' "goods receipt for PO
and a~blart = 'WE' "goods receipt
and a~xblnr = e1edk02-belnr(16).
loop at itab_gr.
ABAP Programming Tips
case itab_gr-bwart.
when '101'. "receipt
gr_qty = gr_qty + itab_gr-erfmg.
when '102'. "reversal
gr_qty = gr_qty - itab_gr-erfmg.
endcase.
endloop.
* if no goods receipt
if gr_qty <= 0.
case iedidc-status.
* if new IDoc, status to '66'
when '64'.
* 'Waiting for Goods Receipt'
perform idoc_status_update using '66' '022' ' ' ' '.
* if reprocessed IDoc, check length of delay and status to 51
* (late receipt) if > 10 days.
when '66'.
clear lead_time.
select single plifz from lfm1 into lead_time
where lifnr = vendor_id
and ekorg = '7100'.
if lead_time is initial.
lead_time = 10.
endif.
test_date = iedidc-credat + lead_time.
**TEST
**
if test_date > sy-datum.
**TEST
if test_date <= sy-datum.
* 'Goods Receipt Overdue'
perform idoc_status_update using '51' '024' ' ' ' '.
else.
* do nothing - IDoc stays in status 66 and gets tested for GR in next
* job run
endif.
endcase.
else. "goods receipt exists
* if this is a reprocess of an IDoc for which a goods receipt now
* exists, give the IDoc status 64, so it is processed by RBDAPP01
* in the next job step.
if iedidc-status = '66'.
c_mblnr = mkpf-mblnr.
shift c_mblnr left deleting leading '0'.
* 'Goods Receipt found for ref.no. &'
perform idoc_status_update
using '64' '023' e1edk02-belnr(16) ' '.
endif.
endif.
else. "wrong K02 qualifier
* do nothing - IDoc will try to post and be handled manually
endif. "QUALF='009'
endloop. "data_rec
endif. "successful retrieval of IDoc data segments > data_rec
endloop.
"iedidc
end-of-selection.
*----------------------------------------------------------------------* FORM IDOC_STATUS_UPDATE
* Creates status records for the selected IDocs.
*----------------------------------------------------------------------FORM IDOC_STATUS_UPDATE using value(i_stat)
value(i_msgno)
value(i_msgv1)
value(i_msgv2).
tables: edi_ds, tede2.
DATA: MESS like EDIMESSAGE.
data:
l_commit_counter
inbsync
t_couple_to_process
EXPORTING
DOCUMENT_NUMBER
IMPORTING
IDOC_CONTROL
EXCEPTIONS
DOCUMENT_FOREIGN_LOCK
DOCUMENT_NOT_EXIST
DOCUMENT_NUMBER_INVALID
ERROR_MESSAGE
OTHERS
= iedidc-docnum
= IEDIDC
=
=
=
=
=
01
02
03
04
05.
=
=
=
=
=
=
=
=
=
=
iedidc-DOCNUM.
i_stat.
'ZS7BM000007'.
'EDI_DS'.
SY-MANDT.
'SAP'.
'ZS7'.
i_msgno.
i_msgv1.
i_msgv2.
= SY-DATUM.
= SY-UZEIT.
MESS-MSGID = 'ZS7'.
MESS-MSGTY = 'E'.
MESS-MSGNO = i_msgno.
MESS-MSGV1 = i_msgv1.
MESS-MSGV2 = i_msgv2.
CALL FUNCTION 'IDOC_ERROR_WORKFLOW_START'
EXPORTING
DOCNUM
= 0
EVENTCODE
= 'EDIM'
MESS
= mess
STATUSMESS
= mess
EXCEPTIONS
NO_ENTRY_IN_TEDE5
= 1
ERROR_IN_START_WORKFLOW
= 2
OTHERS
= 3.
COMMIT WORK.
endif. "link created
endif. "tede2 found
endif.
* Set return code to stop further processing of this IDoc
rc = 'X'.
ENDFORM.
LOOP AT t_couple_to_process_in.
* cast
l_idoc_number = t_couple_to_process_in(16).
CALL FUNCTION 'EDI_DOCUMENT_DEQUEUE_LATER'
EXPORTING
docnum = l_idoc_number
EXCEPTIONS
OTHERS = 0.
ENDLOOP.
* get first idoc number in table in order to create an object
READ TABLE t_couple_to_process_in INDEX 1.
* set object key in variable of correct type (casting)
l_object_key = t_couple_to_process_in(16).
* create an object, i.e. an IDoc
swc_create_object l_object c_object_type l_object_key.
* fill container: work item object id (idoc)
swc_set_element l_t_ev_container
"EC *
c_element_wi_obj_id "EC *
l_object.
"EC *
* fill container: NumberPlusEventcode (table of couples)
swc_set_table l_t_ev_container
c_element_no_plus_info
t_couple_to_process_in.
* fire event that will trigger the
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype
=
objkey
=
event
=
*
CREATOR
=
*
START_WITH_DELAY
=
start_recfb_synchron =
IMPORTING
event_id
=
TABLES
event_container
=
EXCEPTIONS
objtype_not_found
=
OTHERS
=
c_object_type
l_object_key
c_idc_evt
' '
' '
l_start_recfb_synchron
l_event_id
l_t_ev_container
1
2.
IF
( sy-subrc <> 0 )
* event was not created => error handling for this idoc (EDIM)
OR ( l_event_id = 0 ).
* stop processing, no commit
MESSAGE ID
'E0'
TYPE
'A'
NUMBER '374'
WITH
l_status_record-docnum
c_idc_evt
RAISING event_create_failed.
ELSE.
* do commit and reset counter
* the commit will get the idocs to the database and at the same time
* activate the event that was created
COMMIT WORK.
* dequeue all unprocessed IDocs to avoid log-overflow
CALL FUNCTION 'DEQUEUE_ALL'.
CLEAR commit_counter_in.
* reset table of idocs that need to be processed
CLEAR
t_couple_to_process_in.
REFRESH t_couple_to_process_in.
ENDIF.
ENDFORM.
" ANALYZING_EVENT_CREATE
19990719
12531H
001EX
* Function
: Up/Download ABAP reports complete with texts
*
*----------------------------------------------------------------------*
* Change Log :
*
* July 5, 1999
*
*
- Combined existing programs that did the upload and download into*
*
- one program.
*
*
- Changed format that the reports are saved in to be compatible
*
*
with Wolfgang Morgenthaler's upload/download program(YSTRASN00 *
*
at www.antarcon.de). Major differences between this program and*
*
Wolfgang's are:
*
- this program does not update TRDIR with the
*
*
TRDIR entries that are in the program uploaded. Instead, *
*
current users stats are used.
*
*
- this program allows selection of reports from a list or
*
*
a single report can be tuped in and uploaded
*
*
- this program also updates TADIR so that a development class*
*
is assigned to the program
*
*
- this program checks to see if the program already has a
*
*
TRDIR entry, and if it does, warns the user
*
*
- this program will save/restore the program documenation too*
*
*
*
*
*
*
*----------------------------------------------------------------------*
REPORT ZKBPROGS
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*----------------------------------------------------------------------*
* Declare Database Objects
*
*----------------------------------------------------------------------*
tables:
DOKIL,
TRDIR.
*----------------------------------------------------------------------*
* Constants
*
CONSTANTS:
MC_TRDIR_IDENTIFIER(72) TYPE C VALUE '%&%& RDIR',
MC_REPORT_IDENTIFIER(72) TYPE C VALUE '%&%& REPO',
MC_TEXT_IDENTIFIER(72)
TYPE C VALUE '%&%& TEXP',
MC_THEAD_IDENTIFIER(72) TYPE C VALUE '%&%& HEAD',
MC_DOC_IDENTIFIER(72)
TYPE C VALUE '%&%& DOKL',
MC_TRDIR_SHORT(4)
TYPE C VALUE 'RDIR',
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'.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Declare Module level data structures
*
*----------------------------------------------------------------------*
DATA: BEGIN OF MTAB_PROGRAM_SOURCE OCCURS 0,
LINE(72) TYPE C,
END OF MTAB_PROGRAM_SOURCE.
DATA: MTAB_PROGRAM_TRDIR LIKE TRDIR OCCURS 0 WITH HEADER LINE.
DATA: MTAB_PROGRAM_TEXTS LIKE TEXTPOOL OCCURS 0 WITH HEADER LINE.
DATA: MSTR_THEAD LIKE THEAD.
DATA: BEGIN OF MTAB_PROGRAM_FILE OCCURS 0,
LINE(275) TYPE C,
END OF MTAB_PROGRAM_FILE.
DATA: BEGIN OF MTAB_DIRECTORY OCCURS 0,
NAME LIKE TRDIR-NAME,
DESC(72) TYPE C,
SAVENAME LIKE RLGRAP-FILENAME,
END OF MTAB_DIRECTORY.
DATA: BEGIN OF MTAB_PROGRAM_DOCUMENTATION OCCURS 0,
LINE(255) TYPE C,
END OF MTAB_PROGRAM_DOCUMENTATION.
*----------------------------------------------------------------------*
* Selection Screen
*
*----------------------------------------------------------------------*
*-- Options for upload/download of programs
SELECTION-SCREEN BEGIN OF BLOCK FRM_OPTIONS WITH FRAME TITLE TEXT-UDL.
PARAMETERS:
RB_DOWN RADIOBUTTON GROUP UDL DEFAULT 'X'.
" Download reports
SELECTION-SCREEN BEGIN OF BLOCK FRM_TRDIR WITH FRAME TITLE TEXT-DIR.
SELECT-OPTIONS:
S_NAME FOR TRDIR-NAME,
" Program Name
ABAP Programming Tips
S_SUBC
FOR TRDIR-SUBC
" Program Type
DEFAULT 'F' OPTION EQ SIGN E," Exclude Functions by default
S_CNAM FOR TRDIR-CNAM
" Created by
DEFAULT SY-UNAME,
S_UNAM FOR TRDIR-UNAM,
" Last Changed by
S_CDAT FOR TRDIR-CDAT,
" Creation date
S_UDAT FOR TRDIR-UDAT.
" Last update date
SELECTION-SCREEN END OF BLOCK FRM_TRDIR.
*-- Options for uploading programs
PARAMETERS:
RB_UP
RADIOBUTTON GROUP UDL.
" Upload reports
SELECTION-SCREEN BEGIN OF BLOCK FRM_UPLOAD WITH FRAME TITLE TEXT-UPL.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(29) TEXT-SNG.
PARAMETERS:
RB_FILE RADIOBUTTON GROUP HOW DEFAULT 'X'.
SELECTION-SCREEN COMMENT 33(42) TEXT-FNA.
SELECTION-SCREEN END OF LINE.
PARAMETERS:
RB_LIST RADIOBUTTON GROUP HOW.
SELECTION-SCREEN END OF BLOCK FRM_UPLOAD.
SELECTION-SCREEN END OF BLOCK FRM_OPTIONS.
*-- Options for up/downloading programs
SELECTION-SCREEN BEGIN OF BLOCK FRM_FILEN WITH FRAME TITLE TEXT-FIL.
PARAMETERS:
RB_DOS RADIOBUTTON GROUP FIL DEFAULT 'X', " Save to local
RB_UNIX RADIOBUTTON GROUP FIL,
" Save to UNIX
P_PATH LIKE RLGRAP-FILENAME
" Path to save files to
DEFAULT 'c:\temp\'.
SELECTION-SCREEN END OF BLOCK FRM_FILEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-LOW.
CALL FUNCTION 'F4_PROGRAM'
EXPORTING
OBJECT
= S_NAME-LOW
SUPPRESS_SELECTION = 'X'
IMPORTING
RESULT
= S_NAME-LOW
EXCEPTIONS
OTHERS
= 1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-HIGH.
CALL FUNCTION 'F4_PROGRAM'
EXPORTING
OBJECT
= S_NAME-HIGH
SUPPRESS_SELECTION = 'X'
IMPORTING
RESULT
= S_NAME-HIGH
EXCEPTIONS
OTHERS
= 1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-LOW.
PERFORM GET_NAME USING 'S_UNAM-LOW'
CHANGING S_UNAM-LOW.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-HIGH.
PERFORM GET_NAME USING 'S_UNAM-HIGH'
CHANGING S_UNAM-HIGH.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-LOW.
PERFORM GET_NAME USING 'S_CNAM-LOW'
CHANGING S_CNAM-LOW.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-HIGH.
PERFORM GET_NAME USING 'S_CNAM-HIGH'
CHANGING S_CNAM-HIGH.
TOP-OF-PAGE.
IF RB_LIST = 'X'.
FORMAT COLOR COL_HEADING.
NEW-LINE.
WRITE: AT 3 TEXT-H01,
AT 15 TEXT-H03.
FORMAT COLOR OFF.
ENDIF.
AT LINE-SELECTION.
CHECK RB_LIST = 'X'.
" only do in list mode
READ LINE SY-CUROW FIELD VALUE MTAB_DIRECTORY-SAVENAME.
*-- Read file into an internal table
PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE
USING MTAB_DIRECTORY-SAVENAME.
*-- Split table into TADIR entry, report lines, and report text
PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE
MTAB_PROGRAM_SOURCE
ABAP Programming Tips
MTAB_PROGRAM_TEXTS
MTAB_PROGRAM_DOCUMENTATION
CHANGING TRDIR
MSTR_THEAD.
*-- Save all of the data
PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE
MTAB_PROGRAM_TEXTS
MTAB_PROGRAM_DOCUMENTATION
USING TRDIR
MSTR_THEAD.
*----------------------------------------------------------------------*
* Start of processing
*
*----------------------------------------------------------------------*
START-OF-SELECTION.
FORMAT COLOR COL_NORMAL.
IF RB_DOWN = 'X'.
PERFORM DOWNLOAD_REPORTS.
ELSEIF RB_UP = 'X'.
PERFORM UPLOAD_REPORTS.
ENDIF.
END-OF-SELECTION.
IF RB_DOWN = 'X'.
CONCATENATE P_PATH
'directory.txt'
INTO P_PATH.
PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_DIRECTORY
USING P_PATH.
ENDIF.
*---------------------------------------------------------------------*
*
FORM UPLOAD_REPORTS
*
*---------------------------------------------------------------------*
FORM UPLOAD_REPORTS.
*-- Can upload a reports entered in selection criteria or
*-- select from a list. List can be from index.txt in same directory
*-- (created by the download) or by reading the first line of each file
*-- in the directory.
IF RB_FILE = 'X'. " Upload single program from a file
*-- Read file into an internal table
PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE
USING P_PATH.
*-- Split table into TADIR entry, report lines, and report text
PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE
MTAB_PROGRAM_SOURCE
MTAB_PROGRAM_TEXTS
MTAB_PROGRAM_DOCUMENTATION
CHANGING TRDIR
MSTR_THEAD.
*-- Save all of the data
PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE
MTAB_PROGRAM_TEXTS
MTAB_PROGRAM_DOCUMENTATION
USING TRDIR
MSTR_THEAD.
ELSEIF RB_LIST = 'X'. " Show list for user to choose from
*-- get list of report names/descriptions from directory text
CONCATENATE P_PATH
'directory.txt'
INTO P_PATH.
PERFORM READ_REPORT_FROM_DISK TABLES MTAB_DIRECTORY
USING P_PATH.
SORT MTAB_DIRECTORY.
*-- Write out list of report names/descriptions
LOOP AT MTAB_DIRECTORY.
WRITE:
/ MTAB_DIRECTORY-NAME UNDER TEXT-H01,
MTAB_DIRECTORY-DESC UNDER TEXT-H03,
MTAB_DIRECTORY-SAVENAME.
ENDLOOP.
*-- Process user selections for reports to upload.
ENDIF.
ENDFORM.
" upload_reports
*---------------------------------------------------------------------*
*
FORM DOWNLOAD_REPORTS
*
*---------------------------------------------------------------------*
*
From the user selections, get all programs that meet the
*
*
criteria, and save them in ftab_program_directory.
*
*
Also save the report to disk.
*
ABAP Programming Tips
*---------------------------------------------------------------------*
FORM DOWNLOAD_REPORTS.
DATA:
LC_FULL_FILENAME LIKE RLGRAP-FILENAME.
*-- The table is put into an internal table because the program will
*-- abend if multiple transfers to a dataset occur within a SELECT/
*-- ENDSELCT (tested on 3.1H)
SELECT * FROM TRDIR
INTO TABLE MTAB_PROGRAM_TRDIR
WHERE NAME IN S_NAME
AND
SUBC IN S_SUBC
AND
CNAM IN S_CNAM
AND
UNAM IN S_UNAM
AND
CDAT IN S_CDAT
AND
UDAT IN S_UDAT.
LOOP AT MTAB_PROGRAM_TRDIR.
*-- Clear out text and source code tables
CLEAR:
MTAB_PROGRAM_FILE,
MTAB_PROGRAM_SOURCE,
MTAB_PROGRAM_TEXTS,
MTAB_PROGRAM_DOCUMENTATION.
REFRESH:
MTAB_PROGRAM_FILE,
MTAB_PROGRAM_SOURCE,
MTAB_PROGRAM_TEXTS,
MTAB_PROGRAM_DOCUMENTATION.
*-- Get the report
READ REPORT MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_SOURCE.
*-- Get the text for the report
READ TEXTPOOL MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_TEXTS.
*-- Get the documentation for the report
CLEAR DOKIL.
SELECT * UP TO 1 ROWS FROM DOKIL
WHERE ID
= 'RE'
AND
OBJECT
= MTAB_PROGRAM_TRDIR-NAME
AND
LANGU
= SY-LANGU
AND
TYP
= 'E'
ORDER BY VERSION DESCENDING.
ENDSELECT.
*-- Documentation exists for this object
IF SY-SUBRC = 0.
CALL FUNCTION 'DOCU_READ'
EXPORTING
ID
= DOKIL-ID
LANGU
= DOKIL-LANGU
OBJECT = DOKIL-OBJECT
TYP
= DOKIL-TYP
VERSION = DOKIL-VERSION
IMPORTING
HEAD
= MSTR_THEAD
TABLES
LINE
= MTAB_PROGRAM_DOCUMENTATION
EXCEPTIONS
OTHERS = 1.
ENDIF.
*-- Put the report code and texts into a single file
*-- Put the identifier line in so that the start of the TRDIR line
*-- is marked
CONCATENATE MC_TRDIR_IDENTIFIER
MTAB_PROGRAM_TRDIR-NAME
INTO MTAB_PROGRAM_FILE-LINE.
APPEND MTAB_PROGRAM_FILE.
*-- Add the TRDIR line
MTAB_PROGRAM_FILE-LINE = MTAB_PROGRAM_TRDIR.
APPEND MTAB_PROGRAM_FILE.
*-- Put the identifier line in so that the start of the report code
*-- is marked
CONCATENATE MC_REPORT_IDENTIFIER
MTAB_PROGRAM_TRDIR-NAME
INTO MTAB_PROGRAM_FILE-LINE.
APPEND MTAB_PROGRAM_FILE.
*-- Add the report code
LOOP AT MTAB_PROGRAM_SOURCE.
MTAB_PROGRAM_FILE = MTAB_PROGRAM_SOURCE.
APPEND MTAB_PROGRAM_FILE.
ENDLOOP.
ABAP Programming Tips
*-- Put the identifier line in so that the start of the report text
*-- is marked
CONCATENATE MC_TEXT_IDENTIFIER
MTAB_PROGRAM_TRDIR-NAME
INTO MTAB_PROGRAM_FILE-LINE.
APPEND MTAB_PROGRAM_FILE.
*-- Add the report texts
LOOP AT MTAB_PROGRAM_TEXTS.
MTAB_PROGRAM_FILE = MTAB_PROGRAM_TEXTS.
APPEND MTAB_PROGRAM_FILE.
ENDLOOP.
*-- Put the identifier line in so that the start of the THEAD record
*-- is marked
CONCATENATE MC_THEAD_IDENTIFIER
MTAB_PROGRAM_TRDIR-NAME
INTO MTAB_PROGRAM_FILE-LINE.
APPEND MTAB_PROGRAM_FILE.
MTAB_PROGRAM_FILE = MSTR_THEAD.
APPEND MTAB_PROGRAM_FILE.
*-- Put the identifier line in so that the start of the report
*-- documentation is marked
CONCATENATE MC_DOC_IDENTIFIER
MTAB_PROGRAM_TRDIR-NAME
INTO MTAB_PROGRAM_FILE-LINE.
APPEND MTAB_PROGRAM_FILE.
*-- Add the report documentation
LOOP AT MTAB_PROGRAM_DOCUMENTATION.
MTAB_PROGRAM_FILE = MTAB_PROGRAM_DOCUMENTATION.
APPEND MTAB_PROGRAM_FILE.
ENDLOOP.
*-- Make the fully pathed filename that report will be saved to
CONCATENATE P_PATH
MTAB_PROGRAM_TRDIR-NAME
'.txt'
INTO LC_FULL_FILENAME.
PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_PROGRAM_FILE
USING LC_FULL_FILENAME.
*-- Write out message with Program Name/Description
READ TABLE MTAB_PROGRAM_TEXTS WITH KEY ID = 'R'.
IF SY-SUBRC = 0.
MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.
MTAB_DIRECTORY-DESC = MTAB_PROGRAM_TEXTS-ENTRY.
MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.
APPEND MTAB_DIRECTORY.
WRITE: / MTAB_PROGRAM_TRDIR-NAME,
MTAB_PROGRAM_TEXTS-ENTRY(65) COLOR COL_HEADING.
ELSE.
MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.
MTAB_DIRECTORY-DESC = 'No description available'.
MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.
APPEND MTAB_DIRECTORY.
WRITE: / MTAB_PROGRAM_TRDIR-NAME.
ENDIF.
ENDLOOP.
ENDFORM.
" BUILD_PROGRAM_DIRECTORY
*---------------------------------------------------------------------*
*
FORM SAVE_TABLE_TO_FILE
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> FTAB_TABLE
*
* --> F_FILENAME
*
*---------------------------------------------------------------------*
FORM SAVE_TABLE_TO_FILE TABLES FTAB_TABLE
USING F_FILENAME.
IF RB_DOS = 'X'.
" Save file to presentation server
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = F_FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = FTAB_TABLE
EXCEPTIONS
OTHERS
= 4.
IF SY-SUBRC NE 0.
WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,
F_FILENAME COLOR COL_NEGATIVE.
ABAP Programming Tips
ENDIF.
ELSE.
" Save file to application server
OPEN DATASET F_FILENAME FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT FTAB_TABLE.
TRANSFER FTAB_TABLE TO F_FILENAME.
IF SY-SUBRC NE 0.
WRITE: / 'Error writing record to file;' COLOR COL_NEGATIVE,
F_FILENAME COLOR COL_NEGATIVE.
ENDIF.
ENDLOOP.
ELSE.
WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,
F_FILENAME COLOR COL_NEGATIVE.
ENDIF.
ENDIF.
" End RB_DOS
ENDFORM.
" SAVE_PROGRAM
*---------------------------------------------------------------------*
*
FORM READ_REPORT_FROM_DISK
*
*---------------------------------------------------------------------*
*
Read report into internal table. Can read from local or
*
*
remote computer
*
*---------------------------------------------------------------------*
FORM READ_REPORT_FROM_DISK TABLES FTAB_TABLE
USING F_FILENAME.
DATA:
LC_MESSAGE(128) TYPE C.
CLEAR
FTAB_TABLE.
REFRESH FTAB_TABLE.
IF RB_DOS = 'X'.
TRANSLATE F_FILENAME USING '/\'.
" correct slash for Dos PC file
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME
= F_FILENAME
FILETYPE
= 'ASC'
TABLES
DATA_TAB
= FTAB_TABLE
EXCEPTIONS
CONVERSION_ERROR
= 1
FILE_OPEN_ERROR
= 2
FILE_READ_ERROR
= 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE
= 5
NO_BATCH
= 6
UNKNOWN_ERROR
= 7
OTHERS
= 8.
IF SY-SUBRC >< 0.
WRITE: / 'Error reading file from local PC' COLOR COL_NEGATIVE.
ENDIF.
ELSEIF RB_UNIX = 'X'.
TRANSLATE F_FILENAME USING '\/'.
" correct slash for unix
OPEN DATASET F_FILENAME FOR INPUT MESSAGE LC_MESSAGE IN TEXT MODE.
IF SY-SUBRC = 0.
DO.
READ DATASET F_FILENAME INTO FTAB_TABLE.
IF SY-SUBRC = 0.
APPEND FTAB_TABLE.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET F_FILENAME.
ELSE.
WRITE: / 'Error reading file from remote computer'
COLOR COL_NEGATIVE,
/ LC_MESSAGE,
/ F_FILENAME.
SY-SUBRC = 4.
ENDIF.
ENDIF.
ENDFORM.
" READ_REPORT_FROM_DISK
*---------------------------------------------------------------------*
*
FORM SPLIT_INCOMING_FILE
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
ABAP Programming Tips
* --> FTAB_PROGRAM_FILE
*
* --> FTAB_PROGRAM_SOURCE
*
* --> `
*
* --> FTAB_PROGRAM_TEXTS
*
*---------------------------------------------------------------------*
FORM SPLIT_INCOMING_FILE TABLES FTAB_PROGRAM_FILE
STRUCTURE MTAB_PROGRAM_FILE
FTAB_PROGRAM_SOURCE
STRUCTURE MTAB_PROGRAM_SOURCE
FTAB_PROGRAM_TEXTS
STRUCTURE MTAB_PROGRAM_TEXTS
FTAB_PROGRAM_DOCUMENTATION
STRUCTURE MTAB_PROGRAM_DOCUMENTATION
CHANGING FSTR_TRDIR
FSTR_THEAD.
DATA:
LC_DATATYPE(4) TYPE C,
" Type of data, REPO, TEXP, RDIR
LC_PROGRAM_FILE LIKE MTAB_PROGRAM_FILE.
LOOP AT FTAB_PROGRAM_FILE.
LC_PROGRAM_FILE = FTAB_PROGRAM_FILE.
CASE LC_PROGRAM_FILE(9).
WHEN MC_TRDIR_IDENTIFIER.
LC_DATATYPE = MC_TRDIR_SHORT.
WHEN MC_REPORT_IDENTIFIER.
LC_DATATYPE = MC_REPORT_SHORT.
WHEN MC_TEXT_IDENTIFIER.
LC_DATATYPE = MC_TEXT_SHORT.
WHEN MC_DOC_IDENTIFIER.
LC_DATATYPE = MC_DOC_SHORT.
WHEN MC_THEAD_IDENTIFIER.
LC_DATATYPE = MC_THEAD_SHORT.
WHEN OTHERS. " Actual contents of report, trdir, or text
CASE LC_DATATYPE.
WHEN MC_TRDIR_SHORT.
FSTR_TRDIR = FTAB_PROGRAM_FILE.
WHEN MC_REPORT_SHORT.
FTAB_PROGRAM_SOURCE = FTAB_PROGRAM_FILE.
APPEND FTAB_PROGRAM_SOURCE.
WHEN MC_TEXT_SHORT.
FTAB_PROGRAM_TEXTS = FTAB_PROGRAM_FILE.
APPEND FTAB_PROGRAM_TEXTS.
WHEN MC_THEAD_SHORT.
FSTR_THEAD = FTAB_PROGRAM_FILE.
WHEN MC_DOC_SHORT.
FTAB_PROGRAM_DOCUMENTATION = FTAB_PROGRAM_FILE.
APPEND FTAB_PROGRAM_DOCUMENTATION.
ENDCASE.
ENDCASE.
ENDLOOP.
ENDFORM.
" SPLIT_INCOMING_FILE
*---------------------------------------------------------------------*
*
FORM INSERT_NEW_REPORT
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> FTAB_PROGRAM_SOURCE
*
* --> FTAB_PROGRAM_TEXTS
*
* --> F_TRDIR
*
*---------------------------------------------------------------------*
FORM INSERT_NEW_REPORT TABLES FTAB_PROGRAM_SOURCE
STRUCTURE MTAB_PROGRAM_SOURCE
FTAB_PROGRAM_TEXTS
STRUCTURE MTAB_PROGRAM_TEXTS
FTAB_PROGRAM_DOCUMENTATION
STRUCTURE MTAB_PROGRAM_DOCUMENTATION
USING FSTR_TRDIR LIKE TRDIR
FSTR_THEAD LIKE MSTR_THEAD.
DATA:
LC_OBJ_NAME LIKE E071-OBJ_NAME,
LC_LINE2(40)
TYPE C,
LC_ANSWER(1)
TYPE C.
*-- read trdir to see if the report already exists, if it does, prompt
*-- user to overwrite or abort.
SELECT SINGLE * FROM TRDIR WHERE NAME = FSTR_TRDIR-NAME.
IF SY-SUBRC = 0.
" Already exists
CONCATENATE 'want to overwrite report'
FSTR_TRDIR-NAME
ABAP Programming Tips
LC_DNUM = SY-DYNNR .
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME
= LC_PROG
DYNUMB
= LC_DNUM
TABLES
dynpfields = ltab_fields
EXCEPTIONS
OTHERS
= 01.
read table ltab_fields index 1.
IF SY-SUBRC EQ 0.
F_NAME = LTAB_FIELDS-FIELDVALUE.
refresh ltab_fields.
ENDIF.
CALL FUNCTION 'F4_USER'
EXPORTING
OBJECT = F_NAME
IMPORTING
RESULT = F_NAME.
ENDFORM.
" GET_NAME
%&%& TEXPZKBPROGS
IDIR
File Download Options (File Selection)
{{{
IFIL
File Options
{{{
IFNA
Enter filename below (under File Options)
*{{{
IH01
Prog Name
{{{
IH03
Program Description
{{{
ISNG
Upload a single file
#{{{
IUDL
Upload to SAP/Download from SAP
{{{
IUPL
File Upload Options
{{{
R
Backup/Restore program source code with texts
-{{{
SP_PATH
Path to save programs to
{{{
SRB_DOS
Files on local computer
#{{{
SRB_DOWN
Download Programs
{{{
SRB_FILE
Upload a single file
{{{
SRB_LIST
Select program(s) from a list
%{{{
SRB_UNIX
Files on remote computer
"{{{
SRB_UP
Upload Programs to
SAP
-{{{
SS_CDAT
{{{
SS_CNAM
{{{
SS_NAME
{{{
SS_SUBC
{{{
SS_UDAT
{{{
SS_UNAM
UserID
Date Created
Created by UserID
Program Name
Program Type
Date Changed
Last Changed by
-{{{
%&%& HEADZKBPROGS
DOKU
ZHRBDC54
S_DOCU_SHOW
S_DOCUS100002ABAPER1
1999070715193207200000 0
%&%& DOKLZKBPROGS
RE
31H 19990707151635ABAPER1
E
31H
***********************************************************
* 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 = '<HTML><HEAD><TITLE>Table Browser</TITLE>'.
APPEND htmlview.
htmlview-htmlcode = '<BODY BGCOLOR="#404040"><FONT COLOR="#00FFFF"
face="Arial Black"> Table View : '.
APPEND htmlview.
htmlview-htmlcode = tabname. APPEND htmlview.
htmlview-htmlcode = '</FONT> <p> </p>'. 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 = '<table border="0" width="100%">'. APPEND htmlview.
htmlview-htmlcode = '<tr valign="middle" BGCOLOR="#5F5F5F">'.
APPEND htmlview.
htmlview-htmlcode = '<FONT SIZE="3" COLOR="#FFBF18" FACE= "Courier
new">'.
APPEND htmlview.
LOOP AT zdfies.
PERFORM htmlheader USING zdfies-fieldname.
flditab-fldname = zdfies-fieldname.
APPEND flditab.
ENDLOOP.
htmlview-htmlcode = '</B></tr>'. APPEND htmlview.
colorval = 1.
SELECT COUNT(*) FROM (tabname) INTO totalrows.
WRITE :/ totalrows.
ABAP Programming Tips
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 = '<tr valign="middle" BGCOLOR="#F7F7F7"><FONT
size="1" COLOR="#008080" FACE="Arial Narrow">'.
APPEND htmlview.
ELSE.
htmlview-htmlcode = '<tr valign="middle"
bgcolor="#D2D2D2"><FONT SIZE="1" COLOR="#9F000F" FACE="Arial Narrow">'.
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 = '</FONT></tr>'. APPEND htmlview.
CLEAR: w_area1.
ENDSELECT.
htmlview-htmlcode = '</body></html>'. 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.
ABAP Programming Tips
=
=
=
=
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 = '<td >'. APPEND htmlview.
htmlview-htmlcode = name. APPEND htmlview.
htmlview-htmlcode = '</td>'. APPEND htmlview.
ENDFORM.
********************************************************
FORM htmlheader USING name TYPE c.
htmlview-htmlcode = '<td >'. APPEND htmlview.
htmlview-htmlcode = name. APPEND htmlview.
htmlview-htmlcode = '</td>'. APPEND htmlview.
ENDFORM.
'31' '34'
'Tomasevic'.
s_erdat
s_usnam
s_vstat
SELECTION-SCREEN END OF
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
ABAP Programming Tips
object
TABLES
roles
EXCEPTIONS
internal_error
no_logsys
OTHERS
= t_object
= t_roles
= 1
= 2
= 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.
COLLECT itab_data2.
ENDLOOP.
ENDIF.
WHEN 'ZP00'.
"Scheduling Agreement
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 = 'BUS2035'.
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.
ENDCASE.
ENDLOOP.
ENDIF.
ENDIF.
END-OF-SELECTION.
DESCRIBE TABLE itab_data.
IF sy-tfill > 0.
IF r_kappl = 'X'.
SORT itab_data BY kappl.
ELSEIF r_objky = 'X'.
SORT itab_data BY objky.
ELSEIF r_kschl = 'X'.
SORT itab_data BY kschl.
ELSEIF r_parnr = 'X'.
SORT itab_data BY parnr.
ELSEIF r_erdat = 'X'.
SORT itab_data BY erdat.
ELSEIF r_usnam = 'X'.
SORT itab_data BY usnam.
ELSEIF r_vstat = 'X'.
SORT itab_data BY vstat.
ABAP Programming Tips
ENDIF.
PERFORM print_itab_data
TABLES itab_data
itab_data2.
ENDIF.
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',
ABAP Programming Tips
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
DATA:
FOR bseg-belnr,
FOR bkpf-budat,
FOR bkpf-blart
BLOCK block1.
DATA:
DATA:
DATA:
* 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.
= pos.
= 'SKAT-TXT20'.
"Posting Date
"Acct number
"Cost Center
"Acct Description
Page 136 of 157
ls_fieldcat-ref_fieldname = 'TXT20'.
ls_fieldcat-ref_tabname
= 'SKAT'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'SKAT-TXT50'.
ls_fieldcat-ref_fieldname = 'TXT50'.
ls_fieldcat-ref_tabname
= 'SKAT'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
*
*
*
*
*
*
*
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-AUGBL'.
ls_fieldcat-ref_fieldname = 'AUGBL'.
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-KUNNR'.
ls_fieldcat-ref_fieldname = 'KUNNR'.
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
= 'KNA1-NAME1'.
ls_fieldcat-ref_fieldname = 'NAME1'.
ls_fieldcat-ref_tabname
= 'KNA1'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BKPF-XBLNR'.
ls_fieldcat-ref_fieldname = 'XBLNR'.
ls_fieldcat-ref_tabname
= 'BKPF'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-SHKZG'.
ls_fieldcat-ref_fieldname = 'SHKZG'.
ls_fieldcat-ref_tabname
= 'BSEG'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-WRBTR'.
ls_fieldcat-ref_fieldname = 'WRBTR'.
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
= 'BKPF-WAERS'.
ls_fieldcat-ref_fieldname = 'WAERS'.
ls_fieldcat-ref_tabname
= 'BKPF'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
"Acct Description
"Clearing Doc
"Cust number
"Customer name
"DR/CR ind.
"Currency Key
pos.
Page 137 of 157
ls_fieldcat-fieldname
= 'BKPF-KURSF'.
ls_fieldcat-ref_fieldname = 'KURSF'.
ls_fieldcat-ref_tabname
= 'BKPF'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-DMBTR'.
ls_fieldcat-ref_fieldname = 'DMBTR'.
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-GJAHR'.
ls_fieldcat-ref_fieldname = 'GJAHR'.
ls_fieldcat-ref_tabname
= 'BSEG'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-BUZEI'.
ls_fieldcat-ref_fieldname = 'BUZEI'.
ls_fieldcat-ref_tabname
= 'BSEG'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos
= pos.
ls_fieldcat-fieldname
= 'BSEG-BSCHL'.
ls_fieldcat-ref_fieldname = 'BSCHL'.
ls_fieldcat-ref_tabname
= 'BSEG'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
*
*
*
*
*
*
*
*
*
"Exchange Rate
"Fiscal Year
"Doc Line #
"Posting Key
"Cost Center
"Company Code
"Document Type
"Item Text
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
= 'BKPF-USNAM'.
ls_fieldcat-ref_fieldname = 'USNAM'.
ls_fieldcat-ref_tabname
= 'BKPF'.
LS_FIELDCAT-NO_OUT
= 'X'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
ENDFORM.
"User name
"fieldcat_init
* Data selection
FORM select_data TABLES rt_outtab LIKE gt_outtab[].
DATA: l_name LIKE tline-tdline.
* IF s_hkont IS INITIAL.
SELECT
" select_data
TABLES MAKT.
TABLES T001.
TABLES MBEW.
DATA %COUNT-MBEW(4) TYPE X.
DATA %LINR-MBEW(2).
DATA: BEGIN OF %JOINWA,
MBEW LIKE MBEW,
MAKT LIKE MAKT,
END OF %JOINWA.
TABLES AQLDB.
INCLUDE RSAQEXCD.
DATA: BEGIN OF %ST_LISTE OCCURS 100,
HEAD(1),
TAB(3),
LINE(6) TYPE N,
CONT(1) TYPE N,
FINT(1),
FINV(1),
FCOL(1) TYPE N,
TEXT(0253),
END OF %ST_LISTE.
DATA
DATA
DATA
DATA
DATA
DATA
DATA
DATA
%DATA_SELECTED(1).
%GLFRAME(1) VALUE 'X' .
%UFLAG(1).
%USTFLAG(1).
%GRST_TEXT(255).
%GLLINE TYPE I.
%TABIX LIKE SY-TABIX.
%PRFLAG(1) TYPE X VALUE '02'.
PARAMETERS:
%EIS RADIOBUTTON GROUP FUNC MODIF ID OLD.
SELECTION-SCREEN: COMMENT 4(26) TEXT-F63 FOR FIELD %EIS
MODIF ID OLD.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
PARAMETERS:
%XINT RADIOBUTTON GROUP FUNC MODIF ID XIN.
SELECTION-SCREEN: COMMENT 4(26) TEXT-F73 FOR FIELD %XINT
MODIF ID XIN.
PARAMETERS:
%XINTK(30) LOWER CASE MODIF ID XIN.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
PARAMETERS:
%DOWN RADIOBUTTON GROUP FUNC MODIF ID OLD.
SELECTION-SCREEN: COMMENT 4(26) TEXT-F64 FOR FIELD %DOWN
MODIF ID OLD.
PARAMETERS:
%PATH(132) LOWER CASE MODIF ID OLD.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
PARAMETERS:
%SAVE RADIOBUTTON GROUP FUNC MODIF ID OLD.
SELECTION-SCREEN: COMMENT 4(26) TEXT-F62 FOR FIELD %SAVE
MODIF ID OLD.
PARAMETERS:
%LISTID(40) LOWER CASE MODIF ID OLD.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: END OF BLOCK DIRECT.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF %G00 OCCURS 100,
MBEW-MATNR LIKE MBEW-MATNR,
MAKT-MAKTX LIKE MAKT-MAKTX,
MBEW-VERPR LIKE MBEW-VERPR,
T001-WAERS-0103 LIKE T001-WAERS,
MBEW-PEINH LIKE MBEW-PEINH,
END OF %G00.
DATA: BEGIN OF %%G00,
MBEW-MATNR(018),
MAKT-MAKTX(040),
MBEW-VERPR(015),
T001-WAERS-0103 LIKE T001-WAERS,
MBEW-PEINH(006),
END OF %%G00.
DATA %ZNR TYPE I.
DATA %LZNR TYPE I VALUE 99999.
FIELD-GROUPS HEADER.
DATA %GROUP01.
DATA %%MAKT-MAKTX LIKE MAKT-MAKTX.
DATA %%%MAKT-MAKTX(1).
DATA %GROUP0101.
FIELD-GROUPS %FG01.
DATA %ANY-01.
CONTROLS TVIEW100 TYPE TABLEVIEW USING SCREEN 100.
AT SELECTION-SCREEN .
PERFORM ALVL_CHECK(RSAQEXCE) USING %ALVL 'G00'.
PERFORM TESTMODE(RSAQEXCE).
PERFORM CHECK_EXPCOL(RSAQEXCE) USING %ALV.
RINIT(RSAQBRST).
SET_EXPCOL(RSAQEXCE) USING %ALV PB%EXCO.
ALVL_SET_INVISIBLE(RSAQEXCE).
SET_XINT_PARAMS(RSAQEXCE).
INITIALIZATION.
PERFORM INIT_XINT(RSAQEXCE).
PERFORM SET_WWW_FLAGS(RSAQEXCE).
START-OF-SELECTION.
INSERT MAKT-MAKTX INTO HEADER.
INSERT %COUNT-MBEW INTO HEADER.
ABAP Programming Tips
%DIACT = SPACE.
%BATCH = SY-BATCH.
IF %BATCH <> SPACE.
IF %EIS <> SPACE.
%DIACT = 'E'.
NEW-PAGE PRINT ON DESTINATION 'NULL' NO DIALOG
LINE-SIZE 0253 LINE-COUNT 0065.
ENDIF.
IF %ALV <> SPACE.
%DIACT = 'V'.
%ALV_LAYOUT = %ALVL.
NEW-PAGE PRINT ON DESTINATION 'NULL' NO DIALOG
LINE-SIZE 0253 LINE-COUNT 0065.
ENDIF.
IF %SAVE <> SPACE.
%DIACT = 'S'.
NEW-PAGE PRINT ON DESTINATION 'NULL' NO DIALOG
LINE-SIZE 0253 LINE-COUNT 0065.
ENDIF.
ELSEIF %CALLED_BY_WWW <> SPACE.
%DIACT = SPACE.
ELSEIF %CALLED_BY_WWW_ALV <> SPACE.
%DIACT = 'V'.
ELSE.
IF %SAVE <> SPACE. %DIACT = 'S'. ENDIF.
IF %XINT <> SPACE. %DIACT = 'I'. ENDIF.
IF %TVIEW <> SPACE. %DIACT = 'T'. ENDIF.
IF %ALV
<> SPACE. %DIACT = 'V'. ENDIF.
IF %DOWN <> SPACE. %DIACT = 'D'. ENDIF.
IF %EIS
<> SPACE. %DIACT = 'E'. ENDIF.
IF %GRAPH <> SPACE. %DIACT = 'G'. ENDIF.
IF %EXCEL <> SPACE. %DIACT = 'X'. ENDIF.
IF %TEXT <> SPACE. %DIACT = 'W'. ENDIF.
IF %ABC
<> SPACE. %DIACT = 'A'. ENDIF.
IF %DIACT <> SPACE AND %DIACT <> 'S' AND %DIACT <> 'W'.
NEW-PAGE PRINT ON DESTINATION 'NULL' NO DIALOG
LINE-SIZE 0253 LINE-COUNT 0065.
ENDIF.
%PATHNAME = %PATH.
IF %DIACT = 'I'.
%FUNCTIONKEY = %XINTK.
ENDIF.
IF %DIACT = 'V'.
%ALV_LAYOUT = %ALVL.
ENDIF.
ENDIF.
FREE MEMORY ID 'AQLISTDATA'.
IF %MEMMODE <> SPACE.
IF %BATCH <> SPACE.
NEW-PAGE PRINT ON DESTINATION 'NULL' NO DIALOG
LINE-SIZE 0253 LINE-COUNT 0065.
ENDIF.
%DIACT = '1'.
ENDIF.
%TITEL = ' '.
IF SY-SUBTY O %PRFLAG AND %TITEL = SPACE.
NEW-PAGE WITH-TITLE.
ENDIF.
%TVSIZE = 0200.
%PLINE = 1.
%PZGR = 1.
%FIRST = 'X'.
PERFORM %OUTPUT.
%FIRST = SPACE.
IF %DIACT <> SPACE AND %DIACT <> 'S'.
NEW-PAGE PRINT OFF.
NEW-PAGE NO-HEADING NO-TITLE.
WRITE SPACE.
ELSE.
PERFORM PF-STATUS(RSAQEXCE) USING 'XXX
'.
ENDIF.
CLEAR: %TAB, %LINE, %CONT.
IF %DATA_SELECTED = SPACE.
IF %DIACT = '1'.
EXPORT EMPTY FROM %EMPTY TO MEMORY ID 'AQLISTDATA'.
LEAVE.
ELSE.
ABAP Programming Tips
WHEN 'WEIT'.
PERFORM RETURN(RSAQEXCE).
WHEN 'INHA'.
PERFORM CATALOGUE(RSAQEXCE).
WHEN 'AUSL'.
PERFORM PICKUP(RSAQEXCE).
WHEN 'AUSW'.
PERFORM PICKUP(RSAQEXCE).
WHEN 'RCAA'.
PERFORM RCHAIN(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_LIST.
WHEN 'ODRU'.
PERFORM PRINT_LIST(RSAQEXCE).
WHEN 'COPA'.
PERFORM PRINT_COVER_PAGE(RSAQEXCE).
WHEN 'TEXT'.
PERFORM %DOWNLOAD USING 'TEXT'.
WHEN 'ALV'.
PERFORM %DOWNLOAD USING 'ALV'.
WHEN 'VIEW'.
PERFORM %VIEW.
WHEN 'XXL'.
PERFORM %DOWNLOAD USING 'XXL'.
WHEN 'GRAF'.
PERFORM %DOWNLOAD USING 'GRAF'.
WHEN 'ABCA'.
PERFORM %DOWNLOAD USING 'ABCA'.
WHEN 'EIS'.
PERFORM %DOWNLOAD USING 'EIS'.
WHEN 'DOWN'.
PERFORM %DOWNLOAD USING 'DOWN'.
WHEN 'XINT'.
PERFORM %DOWNLOAD USING 'XINT'.
ENDCASE.
CLEAR: %CLINE, %ZGR.
CLEAR: %TAB, %LINE, %CONT.
IF %DIACT <> SPACE.
LEAVE LIST-PROCESSING.
ENDIF.
FORM %COMP_LDESC.
REFRESH %LDESC.
REFRESH %GDESC.
PERFORM LDESC(RSAQEXCE) USING 'G00010000X018
00 98'
TEXT-A00 TEXT-B00 TEXT-H00 'MBEW-MATNR' MBEW-MATNR 'MBEW-MATNR'.
PERFORM LDESC(RSAQEXCE) USING 'G00020000X040
01 98'
TEXT-A01 TEXT-B01 TEXT-H00 'MAKT-MAKTX' MAKT-MAKTX 'MAKT-MAKTX'.
PERFORM LDESC(RSAQEXCE) USING 'G00030062 015F
00 98'
TEXT-A02 TEXT-B02 TEXT-H00 'MBEW-VERPR' MBEW-VERPR 'MBEW-VERPR'.
PERFORM LDESC(RSAQEXCE) USING 'G00040000 005W
00 98'
TEXT-A03 TEXT-B03 TEXT-H00 'T001-WAERS' T001-WAERS
'T001-WAERS-0103'.
PERFORM LDESC(RSAQEXCE) USING 'G00050084 006
00 98'
TEXT-A04 TEXT-B04 TEXT-H00 'MBEW-PEINH' MBEW-PEINH 'MBEW-PEINH'.
PERFORM GDESC(RSAQEXCE) USING 'G00' 5 20 ' ' ' ' 'X'.
ENDFORM.
FORM %OUTPUT.
DESCRIBE TABLE %PRLIST LINES %MAX_PRLIST.
%HEAD = 'AAA'.
ABAP Programming Tips
%KEYEMPTY = SPACE.
NEW-PAGE.
PERFORM %OUTPUT_GL.
PERFORM COMPLETE_PAGE(RSAQEXCE).
%HEAD = 'ZZZ'.
PERFORM LAST_PTAB_ENTRY(RSAQEXCE).
NEW-PAGE.
IF %KEYEMPTY <> SPACE.
MESSAGE S894(AQ).
ENDIF.
ENDFORM.
FORM %TOP-OF-PAGE.
IF
IF
IF
IF
FORM %NEWLINE.
%UFLAG = SPACE.
NEW-LINE.
WRITE: '|', 252 '|'.
POSITION 2.
ENDFORM.
FORM %SKIP USING COUNT.
IF SY-LINNO > 1.
%UFLAG = SPACE.
DO COUNT TIMES.
NEW-LINE.
FORMAT RESET.
WRITE: '|', 252 '|'.
ENDDO.
ENDIF.
ENDFORM.
FORM %ULINE.
IF %UFLAG = SPACE.
IF SY-LINNO > 1.
ULINE /1(252).
ENDIF.
%UFLAG = 'X'.
ENDIF.
ENDFORM.
FORM %HIDE.
IF %BATCH <> SPACE AND %DIACT = 'S'.
PERFORM HIDE(RSAQEXCE).
ELSE.
HIDE: %TAB, %LINE, %CONT.
ENDIF.
ENDFORM.
FORM %HIDE_COLOR.
IF %BATCH <> SPACE AND %DIACT = 'S'.
PERFORM HIDE_COLOR(RSAQEXCE).
ELSE.
HIDE: %FINT, %FCOL.
ENDIF.
ENDFORM.
FORM %RCALL USING NAME VALUE.
FIELD-SYMBOLS <FIELD>.
ASSIGN (NAME) TO <FIELD>.
READ CURRENT LINE FIELD VALUE <FIELD> INTO VALUE.
IF SY-SUBRC <> 0.
VALUE = SPACE.
EXIT.
ENDIF.
IF VALUE = SPACE AND %TAB = 'G00' AND %LDESC-FCUR NA 'FM'.
READ TABLE %G00 INDEX %LINE.
IF SY-SUBRC = 0.
ASSIGN COMPONENT %LDESC-FNAMEINT OF STRUCTURE %G00
TO <FIELD>.
IF SY-SUBRC = 0.
WRITE <FIELD> TO VALUE(%LDESC-FOLEN).
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
FORM %SAVE_PAGE.
IF %BATCH <> SPACE AND %DIACT = 'S'.
PERFORM SAVE_PAGE(RSAQEXCE) TABLES %ST_LISTE.
ENDIF.
ENDFORM.
FORM %REPLACE_VAR USING TEXT.
FIELD-SYMBOLS <VAR>.
ASSIGN TEXT+1(*) TO <VAR>.
ENDFORM.
FORM %SAVE_LIST.
DATA: %SFLAG,
QREPORT LIKE SY-REPID.
IF %DIACT = 'S'. %SFLAG = 'X'. ENDIF.
QREPORT = SY-REPID.
PERFORM SAVE_LIST(RSAQEXCE) TABLES %ST_LISTE
USING QREPORT %SFLAG %LISTID.
IF %QL_ID <> SPACE.
%DLFLAG = 'X'.
%LISTSIZE = 0253.
PERFORM COMP_SELECTION_SCREEN(RSAQEXCE).
EXPORT %ST_LISTE %PTAB %LDESC %GDESC %DLFLAG %LISTSIZE
%SELECTIONS
%G00
TO DATABASE AQLDB(AQ) ID %QL_ID.
ENDIF.
ENDFORM.
FORM %REFRESH.
CASE %TAB.
WHEN 'G00'.
IMPORT %G00 FROM DATABASE AQLDB(AQ) ID %QL_ID.
ABAP Programming Tips
ENDCASE.
ENDFORM.
FORM %DOWNLOAD USING CODE.
DATA: QREPORT LIKE SY-REPID.
PERFORM INIT_DOWNLOAD(RSAQEXCE).
QREPORT = SY-REPID.
CASE %TAB.
WHEN 'G00'.
PERFORM DOWNLOAD(RSAQEXCE)
TABLES %G00 USING CODE QREPORT TEXT-GRL.
WHEN OTHERS.
MESSAGE S860(AQ).
ENDCASE.
ENDFORM.
FORM %SET_DATA CHANGING L_LINES TYPE I.
IMPORT LDATA TO %G00 FROM MEMORY ID 'AQLISTDATA'.
DESCRIBE TABLE %G00 LINES L_LINES.
FREE MEMORY ID 'AQLISTDATA'.
ENDFORM.
FORM %GET_DATA TABLES DATATAB STRUCTURE %G00
USING FIRST TYPE I
LAST TYPE I.
APPEND LINES OF %G00 FROM FIRST TO LAST TO DATATAB.
ENDFORM.
FORM %GET_REF_TO_TABLE USING LID
LIKE RSAQLDESC-LID
REF_TO_ITAB TYPE REF TO DATA
SUBRC
LIKE SY-SUBRC.
SUBRC = 0.
CASE LID.
WHEN 'G00'.
CREATE DATA REF_TO_ITAB LIKE %G00[].
WHEN OTHERS.
SUBRC = 4.
MESSAGE S860(AQ).
ENDCASE.
ENDFORM.
FORM %VIEW.
DATA: ANZ TYPE I,
PROG LIKE SY-REPID.
PROG = SY-REPID.
PERFORM INIT_DOWNLOAD(RSAQEXCE).
CASE %TAB.
WHEN 'G00'.
PERFORM GENERATE_VIEW_DYNPRO(RSAQEXCE)
USING PROG TEXT-GRL.
DESCRIBE TABLE %G00 LINES ANZ.
TVIEW100-LINES = ANZ.
PERFORM INIT_VIEW(RSAQEXCE) TABLES %G00 USING TVIEW100.
CALL SCREEN 100.
PERFORM RESET_VIEW_DYNPRO(RSAQEXCE).
WHEN OTHERS.
MESSAGE S860(AQ).
ENDCASE.
ENDFORM.
FORM %OUTPUT_GL.
IF %MAX_PRLIST <> 0.
ABAP Programming Tips
CASE %TAB.
WHEN 'G00'.
PERFORM INIT_PBO(RSAQEXCE) TABLES %G00 USING TVIEW100 'X'.
WHEN OTHERS.
MESSAGE S860(AQ).
ENDCASE.
ENDMODULE.
MODULE %PBO_VIEW OUTPUT.
CASE %TAB.
WHEN 'G00'.
PERFORM LOOP_PBO(RSAQEXCE) TABLES %G00 USING %%G00 TVIEW100.
ENDCASE.
ENDMODULE.
MODULE %PAI_VIEW INPUT.
CASE %TAB.
WHEN 'G00'.
PERFORM LOOP_PAI(RSAQEXCE) TABLES %G00 USING %%G00 TVIEW100.
ENDCASE.
ENDMODULE.
MODULE %OKCODE_VIEW INPUT.
CASE %TAB.
WHEN 'G00'.
PERFORM OKCODE(RSAQEXCE) TABLES %G00 USING TVIEW100.
ENDCASE.
ENDMODULE.
TYPE
TYPE
LIKE
LIKE
LIKE
TYPE
= filestring
= ','
= itab_tx
=
=
=
=
=
=
=
=
=
=
=
=
1
2
3
4
5
6
7
8
9
10
11
12
Page 151 of 157
dp_error_write
= 13
unknown_dp_error
= 14
access_denied
= 15
dp_out_of_memory
= 16
disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception = 20
control_flush_error
= 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
Syntax error in SDCC, table inconsistency between 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 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:
select EDIT
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.
Under import parameter MODE, enter the number 12 and under TABNAME the corresponding table
name
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:
Then call Transaction SE14 again and verify that the table has been activated.
If this is not the case, open a CSN message under the BC-DWB-DIC-ED component.
CHAPTER 9 INDEX
ALV Grid Controls
Custom Buttons, 46
Method
handle_toolbar, 47
handle_user_command, 48
Text Edit
highlight_lines, 50
set_first_visible_line, 50
set_readonly_mode, 50
Text Editor Control Object, 51
background processing, 33
BAPI, 14
BDC
BDC Processing & Idoc status update, 59
'BDC_CLOSE_GROUP', 60
'BDC_INSERT', 60
'BDC_OPEN_GROUP', 60
CALL FUNCTION
'AB_RFC_X_SCRAMBLE_STRING', 25
ABAP_DOCU_DOWNLOAD, 7
ARFC_GET_TID, 7
BAL_*, 7
BP_EVENT_RAISE, 7
BP_JOBLOG_READ, 7
CLOI_PUT_SIGN_IN_FRONT, 7
CLPB_EXPORT, 7
CLPB_IMPORT, 7
COMMIT_TEXT, 7
CONVERSION_EXIT_ALPHA_INPUT, 7
CONVERSION_EXIT_ALPHA_OUTPUT, 7
CONVERT_ABAPSPOOLJOB_2_PDF, 9
CONVERT_OTF, 7, 10
'CONVERT_OTF', 7
CONVERT_OTFSPOOLJOB_2_PDF, 9
DATE_CHECK_PLAUSIBILITY, 7
DATE_GET_WEEK, 7
'DEQUEUE_ALL', 56, 57, 112, 113
DOWNLOAD, 7, 8, 26, 27, 32, 75, 77, 78, 98, 116, 117,
118
DYNP_VALUES_READ, 8, 122
DYNP_VALUES_UPDATE, 8
'EDI_DOCUMENT_CLOSE_EDIT', 54
'EDI_DOCUMENT_CLOSE_PROCESS', 54, 111
'EDI_DOCUMENT_DATA_DISPLAY', 21, 55, 69
'EDI_DOCUMENT_DEQUEUE_LATER', 56, 113
ABAP Programming Tips
'EDI_DOCUMENT_OPEN_FOR_EDIT', 53
'EDI_DOCUMENT_OPEN_FOR_PROCESS', 54, 110
'EDI_DOCUMENT_OPEN_FOR_READ', 54, 108
'EDI_DOCUMENT_STATUS_SET', 53, 54, 111
'EDI_SEGMENTS_GET_ALL', 54, 108
ENQUE_SLEEP, 8
ENQUEUE_ESFUNCTION, 8
EPS_GET_DIRECTORY_LISTING, 8
EPS_GET_FILE_ATTRIBUTES, 8
F4_DATE, 8
'F4_USER', 122
F4IF_SHLP_EXIT_EXAMPLE, 8
FILENAME_GET, 8, 10
FORMAT_MESSAGE, 8
FTP_COMMAND, 8, 25
'FTP_COMMAND', 25
FTP_CONNECT, 8, 25
FTP_DISCONNECT, 8, 25
'FTP_DISCONNECT', 25
G_SET_GET_ALL_VALUES, 8
GET_GLOBAL_SYMBOLS, 8
GET_INCLUDETAB, 8
GUI_CREATE_DIRECTORY, 8
GUI_DELETE_FILE, 8
'GUI_DOWNLOAD', 27, 98
GUI_EXEC, 8
GUI_GET_DESKTOP_INFO, 8
GUI_REMOVE_DIRECTORY, 8
GUI_RUN, 8
GUI_UPLOAD, 8
HELP_START, 8
HOLIDAY_GET, 8
HR_DISPLAY_BASIC_LIST, 8
HR_GET_LEAVE_DATA, 8
'IDOC_ERROR_WORKFLOW_START', 55, 112
'IDOC_READ_COMPLETELY', 54
IDOC_STATUS_WRITE_TO_DATABASE, 7
IDOC_TYPE_COMPLETE_READ, 7
'INBOUND_IDOC_PROCESS', 53
INIT_TEXT, 8
K_WERKS_OF_BUKRS_FIND, 8
LIST_TO_ASCII, 8
MASTER_IDOC_DISTRIBUTE, 7, 53
MONTH_NAMES_GET, 8
MS_EXCEL_OLE_STANDARD_OLE, 8
Page 155 of 157
OTF_CONVERT, 8
'POPUP_GET_VALUES', 20, 27, 98
POPUP_TO_CONFIRM_LOSS_OF_DATA, 9
POPUP_TO_CONFIRM_STEP, 9, 121
POPUP_TO_CONFIRM_WITH_MESSAGE, 9
POPUP_TO_CONFIRM_WITH_VALUE, 9
POPUP_TO_DECIDE, 9
POPUP_TO_DISPLAY_TEXT, 9
POPUP_TO_SELECT_MONTH, 9
POPUP_WITH_TABLE_DISPLAY, 9
PRICING, 9
PROFILE_GET, 9
PROFILE_SET, 9
READ_TEXT, 9
REGISTRY_GET, 9
REGISTRY_SET, 9
RFC_ABAP_INSTALL_AND_RUN, 9
RH_GET_ACTIVE_WF_PLVAR, 9
RH_GET_DATE_DAYNAME, 9
RH_START_EXCEL_WITH_DATA, 9
RH_STRUC_GET, 9
RP_CALC_DATE_IN_INTERVAL, 9
RP_LAST_DAY_OF_MONTHS, 9
RPY_DYNPRO_READ, 9
RPY_TRANSACTION_READ, 9
RS_COVERPAGE_SELECTIONS, 9
RS_REFRESH_FROM_SELECTOPTIONS, 9
RS_SEND_MAIL_FOR_SPOOLLIST, 9
RS_VARIANT_CONTENTS, 9
'RV_ORDER_FLOW_INFORMATION', 32
RZL_READ_DIR, 9
RZL_READ_DIR_LOCAL, 9
RZL_READ_FILE, 10
RZL_SLEEP, 9
RZL_SUBMIT, 9
RZL_WRITE_FILE_LOCAL, 10
SAPGUI_PROGRESS_INDICATOR, 10
SAVE_TEXT, 10
SCROLLING_IN_TABLE, 10
SD_DATETIME_DIFFERENCE, 10
SO_NEW_DOCUMENT_ATT_SEND_API1, 10
SO_SPLIT_FILE_AND_PATH, 10
SO_SPOOL_READ, 10
SO_WIND_SPOOL_LIST, 10
'SWE_EVENT_CREATE', 56, 113
SXPG_CALL_SYSTEM, 10
SXPG_COMMAND_CHECK, 10
SXPG_COMMAND_DEFINITION_GET, 10
ABAP Programming Tips
SXPG_COMMAND_EXECUTE, 10
SXPG_COMMAND_LIST_GET, 10
TERMINAL_ID_GET, 10
TH_DELETE_USER, 10
TH_ENVIRONMENT, 10
TH_POPUP, 10
TH_REMOTE_TRANSACTION, 10
TH_USER_INFO, 10
TH_USER_LIST, 10
UNIT_CONVERSION_SIMPLE, 10
UPLOAD, 8, 10, 115, 116, 119
WRITE_LIST, 8, 10
WS_DOWNLOAD, 10, 32, 124
'WS_DOWNLOAD', 27, 78, 118
WS_EXCEL, 10
WS_EXECUTE, 8, 10, 124
WS_FILE_DELETE, 8, 10
WS_MSG, 10
WS_VOLUME_GET, 10
WWW_LIST_TO_HTML, 10
Checkboxes, 20
Displaying Transaction, 31
Document Flow, 32
Dynamic selection screens, 22
Editor
*$*$*, 33
*EJECT, 32, 33
Editor Tips, 32
File Processing
DATASET, 25
FTP, 8, 24, 25
Graphical POPUP progress display, 106
GUI-Status, 31
Hiding ABAP Source Code, 32
IDoc
Change IDoc status to error status and send to
workflow, 106
Changing an IDoc, 53
Creating an IDoc, 53
Creation, 53, 85, 96
Displaying an IDoc, 55
IDoc creation from inbound file, 86
Idoc type pool, 55
Include Definitions
MBDCONWF, 12
Reading an IDoc, 54
Returning IDocs linked to documents, 57
sending an IDoc, 53
Write Idoc Status, 59
Page 156 of 157
Initialization
Initializing date ranges, 19
Joins
Report with joins and macros, 99
Launching an Error workflow, 55
List Boxes, 20
Macro
Define, 28, 29, 100, 101
MACRO
Define, 28, 87, 100
Mailing in SAP, 61
Message Type
DELINS, 3
Output Type
BA00, 3, 4
LAVA, 3
RD00, 3
Popup selection, 20
Program
Report to download programs, 113
Programs
IDoc creation from inbound file, 97
RPR_ABAP_SOURCE_SCAN, 11, 12
RV80HGEN, 11
Report
headings, 19
SAP ABAP
as checkbox, 20
AT LINE SELECTION, 68
AT LINE-SELECTION, 21, 68, 102, 115
at selection-screen, 26
CALL TRANSACTION, 21, 60, 61, 68, 102
CLOSE DATASET, 25, 26, 81, 88, 89, 119
concatenate, 28, 29, 80, 83, 88, 100, 101
DELETE DATASET, 26, 81, 89