Beruflich Dokumente
Kultur Dokumente
# 1 . What are the 2 boxes in your system for coding for Abap and their logins?
Development System & IDES/Sandbox
# 2. If I get a problem on a report in Production server how can I modify the report.
If the problem in production server we have to alter the program in Developemnt Client and transport it to
QA client Test it throughly and then Transport it to Production.
# 3. Tell me about Tokens.
Tokens are Issues sent by the Client to us.
#4 .How to Fix the bugs and where you will do those things.
It Actuall Depends what kind of bugs they asked about:
If it is a problem in Program, then we alter them in the SE38 (Develpment) and transport it after testing to
Prd Server.
#5. What is a sandboxes.
SAND BOX is nothing but a test client other than Develpment Client or QA.
#6.How to conncet the from ur office to clinet in US.
It will be configured by the BASIS guys..
In the sap logon pad they will enter the application server id and Routing String and the SERver type in the
Sytem Number....
with that we will connect
#7.Tell me about VPN and the connections.
Its a another way to connect to other PC. its a 3rd party utility....
#8. How to login ur system.
Thru SAP Logon enter the client number ,user id & password.
#9 .What is the purpose of SE14.
Database Utility to perform table maintenance such as deleting the table or adjusting the table when there is
a structure change.
#10 .What is the purpose of SM30.
SM30 is a table Maintanance for the Ztable Created by us.
#11.In Data dictionary in the table creation,What is the purpose of Technical settings.
To identify the Size of the Table Created and to Set whether buffering needs to be done for the table or not.
#12. What is the purpose of buffering in technical settings and for what type of tables are using
buffering.
It will reduce the Network tarffic but disadvantage is it will not update the Server back immediately.
#13. In reporting tell me all the events in a sequentail order.
- Initialization.
- At Selection-Screen
- Start-of-Selection.
- Top-of-Page.
- At Pfn.
- End-of-Page.
- End-of-Selection.
ABAP Self Test Q & A
1) Authorization Objects
( this question has more than 1 answer )
a) Stored in User Master
b) Defines fields for a complex authority check
c) Grouped together in profiles
d) Covers up to 10 fields
e) Consists of up to 10 authorization objects
2) Authorization Checking
( this question has more than 1 answer )
a) performed with SELECT statement
b) performed with AUTHORITY-CHECK
c) determines if user has authority in master record
d) always refers to authorization profile
e) system admin defines which authorization checks are executed
3) Authorization
( this question has more than 1 answer )
a) contains value for field of an authorization object
b) defines fields for a complex authorization object
c) can be grouped together in profiles
d) always refer to a particular authorization
e) authorizations and profiles are stored in user master record
4) Using SM35 in which case does the system check authorization:
( this question has more than 1 answer )
a) always
b) process / foreground
c) display errors only
d) process / background
e) system decides based on profile
5) Search Helps:
( this question has more than 1 answer )
a) called at POV
b) controls how fixed values are displayed when F4 is pressed
c) allow different views of info when help is required
c) a logical grouping of database updates that should all be performed at the same time
d) the section of program code from setting a lock until it is released
e) all actions between first and last database update in transaction
14) Why do update functions have attributes of either START NOW (v1) or START DELAYED(V2):
a) define whether update task triggered immediately
b) combine synchronous and asynchronous updates
c) assign different priorities
d) take different speed of servers into account
e) enable reaction to termination n V1
15) Relationship between SAP transactions and database transactions:
a) each SAP corresponds to one database
b) update requests of one SAP transaction are distributed amongst several database transactions
c) one database group change request of several SAP
d) database transaction is an internal system representation of SAP transactions
Answers:
1) b, c, d
2) b, d
3) a, c
4) b, c, d
5) a, c, d
6) a, d
7) a, c, e
8) b, c, e
9) a, c, d
10) c
11) a
12) a, d, e
13) c
14) c
15) b
ABAP Objective Questions
By: Rajendra Rai (raaz.rai.sap@gmail.com) SAP ABAP Consultant
1 Full Buffering would be appropriate for
A. Transaction Tables
B. Small Static tables
C. Internal Tables
D. Tables with generic Keys
2 What is the basic object of data Dictionary
A. Domains
B. Documentation
C. Data Models
D. Dynpro
3 Search help can not be attach to:
A. Domain
B. field of a table
C. check table
D. Type
4 Sub query usually more efficient because:
A. data is filtered in the database
D. Presentation server is a set of executables that collectively interpret the ABAP/4 Programs and manage
the input & output for them.
14.What is the difference between Synchronous and Asynchronous updates? (Multiple Answer)
A. In synchronous processing, the program waits: control returns to the program only when the task has
been completed.
B. In asynchronous processing, the program does not wait: the system returns control after merely logging
the request for execution.
C. In asynchronous processing, the program waits: control returns to the program only when the task has
been completed.
D. In synchronous processing, the program does not wait: the system returns control after merely logging
the request for execution.
15.What are the main events an interactive report have? (Multiple Answer)
A. Top-of-page during line selection.
B. At line-selection.
C. At user-command.
D. AT New
16.How many types of tables exist in data dictionary? (Multiple Answer)
A. Transparent tables
B. Internal Table
C. Pool tables
D. Hash Table
E. Cluster tables
F. Master Data Table
17. What is the difference between UPLOAD and WS_UPLOAD? (Multiple Answer)
A. WS_UPLOAD - File transfer with dialog from presentation server file to internal table. Data which is
available in a file on the presentation server is transferred in an internal table. ASCII & Binary files can be
transferred.
B. UPLOAD - To read data from the presentation server into an internal table without a user dialog, use the
function module WS_UPLOAD. The most important parameters are listed below.
C. UPLOAD - File transfer with dialog from presentation server file to internal table. Data which is available
in a file on the presentation server is transferred in an internal table. ASCII & Binary files can be transferred.
D.WS_UPLOAD - To read data from the presentation server into an internal table without a user dialog, use
the function module WS_UPLOAD. The most important parameters are listed below.
18.Is Session Method, Asynchronous or Synchronous?
A. Asynchronous
B. Synchronous
C. Synchronous and Asynchronous
D. None of above
19. What are the differences between SAP memory and ABAP memory? (Multiple Answer)
A. SAP Memory is a memory area in the internal session (roll area) of an ABAP program. Data within this
area is retained within a sequence of program calls, allowing you to pass data between programs that call
one another. It is also possible to pass data between sessions using SAP Memory.
B. ABAP Memory is a memory area to which all sessions within a SAPgui have access. You can use SAP
memory either to pass data from one program to another within a session (as with ABAP memory) or to pass
data from one session to another.
C.ABAP Memory is a memory area in the internal session (roll area) of an ABAP program. Data within this
area is retained within a sequence of program calls, allowing you to pass data between programs that call
one another. It is also possible to pass data between sessions using SAP Memory.
D.SAP Memory is a memory area to which all sessions within a SAPgui have access. You can use SAP
memory either to pass data from one program to another within a session (as with ABAP memory) or to pass
data from one session to another.
ANSWERS:1. B
2. A
3. D
4. A
5. C
6. C
7. D
8. C
9. B
10. A
11. A
12. A,B
13. C,B
14. A,B
15. A,B,C
16. A,C,E
17. C,D
18. B
19. C,D
20. C
ABAP Interview Questions
What is a 'Z' report?
Y or Z report refer to customized abap programs written for modules such as mm, sd, pp or fi/co etc.
Can we create an ABAP program without using Y or Z?
No, this is because all non Yor Z programs are standard SAP programs.
1. How data is stored in cluster table?
Each field of cluster table behaves as tables which contains the no. of entries.
2. What are client dependant objects in abap/sap?
SAP Script layout, text element, and some DDIC objects.
3. On which even we can validate the input fields in module progams?
In PAI (Write field statement on field you want to validate, if you want to validate group of fields put in chain
and End chain statement.)
4. In selection screen I have three fields, plant mat no and material group. If I input plant how do I get
the mat no and material group based on plant dynamically?
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MATERIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' to get material and material group for the plant.
5. How do you get output from IDOC?
Data in IDOc is stored in segments, the output from Idoc is obtained by reading the data stored in its
respective segments.
6. When top of the page event is triggered?
After excuteing first write statement in start-of-selection event.
63. Is it possible to run host command from SAP environment? How do you run?
64. What kind of financial periods exist in SAP? What is the relavent table for that?
65. Does SAP handle multiple currencies? Multiple languages?
ans:Yes.
66. What is a currency factoring technique?
67. How do you document ABAP/4 programs? Do you use program documentation menu option?
68. What is SAPscript and layout set?
ans:The tool which is used to create layout set is called SAPscript. Layout set is a design document.
69. What are the ABAP/4 commands that link to a layout set?
ans:control commands,system commands,
70. What is output determination?
71. What are IDOCs?
ans:IDOCs are intermediate documents to hold the messages as a container.
72. What are screen painter? menu painter? Gui status? ..etc.
ans:dynpro - flow logic + screens.
menu painter GUI Status - It is subset of the interface elements(title bar,menu bar,standard tool bar,push buttons) used for
a certain screen.
The status comprises those elements that are currently needed by the transaction.
73. What is screen flow logic? What are the sections in it? Explain PAI and PBO.
ans:The control statements that control the screen flow.
PBO - This event is triggered before the screen is displayed.
PAI - This event is responsible for processing of screen after the user enters the data and clicks the
pushbutton.
74. Overall how do you write transaction programs in SAP?
ans:Create program-SE93-create transcode-Run it from command field.
75. Does SAP has a GUI screen painter or not? If yes what operating systems is it available on?
What is the other type of screen painter called?
76. What are step loops? How do you program pagedown pageup in step loops?
ans:step loops are repeated blocks of field in a screen.
77. Is ABAP a GUI language?
ANS:Yes.
ABAP IS AN EVENT DRIVEN LANGUAGE.
78. Normally how many and what files get created when a transaction program is written?
What is the XXXXXTOP program?
ans:ABAP/4 program.
DYNPRO
79. What are the include programs?
ANS:When the same sequence of statements in several programs are to be written repeadly they are coded in
include programs (External programs) and are included in ABAP/4 programs.
80. Can you call a subroutine of one program from another program?
ans:- Yes- only external subroutines Using 'SUBMIT' statement.
81. What are user exits? What is involved in writing them? What precations are needed?
82. What are RFCs? How do you write RFCs on SAP side?
83. What are the general naming conventions of ABAP programs?
ANS:Should start with Y or Z.
84. How do you find if a logical database exists for your program requrements?
ans:SLDB-F4.
85. How do you find the tables to report from when the user just tell you the transaction he uses?
And all the underlying data is from SAP structures?
ans:Transcode is entered in command field to open the table.Utilities-Table contents-display.
86. How do you find the menu path for a given transaction in SAP?
ans:87. What are the different modules of SAP?
ans:FI,CO,SD,MM,PP,HR.
89. How do you get help in ABAP?
ans:HELP-SAP LIBRARY,by pressing F1 on a keyword.
90. What are different ABAP/4 editors? What are the differences?
ans:91. What are the different elements in layout sets?
ans:PAGES,Page windows,Header,Paragraph,Character String,Windows.
92. Can you use if then else, perform ..etc statements in sap script?
ans:yes.
93. What type of variables normally used in sap script to output data?
94. How do you number pages in sapscript layout outputs?
We can create a internal table like 'bsgmcgcoll'. All the messages will go to internal table. We can get errors
in this internal table.
Below messages are go to internal table. when you run the call transaction.
- Message type
- Message id
- Message Number
- Variable1
- Variable2
- Variable3
9) Among the Call Transaction and Session Method, which is faster?
Call transaction is faster then session method. But usually we use session method in real time...because we
can transfer large amount of data from internal table to database and if any errors in a session. Process will
not complete until session get correct.
10) What are the difference between Interactive and
Drill Down Reports?
ABAP/4 provides some interactive events on lists such as AT LINE-SELECTION (double click) or AT USERCOMMAND (pressing a button). You can use these events to move through layers of information about
individual items in a list.
Drill down report is nothing but interactive report...drilldown means above paragraph only.
11) How to pass the variables to forms?
12) What is the table, which contain the details of all the name of the programs and forms?
Table contains vertical and horizontal lines. We can store the data in table as blocks. We can scroll depends
upon your wish. And these all are stored in database (data dictionary).
Which contain the details of all the name of the programs and forms? (I don't know).
13) How did you test the form u developed? How did you taken print?
14) What are Standard Texts?
16) What is the difference between Clustered Tables and Pooled Tables?
A pooled table is used to combine several logical tables in the ABAP/4 dictionary. Pooled tables are logical
tables that must be assigned to a table pool when they are defined.
Cluster table are logical tables that must be assigned to a table cluster when they are defined.
Cluster table can be used to store control data they can also used to store temporary data or text such as
documentation.
17) What is pf-status?
Pf status is used in interactive report for enhancing the functionality. If we go to se41, we can get menus,
items and different function keys, which we are using for secondary list in interactive report.
fields of the cluster tables for this key. If the data does not fit into the long field, continuation records are
created. Control information on the structure of the data string is still written at the beginning of the Vardata
field.
6) Hashed tables
This is the most appropriate type for any table where the main operation is key access. You cannot access a
hashed table using its index. The response time for key access remains constant, regardless of the number
of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if
you want to construct and use an internal table which resembles a database table or for processing large
amounts of data.
Sample Prog: This does nothing.
REPORT Z_1 .
tables: mara.
data: i type hashed table of mara with unique key matnr
7) and 8) ABAP objects are root for your program and reports.
RFC Vs BAPI
BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You
create business objects and those are then registered in your BOR (Business Object Repository) which can
be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA.
In this case you only specify the business object and its method from external system in BAPI there is no
direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used
for most SAP business object types. These BAPIs should be implemented the same for all business object
types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different
BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI. It is not
possible to connect SAP to Non-SAP systems to retrieve data using RFC alone. RFC can acces the SAP
from outside only through BAPI and same is for vice versa access.
RFC is the protocol used by SAP for remote communication, that is, for communications between remote
(independent) systems. RFC is used for communications between two independent SAP systems, or for
communications between an SAP system and a non-SAP system, such as an external application. It can
also be used for communications between modules on the same system. Using the RFC interfaces you can
extend the functionality of R/3 applications from an external program.
What is the different btween clear and refresh?
There are 2 types of clear statements we can use:
Clear ITAB : This Statement will clear the Internal Table Header content.
To clear the Intertal Table Hearder as well Body we can use Clear ITAB [ ] statement.
Refresh will deletes the Internal Table content but still memory is not freed.
What is the pick statment do?
Pick Statemnt will captures the UserAction.
Eg: if SY-UCOMM = 'X'.
This type of user actions can be captured thru PICK Statement only.
What is the different between sesstion method and call transaction method and suppose I used one
method to transform the data next time suppose I want transform the data which method I can use.
There are many difference between Session method and Call Transaction.
Which method we have to use will be found based on Volume Of data and Accuracy of data given. Mainly
Call Transaction used for small sets of data because in Call Transaction we have to Handle the Processing
compulsory
labels are used
not generated
1) The revelant table and fields are stipulated in matchcode object. A matchcode object describes the set of
all possible search paths for a search item.
2) One or more matchcode ID can be defined for a matchcode object. A matchcode ID describes a special
search path for a search term.The fields or combination of fields via which the search is to take place is
defined in the matchcode ID.
Important ABAP FAQ's
How to execute a program step by step on the abap editor?
This is known as Testing and Debugging ABAP Codes, Functions
What are dml statements in sap?
Ans: Insert, Update, Delete.
What is the difference between open sql & native sql?
Ans: Open SQL allows you to access all database tables known to the SAP system, regardless of the
database manufacturer. Sometimes, however, we may want to use database-specific SQL statements called
Native SQL in your ABAP/4 program.
To avoid incompatibilities between different database tables and also to make ABAP/4 programs
independent of the database system in use, SAP has created a set of separate SQL statements called Open
SQL. Open SQL contains a subset of standard SQL statements as well as some enhancements which are
specific to SAP.
A database interface translates SAP's Open SQL statements into SQL commands specific to the database in
use. Native SQL statements access the database directly
What is Primary key, foreign key ? what is primary index? secondary index?
Ans: Primary index: the primary index contains key fiels of a table and a pointer to non-key fields of the
table. The primary index is created automatically when a table is created in database and moreover you can
further define reference to the primary index which are known as Secondary index.
How many indexes can be created for a table?
Ans: 9.
What is data class?
Ans: The data class specifies in which table space the table is created in database.
Give few names of cluster tables in sap?
Ans: sorry i dont know
Give few names of pooled tables in sap?
Ans: A pool table has many to one relation with the table in the database. For one table in the database
there are many tables in the dictionary. Tha table in the database has a diff name than in the table in the
data dict, it has diff no of fields and field names are different. A pooled table is stored in the pool at the
database level. A table pool is a databse table with a special struct that enables the data of many R3 tables
to be stored in it. It can hold only pooled tables.
Sorry I dont know table names
Give few names of transparent tables?
Ans: A transparent table has a one to one relataionship in the database. The table in the dictionary has the
same name, same no of fields, and the fields have the same name as in the R3 table defn. A transparent
tabel has application data (Master and Transaction). sorry i dont know table names
What is a buffer and how many types?
Ans: Buffer is othing but which stores data temporarily. there are two types of buffers. they are Roll and
Page areas.
Pages : it stores the application data.
Roll area: it stores the data of previous pages.Data areas of used programs are created in roll areas for
each internal session.
What is table maintenance generator and how to create that? What is the transaction code?
Ans: Table maintanence generator is nothing but making a table available for adding records and deleting
records.
The transaction code used is SM30.
How to add new fields to a standard sap table?
Ans: 1. Appended structures
2. Customizing tables
When using CALL 'SYSTEM' id 'COMMAND' field unix-command, how does one capture the results
of the command? For example, if the unix-command were the date?
You capture the results in the table e.g TABL, like this
DATA: BEGIN OF TABL OCCURS 0,
LINE(560),
END OF TABL.
REFRESH TABL.
CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC
ID 'TAB' FIELD TABL-*SYS*.
I am working on a program that needs to show number of days between 2 dates. When I scanned the
function library, I only found a function to give you the number of years between dates. I can
probably code this in ABAP but does anyone know if a function exists to do this.
I wrote this example for you. I think this is what you need.
Has anyone been successful in suppressing the selection screen that is automatically displayed
when using logical data bases. I want to run a job in the background using a logical database and I
do not want the user prompted for the parameters. I want to pass the parameters in the program.
Try using the SUBMIT rep USING SELECTION-SET 'variant' WITH ....
command in the report to pass the variant thru the program
I would like to know how to execute from ABAP code an external Unix program and check for a
return code?
There are different ways to this:
(1) OPEN DATASET <file> FOR OUTPUT 'unix command'
CLOSE DATASET <file>
This command executes the unix command and writes the output into <file>
Look into OSS Note 9391.
(2) or try the following program but unfortunately the command CALL SYSTEM is
not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
REPORT ZUNIXCOM .
DATA: U_COMMAND(200).
* Table for system messages
DATA: BEGIN OF RT OCCURS 100 ,
LINE(100) ,
END OF RT .
START-OF-SELECTION .
MOVE 'unix command' to U_COMMAND .
REFRESH RT.
CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
ID 'TAB' FIELD RT-*SYS* .
LOOP AT RT.
WRITE : / RT-LINE .
ENDLOOP.
ABAP Frequently Asked Question
ABAP/4
Q: When we create a customer the information is updated in structure RF02D and the some tables like
KNA1 are updated. How can we find the tables for master data transactions?
A: Go to ABAP Workbench -> Overview -> application hierarchy - SAP -> follow the customizing based tree
for your application. Double click on a lowest hierarchy level to get for the correct marked development
class. Here you can find all the tables, views, logical databases etc. used for a system operation.
RFC
Q: We want to move a SAP table to an Access table using TABLE_EXPORT_TO_MSACCESS_RFC
Importing parameters are
DBNAME
DEST
FLG_APPEND
FLG_POPUP
LANGU
The table has three columns:
TABNAM
MANDT
SDATA
We have no Exporting parameters.
How shall we set the parameters?
A: Install the PS utilities, which are part of SAPGUI install CD. You may run report RIACCESS from SE38.
Go to SALE -> Communication -> Define RFC Destination. Setup two RFC destinations PS_ACCESS_1 and
PS_ACCESS_2 and will have to get them to point to wdpsastr.exe and wdpsatab.exe respectively. Then
execute RIACCESS and choose PS_ACCESS_1 to generate access tables. Please note that Access only
supports tables with up 255 fields.
Q: We want an RFC do the following transactions - MB1A, MB1C,>MB01 (goods receipt/issue).
A: Call the RFC INBOUND_IDOC_PROCESS with IDOC_CONTROL and IDOC_DATA. The structure in the
field sdata in the IDOC_DATA are e1mbxyh and e1mbxyi.
Transports
Q: In a Dev instance, we want to transport a modification to a layout set from one client to another. What is
the best way?
A: use transaction SE71. Choose Utilities->Copy from Client. Layout sets need not be transported between
clients , via transport requests DEVKxxxxxx.
Q: We need to keep track of the transports that need to flow through to other systems (ie, DEV, TST, TRN,
PRD etc). Is there a way do this?
A: SAPCRAFT enables you to control the CTS from DEV system. This keeps track of all transports at all
stages and enables you to allocate Import, export and Authorization functions to specific user.
E D I / IDOC
Q:1 We created an EDI Vendor and created all required output conditions. However no IDOC is generated
when PO is printed. Why?
A: Go to Header->output for the PO. The output type shall be '6'. The status shall be '1'. If the status is '0'
check the timing. If the status is '2' , go to 'GOTO->Processing Log' and the explanation for non-generation
of IDOC can be seen.
Q: How can we create / upload IDOC's from legacy system to SAP?
A: Third party tool Mercator may be used to convert Legacy files to Idoc format. Mercator provides an IDOC
tree import facility, SAP provides the export facility. You can transfer the Idoc layouts from SAP to Mercator
automatically and then map.
Q: We want to receive an outbound EDI 855 IDOC only if E2EDP20 -scheduling confirmation segment is
present. Else get an "error" status preventing triggering the EDI subsystem.
A: User exit logic has to be added in function IDOC_INPUT_ORDRSP.
# Set up a test flag and set it off when the IDOC header is read.
# Turn the flag ON when the EDP20 segment is read.
# Interrogate this flag when the next segment after EDP20 in the same IDOC comes in. If it is on ,you have
an EDP20 coming in.
# Issue an error status 51 with suitable message for whichever condition you don't want the IDOC to be
processed, This will stop the IDOC from posting.
Q: Where ever PO is sent to the vendor via EDI, we want an acknowledgement of the PO by vendor. Which
fields are updated and what should be my procedure?
A: Execute Program: IDOC_INPUT_ORDRSP
Process code: ORDR
Message type: ORDRSP
IDOC: ORDERS01
The confirmation process allows the supplier to return an acknowledgment. Only Dates and quantities can
be changed The information is stored in the PO and can be viewed via Item->Confirmation->Overview. The
PO can be flagged as 'confirmation required' so that Pos without acknowledgement receipt can be
monitored. Control keys and tolerances (days and quantities) have to be customized.
ALE
Q: Our IDOC remains in status 51 ( not posted) while testing ALE setup by passing DEBMAS02 Idocs. The
message 'Field KNA1-BRSCH is not an input field'. This is the Industry key. What are we missing?
A: Go to IMG - menu path IMG->LogisticsGeneral-> Logistics Basic Data: Business partners->Customers->
Control->Define Account groups and field selection for customer.
Select sold-to or ship-to. Select General Data. Select control and double click. Industry key is found here.
Change the option to 'Optional Entry'.
Check OSS 5599. You may have to update view V_T078D also.
Handling Tables
Q: We specify the logical database. And we want a field that is not present in any of the tables defaulted in
logical database. How can we want to add this additional field from a different table?
A: . Presume you have a
logical database
table 1
table 2
table 3
Define the required field as additional field say fld of table 1, table 2 or table 3
and then in the code section define.
Perform get_f1d(zxxxxxxx) using f1d.
Form zxxxxxxx could be like;
Form get_f1d using f.
Select * from where 'conditions'
f = table4 - f1d.
Q: We need to download an internal table to the Presentation Server(local workstation). Whenever we run
the program, the same file has to be saved as a separate file in sequential order. Ex: 0001.txt, 0002.txt etc.
Where can we store the last file number?
A: SAP has a table TVARV for storing the variants.
A record may be created in TVARV for all the programs that require this kind of incremental records.
For Ex: the record could be 100Zmm10001 MM sequence rec where first part consists of client code and the
program being run. Client code is required because TVARV does not has a field for client code. The second
part is the description indicating the purpose what the record is created. This entire string may be posted in
the Name field (char - 30).
The Type field ( char- 1) may be populated with P or S (Parameter or Selection)
Low field (char- 45) may be populated with '0001' when run first time and increment it by one in your
program for downloading of the internal table.
Others
Q: How can we use CAD with SAP ?
A: Third party tools from Eigner + Partner provide interfaces to SAP. Another third party software - Fastlook
Plus from Kamel Software enables you to view all of the Autocad formats.
**********
When you delete an entry from an internal table in ABAP, the system has to re-generate the index for all
entries after your delete, slowing the report if you have many records to eliminate.
It is much quicker to do an insert of the correct records into a second table than to delete entries from the
first. The reason for this is because the index is only generated for the newest element.
**********
If you want to protect a program against debugging, you just have to set the STATUS = S in the attributes
view of the main program.
**********
BDC.
When You use a call transaction ,and populate the BDCDATA table.
Make sure you pass the "DATE FIELDS" of any transaction by formatting it as "XX/XX/YYYY" cos if you
pick this data from database it will be of the format 20030505 or something like that. Make sure You pass
this value as character field.
Same is true for the "Rate Fields". Make sure you pass them as "Character Fields" by formatting them.
**********
If you need to find out the Okcodes for BDC sessions, look for program RSBDCCUA and run it for any
platform say 'WN' for windows or MC for Mac and it will generate list of function codes
**********
To save the contents of an internal table as a Microsoft Excel Worksheet when debugging code in SAP R/3
Enterprise:
1. Click on the "Table" button
2. Type in the name of your internal table in the "Internal table" field and hit Enter.
3. Hit CTRL + F11 or click on the "Save as Excel Worksheet" button.
4. Type in the record numbers that you want to save. (Ex. From Line: 1 To Line: 10) Hit Enter.
5. Save your file.
**********
Starts with a Z is homegrown program
You cannot be sure that anything which starts with a Z is a homegrown program.
SAP provide a number of correction programs, especially within the archiving area, which start with a Z.
For e.g. ZZSTOCKL from note 202345.
**********
Can line-size of abap report large than 255?
You can have line-size upto 1023.
Along with Report statement pass the line-size as 1023. Ex. Report xyz line-size 1023.
**********
How to find out the number of days between a given date, excluding Saturdays and Sundays and
public holidays?
Try functions,
=> DATE_CONVERT_TO_FACTORYDATE
=> HR_HK_DIFF_BT_2_DATES
Create Own Transaction Using SE93
What is SE93 and why we use this transaction?
By: Mrunalini
SE93 is to Maintain Transaction Codes.
If we develop some Module pool programs or Report Programs, to make these programs available to the
end users, we create transaction codes for these programes.
For performing any kind of task in the SAP R/3 ERP system, a transaction is used. SAP provides a standard
set of transactions to manipulate i.e insert, update, delete and display data in the system. But sometimes,
the need to create a customer specific transaction may arise due to the following reasons
--> Standard SAP may not support that task.
--> A particular transaction needs to be customized to suit the customer requirements.
A transaction is defined as a sequence of dynpros (sap term for screens) having input and output fields and
corresponding processing logic behind them to perform a particular task.
So we create a transaction in SE93.
We call an execution of an ABAP program using a transaction code a transaction . There are dialog , report,
parameter, variant, and - as of Release 6.10 - OO transactions. A transaction is started by entering the
transaction code in the input field on the standard toolbar or by means of the ABAP statements CALL
TRANSACTION or LEAVE TO TRANSACTION. Transaction codes can also be linked to screen elements or
menu entries. Selecting such an element will start the transaction.
How can we create TCODE for Table Maintenance Generator(TMG)?
Check following steps,
1. Transaction: SE93
2. Enter Short Text
3. Select Radio button "Transaction with Parameters (Parameter Transaction)"
4. Next screen, give transaction as SM30
5. Check "Skip Initial Screen"
6. Under Default Values tab give two rows
a. VIEWNAME for screen field and <your table name> for value
b. UPDATE for screen and 'X' as value
7. Save and Execute.
What The Differences Between ABAP and HR-ABAP
The ABAP HR is an integral part of ABAP. Generally in ABAP the following are done:
1)
2)
3)
4)
Table development
Date Processin
Reprt developing
BAPIs /RFC s
5)
6)
7)
8)
9)
This is basically done through the PROGRAMMING in ABAP builder by using ABAP 4th generation languge.
This may be related to any module of my SAP ERP 2004 like HR, FICO.SD,MM,CRM Etc.,
Now when it is said ABAP HR. It is the development of ABAP in the area of HR to meet the clients
requirements according to the functional specifications .They may be in any area of HR like in the areas of
time aspects ,pay aspects, OM aspects and Self Services like E-recruitment, ESS etc.,
One example of ABAP PROGRAMME related to HR is given below.
Report: ZP_POSTCODE: This report has been developed by the ABAPER in the area of SAP HR to Display
report of employees by postcode that includes current traveling allowances (i.e. parking, permit or transport
card etc.)
*:.....................................................................:
:
*: Use: Help encourage the use of car sharing and public
* transport wherever it appropriate (this is the functional requirement of the client or the functional
specification
* (which is given by the functional consultants)
:
*:.....................................................................:
REPORT zp_postcode.
type-pools: slis.
"ALV Declarations
NODES: pernr.
INFOTYPES: 0000, 0001, 0002, 0006, 0008, 0014, 0105, 0121.
SELECTION-SCREEN BEGIN OF BLOCK pcode WITH FRAME TITLE text-s01.
SELECT-OPTIONS: so_pcode FOR p0006-pstlz.
SELECTION-SCREEN END OF BLOCK pcode.
TYPES: BEGIN OF t_output,
pernr
TYPE p0001-pernr, "personnel name
anredtxt TYPE t522t-atext, "title (based on p0002-anred)
fname
TYPE p0002-vorna, "first name
lname
TYPE p0002-nachn, "last name
orgtx
TYPE t527x-orgtx, "dept
fte
TYPE p0008-bsgrd, "fte
parking(20) TYPE c,
payslip TYPE t526-sachn,
"payslip address
telno
TYPE p0105-usrid_long, "tel number(p0105-usrty = 0020)
email
TYPE p0105-usrid_long, "email (p0105-usrty = MAIL)
postcode type p0006-pstlz,
END OF t_output.
DATA: it_output TYPE STANDARD TABLE OF t_output INITIAL SIZE 0,
wa_output TYPE t_output.
* Personnel number
wa_output-pernr = pernr-pernr.
* Personnel title
SELECT SINGLE atext
FROM t522t
INTO wa_output-anredtxt
WHERE sprsl EQ sy-langu AND
anred EQ p0002-anred.
* First name
wa_output-fname = p0002-vorna.
* Last name
wa_output-lname = p0002-nachn.
* Organizational Unit text (dept)
SELECT SINGLE orgtx
FROM t527x
INTO wa_output-orgtx
WHERE sprsl EQ sy-langu AND
orgeh EQ p0001-orgeh AND
endda GE sy-datum.
* FTE
wa_output-fte = p0008-bsgrd.
* Parking / travel deducted?
CASE p0014-lgart.
WHEN '7180' OR '7181' OR '7182'.
wa_output-parking = text-002.
WHEN '7183'.
wa_output-parking = text-001.
WHEN '7171' OR '7172' or '7173' or '7174' or
'7175' or '7176' or '7177' or '7178'.
wa_output-parking = text-003.
ENDCASE.
* Payslip Address
SELECT SINGLE sachn
FROM t526
INTO wa_output-payslip
WHERE werks EQ p0001-werks AND
sachx EQ p0001-sacha.
PROVIDE * from p0105 between pn-begda and pn-endda.
* Telephone numbers
if p0105-usrty = '0020'.
wa_output-telno = p0105-usrid_long.
endif.
* Email address
if p0105-usrty = 'MAIL'.
wa_output-email = p0105-usrid_long.
endif.
ENDPROVIDE.
append wa_output to it_output.
clear: wa_output.
************************************************************************
*END-OF-SELECTION.
END-OF-SELECTION.
describe table it_output lines gd_lines.
if gd_lines gt 0.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
else.
message i003(zp) with 'No records found'.
endif.
*&---------------------------------------------------------------------*
*&
Form PROGRESS_INDICATOR
*&---------------------------------------------------------------------*
*
Displays progress indicator on SAP screen
*----------------------------------------------------------------------*
form progress_indicator using p_text.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
*
PERCENTAGE = 0
text
= p_text.
endform.
" PROGRESS_INDICATOR
*&---------------------------------------------------------------------*
*&
Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*
Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
fieldcatalog-fieldname = 'PERNR'.
fieldcatalog-seltext_m = 'Personnel No.'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
* fieldcatalog-emphasize = 'X'.
* fieldcatalog-key
= 'X'.
* fieldcatalog-do_sum
= 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'ANREDTXT'.
fieldcatalog-seltext_m = 'Title'.
fieldcatalog-col_pos = 1.
*&---------------------------------------------------------------------*
*&
Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
*
Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
gd_layout-no_input
= 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text
= 'Totals'(201).
gd_layout-zebra
= 'X'.
endform.
" BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&
Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*
Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= gd_repid
is_layout
= gd_layout
it_fieldcat
= fieldcatalog[]
i_save
= 'X'
tables
t_outtab
= it_output
exceptions
program_error
=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.
endform.
" DISPLAY_ALV_REPORT
To conclude the message its always advantage to have a HR consultant who knows ABAP that is why this
ABAP HR Consultant are in high demand.
SAPScript Transaction codes
SE71 - Form painter
SE72 - Style maintenance
SE78 - SapScript Graphics Management
SO10 - Create standard text module
RSTXSCAT
- Find Styles
RSTXSF01
RSTXTCAT
Drawing a line. You can draw a line by setting the Height or Weidth to 0
and add a frane. E.g. a horizontal line:
/: SIZE HEIGHT '0' MM WIDTH '200' MM
/: BOX FRAME 10 TW XPOS '11.21' MM YPOS '14.81' MM INTENSITY 100
Example:
/: PRINT-CONTROL SESCP = *c5G
If you do not use the equals sign, a space character is inserted between the print control SESCP and the
character *c5G.
Different font on the same line
You can have different font on the same line by defining a character format.
For example B for bold text and U for Underline.
In your SAPScript apply like this :
<U>Underline Text</> <B>Bold Text</>
Print Footer notes only on the last page
Command to used in your sapscripts :/: IF &NEXTPAGE& EQ 0
whatever footer you want.
/: ENDIF
Orientations in SAPSCRIPT
-----Original Message----Subject: Orientations in SAPSCRIPT
From: Ashwini Jaokar
Hi,
I have 2 pages for a Form in SAPscript .
Can I have 2 different Orientations for 2 pages
Ie Can I assign Page1 as Portrait & page2 as Landscape ???
If so , How ????
Thanks in Advance.
Ashwini Jaokar.
-----Reply Message----Subject: Re: Orientations in SAPSCRIPT
From: jmersinger
Ashwini,
Not that I know of in the same layoutset...what you can do is create two layoutsets...one portrait, one
landscape...then in the print program call each one individually.
jjm
I have some doubs in BDC and SMART FORMS. I want to change the material number using the
transaction code MM02 through BDC.
In scripts and smartforms how to calculate totals and subtotals?
To calculate totals and sub totals in sap scripts you have to use subroutines.
Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is
picked write this routine
/: DEFINE &TOT_PRICE&
/: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT&
/:CHANGING &TOT_PRICE& /:ENDPERFORM
Then write the variable where ever you want it to be printed (mostly it will be in footer window)
Then create subroutine pool program and you have to write the code.
FORM F_GET_PRICE tables int_cond structure itcsy
outt_cond structure itcsy. data : value type kbert.
statics value1 type kbert.
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
I have given a rough outline, please be aware of the variable conversions as Int_cond-value and outt_condvalue are characters.
SAPScripts - Developing SAPScript in different languages
Developing SAPScript in different languages
You can goto transaction SE63 and translate the scripts into different languages.
In SE63, click Translation -> Long Texts -> Sapscripts -> Forms
Those language you can convert to have already been pre-installed in the system.
SE63 is the best way to translate since it offers check options.
However, it does not mean that it is 100% full proof that everything is correct
SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.
Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
It look exactly like what you see during a spool display.
Please note that it is not restricted to sapsciprts spool only. Any reports in the spool can be converted using
the program 'RSTXPDFT4'.
4. Press the IMPORT BUTTON (third button from left) and then IMPORT the BMP file from your DESKTOP
5. The code will be written automatically. You just need to drag and drop wherever you want
the graphics to be.
/: INCLUDE Z_COMPANY_LOGO OBJECT GRAPHICS ID BMON LANGUAGE EN
Please note that in 4.6c onwards, you can also used Windows Bitmap file ( .BMP).
Import/Export SapScript form from PC file
How do you backup sapscript layout sets? Can you download and upload? How?
Use ABAP program: RSTXSCRP
It will download and upload your sapscripts as a text file in your local harddisk.
I want to copy SAP Script from one client (512) to client (500). How can I copy this SAP Script.
Login to Client (512)
Goto SE38 or SA38 and execute the abap program: RSTXSCRP
Mode : EXPORT
Login to Client (500)
Goto SE38 or SA38 and execute the abap program: RSTXSCRP
Mode : IMPORT
or
Login to Client (500)
Goto SE71 - Click Utilities - Copy from client
Is there a way that I can find where used list of a SAP Script?
I need to find the program that calls the particular form.
Solution:
Where used list for a sapscript would be difficult in cases where the script is called dynamically.
There is no way of finding the program name of SAP Script.
But you can get the program names from table TNAPR by passing the SAP Script name.
In cases where the script is configured via customising, then you can check it in TNAPR table by putting it in
FONAM field.
or
Also there is one more way of finding the Print Program Name for the specified Script.
Just Goto transaction SE71
--> Enter Form Name --> Display --> In Menu --> Form --> Check --> Texts --> Select Include Res --> Click
on click
This will give you the print program list for the specified SAP Script.
Also you can get the program name from NACE transaction.
Picture doesn't show in Print Preview
You have uploaded the picture as .TIF in Sap using ABAP RSTXLDMC and have also add the statement
/: INCLUDE ZHEX-SAMPLE-PICTURE OBJECT TEXT ID ST LANGUAGE EN
in your SapScript but the problem is that in print preview it's not displaying the picture.
It is normal that the picture doesn't show in print preview and you will be able to see the object only after
printing.
Don't let this bother you as long as the picture is shown on the hardcopy printout.
Delete Load program for SAPScript
Occassionally, when you make frequent changes to your SAPScript, the system can get out of sync.
When you view the form, the old data get display without your changes.
This can be fixed by deleting the SAPScript LOAD with program RSTXDELL.
or write your own ABAP Dialog programs that will fit onto a barcode enabled wireless handheld terminal and
that will follow the business logic as executed on the shop floor.
These programs are highly complex exercises in industrial engineering and ergonomics because of the
limited screen sizes and limited ability to accept keyboard input. The user is instructed step-by-step and only
scan and push F-keys to interact with the SAP system. Scan, scan, beep, beep, enter - highly automated.
SapScript Question
1) How do you backup script layout sets?
2) What type of variables normally used in script to o/p data?
3) How do you use tabsets in layouts?
1) Use this Std program RSTXSCRP.
1) First Export to Presentation file(.doc).
2) Whenever you need that Export into SAP.
2) Normally we call them as Program symbols. Those are defined in Driver program. We can use in Script
as for exp. &itab-matnr&
Other variables ---System symbols : ex &page&
---Std symbols :
---Text symbols :We define them in script editor itself.
Ex : /: Define &mysymbol& = 'XX'
3) We can control the tab feed in a paragraph with tab positions. The tab stops us define in the paragraph
format replace the tab spacing we defined in the header data of the form. However, this depends on the
extent to which we have defined tab stops in the paragraph format. If there are fewer tabs in the paragraph
formats than in the header data, the tab stops of the header data are used for the rest of the line.
SAPscripts Tips by : Venkat O
Q: We get the total number of pages as expected by using 'SAPSCRIPT-FORMPAGES' in a duplex
layout. In our case duplex case is always 'Terms & Conditions'. We do not want the number of pages
as in duplex printing. What is the best possible solution?
A: On the Terms & Conditions page, Change the Page counter mode to 'HOLD' to keep the page counter
from incrementing when you print the Term & Conditions.
Q: Can I Print a logo on an Invoice?
A: Save a Logo using Paintshop Pro or Corel Draw as Tiff file. Use RSTXLDMC to convert the logo to
standard text in SapScript. When the program is executed, the path and file name have to be correctly
specified.
Process could be like the following:
Run RSTXLDMC
Enter file name C:\MAIL\COMPLOGO.TIF
Resolution for Tiff file
Absolute X-position
Absolute Y-position
Absolute positioning
Reserved height
Shift to right
UOM = CM
Text title
Line width for text = 132
Text name ZHEX-MACRO-COMPLOGO
Text ID ST
Text language = E
Postscript scaling
Width & Height according to PS scaling
Number of Tiff gray levels (2,4,9) 2
Then Create a new window 'COMP' with attributes;
Window COMP description Company Logo
Window type CONST
Left margin 7.00 CH window width 10.00 CH
Upper margin LN window height 8.00 LN
Finally in the text element , mention
/: INCLUDE 'ZHEX-MACRO-COMPLOGO' OBJECT TEXT ID ST LANGUAGE 'E'.
Please note that if object name is not indicated as 'ZHEX...', the logo may not be printed!
You will not be able to see the logo in a test print. The same will be printed in actual printout.
If you are using two logos in the same layout, the names of the logos should be unique. Say 'ZHEXMACRO-LOGO1' and 'ZHEX-MACRO-LOGO2'. Else all the information will be overwritten.
If the logo is not EXACTLY TIFF 6.0, the same will not be printed.
What is the difference between a script & a report ?
Script is a form which has a layout set as per the company standards and can be used for external use too.
Generally reports are designed for internal use for in house users
What are the components/elements/layout sets in sap script ?
Layout set and Print program and the layout set has windows in it.
Components of scripts:
Layout sets, SAPScripts text, ABAP print program, symbols, function module like open form, start form, write
form, etc....
Layout sets of scripts are:
Header data, paragraph formats, charcter formats, windows, page windows, pages.
Can you create a script with out a main window ?
No
How many main windows can be created for a script ?
99
How can we use tables in sap scripts?
We can access structures and the tables tat are updated during runtime. Else you have to pass the structure
values to the table in the print program.
How to print a logo in a sap script?
Upolad in the R3 using Se78 and use the Include statement in the script.
When we need to modify standard scripts (eg:medruck) given by sap?
When the client goes for customization of the form
What is the use of transaction code NACE in sap scripts?
You can track the form and the print program used for that form
What is the table name that will contain all the script form names and print program names?
TNAPR
Can you assign your own form to a standard print program? how?
Yes. thru NACE
What is the use of PROTECT & ENDPROTECT?
Keeps the block of text in the same page.
How to add extra functionality to a standard print program with out touching the print program?
Thru subroutine programs
What is sub routine pool in sap script? when it is used?
Its an Abap prog of type sub routine pool, it is used for calculating certain variables, eg DUE date for an
Invoice. You pass the values from the form thru ITCSY structure intot he prgram.
How to read text in sapscripts?
SO10
What is the difference between paragraph & character format?
Self explanatory definition
How to use a sapscript for multiple languages ?
(english, germany etc) Copy the script in each lang or you have an option to click 'TO all Languages'
How to download/upload sapscripts from & to your PC ?
SE78 or RSTXLDMC
What is the difference between scripts & smart forms?
Scripts are client-dependent but SF are client Independent
Sapscripts and abap programs are client dependent or not? Why?
Scripts are client dependent. / Reports are client Independent.
What is the transaction code for logo uploading?
SE78
What is the standard program used for uploading the logo to script?
RSTXLDMC FM to upload image in tiff format.
How can you send forms from one client to other?
SE71, Utilities -> Copy from client...
What does open_form, write_form, close_form do?
Again its self-explanatory
What is the diffrence between open_form and close_form?
open_form is used to open the form/initiate the form.
close_form is used to conclude the open_form.
How to convert a sapscript to smart form?
tcode SMARTFORMS, I think its menu Utilities you have an option.. Migrate Scripts to Smartforms.
How to send a smartform result through mail?
I think you have to configure the output type. Not sure..
How to select desired paper size in sapscript?
In Basic settings.
How to print the Page Nos in Forms. Every page I want to print 1 of 10 , 2 of 10 , 3 of 0 ...etc.
PAGE &PAGE& OF &SAPSCRIPT-FORMPAGES& *-- Nitin
How to debugg a script?
This can done in two ways:
In the form Utilities->debugger / RSTXDBUG FM for debugging script
The Procedure for debugging SAP script is:
Generally SAP script contains the Layout and corresponding print program.
First go to SE71 and enter ur script name. In the same screen go to Utilities->click on activate debugger
option.
Now go to SE 38 and enter ur Print Program name and execute the program.
Now you can debug the script Page wise and window wise.
Questions on PO SapScripts MEDRUCK
1. When do you modified MEDRUCK? ( IF I SAID I HAVE WORKED ON SCRIPTS).
Generally, we modify existing sap scripts provided by SAP rather than creating one. Unless you have to do
something new for your client like Labels or Packaging card, etc., MEDRUCK is the form for PO.
2. I want to know the procedure to create a purchase order using MEDRUCK.
You don't create a PO using MEDRUCK. MEDRUCK is the form used to print a PO that has been created.
3. What are the usual changes to be done on MEDRUCK?
Goto SE71, there is an option in Utilities as COPY ffrom Source client (000). Copy the from MEDRUCK into
a Zname form. The common changes wud b inserting a logo, using Std text for Terms and Conditions,
alignment of windows as per client requirement, get xtra data if client is asking for somethign more.
4. How can I access my data from DB to SCRIPTS?
There are structures used in Scripts which hold the data entered by the user. These structures are used to
get data from Database.
5. Please send me the one examples in full length.
Look at MEDRUCK form and it would have a print program. you can find in tcode NACE.
Create Scripts Of Your Own Using Standard Scripts
The folloiwng info may be useful for those who are new to SAP:
All Standard Scripts are in client '000'.
We have to copy them to '800'. (this is your own company define client no)
All Standard Scripts and their respective print programs are listed in table 'TNAPR'.
Ex: FORM MEDRUCK has the Driver Program SAPFM06P.
NOTE: Never make any changes to the Standard Driver Programs
STEP 1.
---------Goto Transaction Code <SE71> and
select from Menu UTILITIES ->Copy from Client.
Enter the Standard Form Name, It source Client 000 and the target Form Name that you want it to be saved
as on your client.
UNCLOSED
=5
MAIL_OPTIONS
=6
ARCHIVE_ERROR
=7
INVALID_FAX_NUMBER
=8
MORE_PARAMS_NEEDED_IN_BATCH
=9
SPOOL_ERROR
= 10
CODEPAGE
= 11
OTHERS
= 12
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'START_FORM'
EXPORTING
* ARCHIVE_INDEX
=
FORM
= 'ZFORM1'
* LANGUAGE
=''
* STARTPAGE
= 'X'
PROGRAM
= 'ZSCRIPT1'
* MAIL_APPL_OBJECT
=
* IMPORTING
* LANGUAGE
=
* EXCEPTIONS
* FORM
=1
* FORMAT
=2
* UNENDED
=3
* UNOPENED
=4
* UNUSED
=5
* SPOOL_ERROR
=6
* CODEPAGE
=7
* OTHERS
=8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
* ELEMENT
=''
* FUNCTION
= 'SET'
* TYPE
= 'BODY'
WINDOW
= 'HEADER'
* IMPORTING
* PENDING_LINES
=
EXCEPTIONS
ELEMENT
=1
FUNCTION
=2
TYPE
=3
UNOPENED
=4
UNSTARTED
=5
WINDOW
=6
BAD_PAGEFORMAT_FOR_PRINT
=7
SPOOL_ERROR
=8
OTHERS
=9
.
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
* ELEMENT
=''
* FUNCTION
= 'SET'
* TYPE
= 'BODY'
WINDOW
= 'MAIN'
* IMPORTING
* PENDING_LINES
=
EXCEPTIONS
ELEMENT
=1
FUNCTION
=2
TYPE
=3
UNOPENED
=4
UNSTARTED
=5
WINDOW
=6
BAD_PAGEFORMAT_FOR_PRINT
SPOOL_ERROR
=8
OTHERS
=9
.
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.
=7
=2
* CODEPAGE
* OTHERS
.
=4
=5
/E 102
P1 ,,&ITAB-ZCARTON_NO(R)&
Introduction to SAP SmartForms
What is SAP Smart Forms?
SAP Smart Forms is introduced in SAP Basis Release 4.6C as the tool for creating and maintaining forms.
SAP Smart Forms allow you to execute simple modifications to the form and in the form logic by using
simple graphical tools; in 90% of all cases, this won't include any programming effort. Thus, a power user
without any programming knowledge can
configure forms with data from an SAP System for the relevant business processes.
To print a form, you need a program for data retrieval and a Smart Form that contains the entire from logic.
As data retrieval and form logic are separated, you must only adapt the Smart Form if changes to the form
logic are necessary. The application program passes the data via a function module interface to the
Smart Form. When activating the Smart Form, the system automatically generates a function module.
At runtime, the system processes this function module.
You can insert static and dynamic tables. This includes line feeds in individual table cells, triggering events
for table headings and subtotals, and sorting data before output.
You can check individual nodes as well as the entire form and find any existing errors in the tree structure.
The data flow analysis checks whether all fields (variables) have a defined value at the moment they are
displayed.
SAP Smart Forms allow you to include graphics, which you can display either as part of the form or as
background graphics. You use background graphics to copy the layout of an existing (scanned) form or to
lend forms a company-specific look. During printout, you can suppress the background graphic, if desired.
SAP Smart Forms also support postage optimizing.
Also read SAP Note No. 168368 - Smart Forms: New form tool in Release 4.6C
What Transaction to start SAP Smart Forms?
Execute transaction SMARTFORMS to start SAP Smart Forms.
Key Benefits of SAP Smart Forms:
SAP Smart Forms allows you to reduce considerably the implementation costs of mySAP.com solutions
since forms can be adjusted in minimum time.
You design a form using the graphical Form Painter and the graphical Table Painter. The form logic is
represented by a hierarchy structure (tree structure) that consists of individual nodes, such as nodes for
global settings, nodes for texts, nodes for output tables, or nodes for graphics.
To make changes, use Drag & Drop, Copy & Paste, and select different attributes.
These actions do not include writing of coding lines or using a Script language.
Using your form description maintained in the Form Builder, Smart Forms generates a function module that
encapsulates layout, content and form logic. So you do not need a group of function modules to print
a form, but only one.
For Web publishing, the system provides a generated XML output of the processed form.
Smart Forms provides a data stream called XML for Smart Forms (XSF) to allow the use of 3rd party printing
tools. XSF passes form content from R/3 to an external product without passing any layout information about
the Smart Form.
Advantages of SAP Smart Forms
SAP Smart Forms have the following advantages:
1. The adaption of forms is supported to a large extent by graphic tools for layout and logic, so that no
programming knowledge is necessary (at least 90% of all adjustments). Therefore, power user forms can
also make configurations for your business processes with data from an SAP system. Consultants are only
required in special cases.
2. Displaying table structures (dynamic framing of texts)
3. Output of background graphics, for form design in particular the use of templates which were scanned.
4. Colored output of texts
5. User-friendly and integrated Form Painter for the graphical design of forms
6. Graphical Table Painter for drawing tables
7. Reusing Font and paragraph formats in forms (Smart Styles)
8. Data interface in XML format (XML for Smart Forms, in short XSF)
9. Form translation is supported by standard translation tools
10. Flexible reuse of text modules
11. HTML output of forms (Basis release 6.10)
12. Interactive Web forms with input fields, pushbuttons, radio buttons, etc. (Basis-Release 6.10)
A Simple Smartform Tutorial
SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The
output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML
output).
According to SAP, you need neither have any programming knowledge nor use a Script language to adapt
standard forms. However, basic ABAP programming skills are required only in special cases (for example, to
call a function module you created or for complex and extensive conditions).
1. Create a new smartforms
Transaction code SMARTFORMS
Create new smartforms call ZSMART
2. Define looping process for internal table
Pages and windows
First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
Main windows -> TABLE -> DATA
f) Unlike sapscripts (RSTXSCRP), you cannot upload/download Smartform to your local harddisk.
It was said that it was provided in CRM 3.0 version, but not available in R/3. You can download smartforms
into Local PC in a XML format. In the same way you can upload this XML format into Smartform. From the
smartform editor itself you can call download option, if you are working in CRM 3.0 environment.
In R3 also, you can download into XML format. However, it's not sure about uploading. Refer to the program
'SF_XSF_DEMO'.
In 4.7 Enterprise, other have seen this utlity which is completey missing in 4.6c. There is functionality to
downlaod a complete form or only a particular node. (Utilities -> Download form). It will create a XML file
and save it in the hard disk.
For others, if you want to download/upload the Smartforms source, you will need the help from the
Basis people. What you can do is to create a Transport and then FTP down to your local harddisk.
When you need the Smartform source in another system, you have FTP up the Smartforms file back
to the SAP server. Finally, the Basis team, will tp it into your system.
g) The protect and endprotect command in sapscript doesn't work with smartforms. For example on a
invoice: First data of position no 80. is printed on page one, other data of position no 80 is printed on page 2.
And there's nothing you can do about it. Actually, there is something you can do about it. By using a folder
node and checking the 'protect' checkbox, everything in that folder will be page protected.
i) The main difference is that SAP script is client-dependant, while smartform is independent. Also there are
some advanced and intreractive features available in smartforms.
You can use an External subroutine-call in sapscript editor like:
/: perform <form_name> in program <program_name>
/: using <var1>
/: using <var2>
.
.
/: changing <return1>
/: changing <return2>
/:endperform \
&SFSY-PAGE&
Inserts the number of the current print page into the text. You determine the format of the page number (for
example, Arabic, numeric) in the page node.
&SFSY-FORMPAGES&
Displays the total number of pages for the currently processed form. This allows you to include texts such
as'Page x of y' into your output.
&SFSY-JOBPAGES&
Contains the total page number of all forms in the currently processed print request.
&SFSY-WINDOWNAME&
Contains the name of the current window (string in the Window field)
&SFSY-PAGENAME&
Contains the name of the current page (string in the Page field)
&SFSY-PAGEBREAK&
Is set to 'X' after a page break (either automatic [Page 7] or command-controlled [Page 46])
&SFSY-MAINEND&
Is set as soon as processing of the main window on the current page ends
&SFSY-EXCEPTION&
Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the
form interface, using the user_exception macro (syntax: user_exception <exception name >).
Example Forms Available in Standard SAP R/3
SF_EXAMPLE_01
Simple example; invoice with table output of flight booking for one customer
SF_EXAMPLE_02
Similar to SF_EXAMPLE_01 but with subtotals
SF_EXAMPLE_03
Similar to SF_EXAMPLE_02, whereby several customers are selected in the application program; the form
is called for each customer and all form outputs are included in an output request
A Sample Program Calling Smartforms
With Compliments by: Ambekar, Abhijeet
You should use 'SSF_FUNCTION_MODULE_NAME' & call function fm_name in your program & not others.
*&---------------------------------------------------------------------*
*& Report ZTACA_DRIVER_SMARTFORM
*&
*
*&---------------------------------------------------------------------*
*&
*
*&
*
*&---------------------------------------------------------------------*
REPORT ZTACA_DRIVER_SMARTFORM
Tables : sflight.
Data : fm_name TYPE rs38l_fnam.
*&---------------------------------------------------------------------*
REPORT ZTEST_SEARCH_FORMNAME .
TYPE-POOLS: SLIS.
TABLES: STXFADM, STXFADMT.
DATA: BEGIN OF ITAB OCCURS 0,
FORMNAME LIKE STXFADM-FORMNAME,
MASTERLANG LIKE STXFADM-MASTERLANG,
DEVCLASS LIKE STXFADM-DEVCLASS,
VERSION
LIKE STXFADM-VERSION,
FIRSTUSER LIKE STXFADM-FIRSTUSER,
FIRSTDATE LIKE STXFADM-FIRSTDATE,
FIRSTTIME LIKE STXFADM-FIRSTTIME,
LASTUSER LIKE STXFADM-LASTUSER,
LASTDATE LIKE STXFADM-LASTDATE,
FORMTYPE LIKE STXFADM-FORMTYPE,
CAPTION
LIKE STXFADMT-CAPTION,
END OF ITAB.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_DEV FOR STXFADM-DEVCLASS NO INTERVALS.
SELECT-OPTIONS: S_FORM FOR STXFADM-FORMNAME NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS: P_LANG LIKE T002-SPRAS DEFAULT 'EN'.
SELECTION-SCREEN END OF BLOCK B1.
PERFORM F_SELECT_DATA.
PERFORM F_LAYOUT.
PERFORM F_FIELDCAT.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*&
Form f_select_data
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM F_SELECT_DATA .
SELECT
A~FORMNAME
A~MASTERLANG
A~DEVCLASS
A~VERSION
A~FIRSTUSER
A~FIRSTDATE
A~FIRSTTIME
A~LASTUSER
A~LASTDATE
A~FORMTYPE
B~CAPTION
FROM STXFADM AS A INNER JOIN STXFADMT AS B ON
A~FORMNAME = B~FORMNAME INTO TABLE ITAB WHERE
A~DEVCLASS IN S_DEV AND
A~FORMNAME IN S_FORM AND
B~LANGU = P_LANG.
IF SY-SUBRC = 0.
SORT ITAB BY FORMNAME.
ELSE.
MESSAGE I398(00) WITH 'No Form Exits for this selection criteria'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
" f_select_data
*&---------------------------------------------------------------------*
*&
Form display
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SYST-CPROG
IS_LAYOUT
= WA_LAYOUT
IT_FIELDCAT
= IT_FIELDCAT
TABLES
T_OUTTAB
= ITAB.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM.
" display
*&---------------------------------------------------------------------*
*&
Form f_fieldcat
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM F_FIELDCAT .
DATA: WA_COL TYPE I VALUE 1.
WA_FIELDCAT-COL_POS = WA_COL + 1.
WA_FIELDCAT-SELTEXT_L = TEXT-003. " Form Name
WA_FIELDCAT-FIELDNAME = 'FORMNAME'.
WA_FIELDCAT-TABNAME = 'ITAB'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = WA_COL + 1.
WA_FIELDCAT-SELTEXT_L = TEXT-004. " Smart form Text
WA_FIELDCAT-FIELDNAME = 'CAPTION'.
WA_FIELDCAT-TABNAME = 'ITAB'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = WA_COL + 1.
WA_FIELDCAT-SELTEXT_L = TEXT-005. "Package
WA_FIELDCAT-FIELDNAME = 'DEVCLASS'.
WA_FIELDCAT-TABNAME = 'ITAB'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = WA_COL + 1.
WA_FIELDCAT-SELTEXT_L = TEXT-006. "First User
WA_FIELDCAT-FIELDNAME = 'FIRSTUSER'.
WA_FIELDCAT-TABNAME = 'ITAB'.
Then in your window under OUTPUT OPTIONS you include this SMARTSTYLE and use the Paragraph and
character formats.
Line in Smartform
Either you can use a window that takes up the width of your page and only has a height of 1 mm.
Then you put a frame around it (in window output options).
Thus you have drawn a box but it looks like a line.
Or you can just draw "__" accross the page and play with the fonts so that it joins each UNDER_SCORE.
Difference between 'forminterface' and 'global definitions' in global settings of smart forms
The Difference is as follows.
To put it very simply:
Form Interface is where you declare what must be passed in and out of the smartform (in from the print
program to the smartform and out from the smartform to the print program).
Global defs. is where you declare data to be used within the smartform on a global scope.
ie: anything you declare here can be used in any other node in the form.
Smartforms function module name
Once you have activated the smartform, go to the environment -> function module name. There you can get
the name of funtion module name.
The key thing is the program that calls it. for instance, the invoice SMARTFORM LB_BIL_INVOICE is ran by
the program RLB_INVOICE.
This program uses another FM to determine the name of the FM to use itself. The key thing is that when it
calls this FM (using a variable to store the actual name), that the parameters match the paramters in your
smartform.
Another thing to note is that the FM name will change wherever the SF is transported to.
So you need to use the FM to determine the name of the SF.
Here is the code that can be use to determine the internal name of the function module:
Code:
if sf_label(1) <> '/'. " need to resolve by name
move sf_label to externalname.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname
= externalname
importing
fm_name
= internalname
exceptions
no_form
=1
no_function_module = 2
others
= 3.
if sy-subrc <> 0.
message 'e427'.
endif.
move internalname to sf_label.
endif.
It checks to see if the sf_label starts with a '/', which is how the internal names start. if it does, the name has
already been converted. If not, it calls the FM and converts the name.
You would then CALL FUNCTION sf_label.
Smartforms FAQ Part Two
Smartforms output difference
Problem with Smartforms: in a certain form for two differently configured printers, there seem to be
a difference in the output of characters per inch (the distance between characters which gives a
layout problem - text in two lines instead of one.
It happens when the two printers having different Printer Controls' if you go to SPAD Menu (Spool
Administrator Menu) you can see the difference in the Printer Control and if you make the Printer control
setting for both the printers as same. then it will be ok. and also u have to check what is the device type
used for both the output devices.
Typically, generate the SF, then use the pattern to being in the interface. Then change the call function to
use the name you get back from the above function module.
&ktab-<field2>&
save & activate then execute ,, scripts will generate a function module like : '/ibcdw/sf0000031' copy this
function module and call in executable program...
For that
1. go with abap editor se38.
2. table: ugyfel.
3. parameters: test like ugyfel-<field1>.
4. data itab like ugyfel occurs 0 with header line.
5. select * from ugyfel into table itab where field1 = test1.
6. call function '/ibcdw/sf0000031'
7. tables
ktab = itab.
Save and activate the program ( ^f 3).
Now run the program ( f 8)
Internal Table in Smartform
Here is a sample program in which used two internal tables:
REPORT YPRINTPRG_SMARTFORM1 .
DATA : ITKNA1 LIKE KNA1,
ITVBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.
PARAMETERS : PKUNNR LIKE KNA1-KUNNR.
SELECT * FROM KNA1 INTO ITKNA1
WHERE KUNNR = PKUNNR.
ENDSELECT.
SELECT * FROM VBAK
INTO TABLE ITVBAK
WHERE KUNNR = PKUNNR.
CALL FUNCTION '/1BCDWB/SF00000011' THIS FUNCTION MODULE CALLS THE
SMART FORM WE WILL GET THIS AT MENU ENVIRONEMENT
EXPORTING
ITKNA1
= ITKNA1
TABLES
ITVBAK
= ITVBAK.
IN SMART FORM
FORM INERFACE---------IMPORT (TAB)
Parameter name
Type assignment Reference type
ITKNA1
LIKE
KNA1
Default value
a.writeline ""
a.writeline "N"
a.writeline ""
a.writeline ""
a.writeline "q800"
a.writeline "Q635,24+0"
a.writeline "R32,24"
a.writeline "S3"
a.writeline "D8"
a.writeline "ZT"
a.writeline ""
rem this is an example of barcode ean128-ucc
a.writeline "B126,429,0,1E,3,3,61,B,""011234567890123410051215"""
rem this is an example of barcode 3 of 9 rotated
a.writeline "B10,495,3,1,3,3,49,B,""01234567"""
a.writeline ""
a.writeline ""
a.writeline "P1"
a.writeline ""
a.Close
We've send this code to an ascii file or as part of a macro to be run within an excel sheet. We have succeed
in both cases.
The zebra printer is created as local to the computer running the vbscript. We haven't been able to share
the zebra printer so other people in the network can use it. And the zebra printer isn't installed as a SAP
printer (we aren't using sap spooler to send jobs to the zebra). Another Note: zebra 2746 comes with a
software bar-one (or something like that) that allows you to design the barcode label in a wysiwyg way
If my memory isn't failing, I think that I've read something about controlling zebra printers from smartforms in
service.sap.com, but I haven't explored this possibility.
2. From 4.6c on, you can use smartforms to print barcodes without buying any barcode.dll software
nor hardware extention like Bardimm on any laser/inkjet printer (Please Note that I haven't
mentioned Zebra printers here!). To do this, you have to create a smartstyle -> character format with
the desired barcode font (defined within sap). Then in the smartform, create a window, put the field and
associate it the character format. That's all (I mean, that's all we do at least :-). I think, you have to consider
the barcode specifications before sending the barcode value to the smartform (Just an example, if you're
using 3 of 9, the code should start and end with an asterisk - '*' -) We're printing an interleaved 2 out of 5
barcode in our invoices due to a legal requirement, and we did it this way.
3. If you have a barcode scanner, then you should not need reading the barcode into an ascii file to get the
data read in an standard or custom screen field. You can read it directly to the field you want. (unless... you
have complex data coded in the barcode - for example if you're using an ean-ucc 128 compliant code and
you're sending several fields in a single code ... In this case, an interface is almost mandatory because you
must interpret the data fields according to the ucc standard, split the code into several fields .... and .... pure
programming logic ).
To put it clear: if you have to read, for example, a barcode that holds the legal number of an invoice using a
barcode scanner and this number should be sent to migo-> bktxt then you don't need an interface. The
scanner itself acts like a fast operator entering the characters using a keyboard and filling in the field.
We're reading barcodes in several places (when we finish each pallet, when we receive an invoice, and so
on. Each case is a different screen. We arent using an ascii file to read these barcodes. Furthermore, we
read the invoice legal number into migo bktxt field (Head Text).
BAPI Programming Tips and Tricks
SAP created the Business Framework to allow the technical integration and exchange of business data
among SAP components and between SAP and non-SAP components. Important components of the
Business Framework are the Business Application Programming Interfaces (BAPIs), which represent visible
interfaces at the component boundaries and whose properties serve to integrate these components.
The integration can include both components within a local network and components that are connected
with one another through the Internet.
BAPIs allow integration at the business level, not the technical level. This provides for greater stability in the
link, and independence from the underlying communication technology.
You can get all the standard SAP BAPI functions with the transactions code 'BAPI'.
BAPI Conventions
Methods
Parameters
Standardized BAPIs
Standardized Parameters
Important things to remember..
BAPI/ALE Integration
Methods
If the BAPI to be implemented is a standardized BAPI, use the generic names, for example,
GetList, GetDetail.
The method name must be in English (maximum 30 characters).
The individual components of a BAPI name are separated by the use of upper and lower
case.Example: GetList
Underscores ("_") are not allowed in BAPI names.
Each BAPI has a return parameter that is either an export parameter or an export table.
So that customers can enhance BAPIs, each BAPI must have an ExtensionIn and an ExtensionOut
parameter.
Parameters
If standardized parameters are used, you have to use the names specified for standardized
parameters.
BAPI parameter names should be as meaningful as possible. Poorly chosen names include
abbreviations and technical names (e.g. "flag", table names, etc.).
The parameter and field names must be in English with a maximum of 30 characters.
The components of a parameter name in the BOR are separated by upper and lower case letters to
make them easier to read. Example: CompanyCodeDetail
Values that belong to each other semantically should be grouped together in one structured
parameter, instead of using several scalar parameters.
For ISO-relevant fields (country, language, unit of measure, currency), additional fields for ISO
codes are provided.
Unit of measure fields must accompany all quantity fields and currency identifiers must accompany
currency amount fields.
Standardized BAPIs
Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs
should be implemented the same for all business object types. Standardized BAPIs are easier to use and
prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI
must be used in preference to an individual BAPI.
The following standardized BAPIs are provided:
GetList ( )
With the BAPI GetList you can select a range of object key values, for example, company
codes and material numbers.
The BAPI GetList() is a class method.
GetDetail()
With the BAPI GetDetail() the details of an instance of a business object type are retrieved and
returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an
instance method.
BAPIs that can create, change or delete instances of a business object type
The following BAPIs of the same object type have to be programmed so that they can be called several
times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is
created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2.
After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the
database.
Create( ) and
CreateFromData( )
Change( )
The BAPI Delete() deletes an instance of an SAP business object type from
the database or sets a deletion flag.
The BAPI Undelete() removes a deletion flag. These BAPIs are instance
methods.
Cancel ( )
Add<subobject> ( ) and
Remove<subobject> ( )
Replicate( ) and
SaveReplica( )
distributed systems within the context of Application Link Enabling (ALE). These BAPIs
are class methods.
Other Less Used Standardized BAPIs
Standardized Parameters
There are some parameters that can be created for various BAPIs because they contain the same or the
equivalent data in all BAPIs. They should be implemented the same in all BAPIs.
Address
parameters
Specific reference structures are defined for address parameters in BAPIs. You should
copy these structures to use in your BAPI, especially if the underlying object type uses the
central address management (CAM).
Change
Parameters
In BAPIs that cause database changes (for example, Change() and Create() BAPIs) you
must be able to distinguish between parameter fields that contain modified values and
parameter fields that have not been modified. This distinction is made through the use of
standardized parameters.
Extension
parameters
The parameters ExtensionIn and ExtensionOut provides customers with a mechanism that
enables BAPIs to be enhanced without modifications.
Return
Parameters
Each BAPI must have an export return parameter for returning messages to the calling
application. To provide application programmers with a consistent error handling process
for BAPI calls, all return parameters must be implemented in the same, standardized way.
Selection
Parameters
Standardized selection parameters are used in BAPIs that can be used to search for
specific instances of a business object type (e.g. in GetList() ). These parameters enable
the BAPI caller to specify the relevant selection criteria.
Test Run
Parameters
The parameter TestRun is used in write BAPIs (Create() and Change() ), to check the
entries for the object instance in the database before actually creating the object instance.
The creation of the object instance is only simulated and data is not updated.
Text Transfer
Parameters
To transfer BAPI documentation texts (e.g. the documentation of a business object type),
you have to create standardized text transfer parameters.
BAPI/ALE Integration
When you use the BAPIs for asynchronous messagning, the application in the sendig systen calls the
generated ALE IDoc interface isntead of the BAPI.
Asynchronous BAPIs use the ALE interface this way:
The Program coding for calling a BAPI is usually cleaner than setting up the screen flow etc for the Call
Transaction.
You don't need to worry about special data circumstances interrupting the normal data flow of the screens
and causing errors because of that.
BAPIs probably have better performance since they don't do the screen flow processing.
In general if the BAPI exists for the transaction you want to perform and you can figure out how to use it the
BAPI is probably the best way to go.
This is just from my experience working with both BAPI and Call Transaction. I have had some very good
successes with BAPIs, but very occasionally found that I could not get the BAPI to perform the update I
needed.
The interface concept of the classic R/3 is based on two different strategies: Remote Function Calls (RFC)
and data exchange through IDoc message documents. RFC makes direct and synchronous calls of a
program in the remote system. If the caller is an external program it will call an RFC-enabled function in R/3
and if the calling program is the R/3 system it will call an
RFC-function in another R/3-system or it will call a non-R/3 program through a gateway-proxy (usually
rfcexec.exe). BAPIs are a subset of the RFC-enabled function modules, especially designed as Application
Programming Interface (API) to the SAP business object, or in other words: are function modules officially
released by SAP to be called from external programs.
IDocs are text encoded documents with a rigid structure that are used to exchange data between R/3 and a
foreign system. Instead of calling a program in the destination system directly, the data is first packed into an
IDoc and then sent to the receiving system, where it is analyzed and properly processed. Therefore an
IDoc data exchange is always an
asynchronous process. The significant difference between simple RFC-calls and IDoc data exchange is the
fact, that every action performed on IDocs are protocolled by R/3 and IDocs can be reprocessed if an error
occurred in one of the message steps.
While IDocs have to be understood as a data exchange protocol, EDI and ALE are typical use cases for
IDocs. R/3 uses IDocs for both EDI and ALE to deliver data to the receiving system. ALE is basically the
scheduling mechanism that defines when and between which partners and what kind of data will be
exchanged on a regular or event triggered basis. Such a set-up is called an ALE-scenario.
The philosophical difference between EDI and ALE can be pinned as follows: If we send data to an external
partner, we generally speak of EDI, while ALE is a mechanism to reliable replicate data between trusting
systems to store a redundant copy of the IDoc data. The difference is made clear, when we think of a
purchase order that is sent as an IDoc. If we send the purchase order to a supplier then the supplier will
store the purchase order as a sales order. However, if we send the purchase order via ALE to another R/3
system, then the receiving system will store the purchase order also as a purchase order.
With regards,
-----Reply Message----Subject: RE: Difference and/or simmelarities between BAPI and IDOC's
There are many differences between IDOCs and BAPIs.
BAPIs in 3.1 are synchronous; in 4.+ they can be asynchronous (and I
believe they then drive certain ALE/IDOCs).
BAPIs are called from the outside-in. That is, an external program
invokes a BAPI that gets data from SAP to display or updates data in
SAP. The BAPI concept does not include an event concept -- you cannot
tell SAP that when certain events happen to a "business object", to fire
a message or a file to an external system.
BAPIs are invokable from Java or C/C++ or Visual Basic (and I think some
people are using Delphi).
In 3.1x there are very few BAPIs to use. In 4.+ SAP has added a large
number.
BAPIs are not totally immune to upgrades but if they are to be retired
you supposedly will have them supported for two releases. Whether those
are point or letter releases, I don't know. I believe that IDOCs may
be more changable from release to release.
BAPIs are reasonably well documented and there is a common place to look
to see what is available. IDOCs -- I have heard -- are poorly
documented in terms of finding them, and IDOCs were done differently by
different groups in SAP.
BTW, you can also use Java, C/C++, Visual Basic, ... to invoke RFCs in
SAP and get or update data. That's how the BAPIs work since they
utimately are sets of RFC calls (written to a design spec for BAPIs).
Hope I haven't misstated any of the details.
BAPI vs Call transaction
-----Original Message----Subject: BAPI vs Call transaction
Hi all!
Could you explain me why a BAPI is faster than a call transaction?.
E.g. If i have the BAPI: create_sales_document and I could also do a call transaction to
va01. Wich one is better?. Why?.
Thanks in advance...
-----Reply Message----Subject: RE: BAPI vs Call transaction
Hi, As of I know BAPI's R internally they RFC functions and they were implemented
with Objects... ..May be because of this reason they R faqster..if it is wrong ..please
don't mind...Regards...
-----Reply Message----Subject: RE: BAPI vs Call transaction
A BAPI is faster because it is updating the DB "directly" through ABAP code. A BDC with call
transaction goes through the whole screen sequence like any user would do, simply put, it
is filling screens.
Use BAPIs whenever possible.
-----Reply Message----Subject: RE: BAPI vs Call transaction
you use a special BAPI, cause this one uses CALL TRANSACTION to create a sales order.
A lot of BAPIS and IDOC - input FM use DIRECT INPUT instead of CALL TA. Much faster. And
you can do a lot with them, you can't do as easy in CALL TA.
But the best reason for BAPIs is, that they are farely safe on release change or support
package change.
Bye
-----Reply Message----Subject: RE: BAPI vs Call transaction
Thanks for your answers... They have been very useful...
COMMIT WORK and BAPI_TRANSACTION_COMMIT
-----Original Message----Subject: COMMIT WORK and BAPI_TRANSACTION_COMMIT
Does anybody know what's the difference between the two?
-----Reply Message----Subject: RE: COMMIT WORK and BAPI_TRANSACTION_COMMIT
Hi,
Commit work is used when you code directly in ABAP and make changes in the database and
want to commit the database.
BAPI_TRANSACTION_COMMIT is used when you make changes to the SAP database by calling
a BAPI from outside SAP and want to commit the database. When you use a BAPI, you can not
directly use commit work, instead you are allowed to use only
BAPI_TRANSACTION_COMMIT.
Regards,
-----Reply Message----Subject: RE: COMMIT WORK and BAPI_TRANSACTION_COMMIT
I would sasy the diff lies more in the way u want to call Commit Work.
With BAPI_TRANSACTION_COMMIT ..the external systems have a way of deciding on whether to
Commit or to Roll back Changes.
But with Commit Work u have to code it inside ure BAPI and the outside systems then have no chance or
have
any hold over the commit...
so i guess the diff lies more in the way how u want to call commit ,either from outside or from within ure
BAPI.
u can use both...
SAP though recommends using BAPI_Transaction_Commit and not using Commit_work in the BAPI...
but its upto u and ure middleware guy to decide how u want to do it..
Exponential form to general
-----Original Message----Subject: Exponential form to general
hi,
can anyone help me in BAPI
1)In BAPI_BILLINGDOC_CANCEL1
i am not able to under TESTRUN.how can we test it
2)BAPI_SALESORDER_CHANGE
3)BAPI_TRANSACTION_COMMIT
can anyone help me out on these.i dont know BAPI.Can any one advice me where can i read
it?
-----Reply Message----Subject: RE: Exponential form to general
Hi,
You can test the bapi's by passing the required parameters, Actually you can use the
BAPI_SALESORDER_CHANGE when you want to change the existing sales order.
BAPI_TRANSACTION_COMMIT is necessary to commit the changes, if you won't call the
BAPI_TRANSACTION_COMMIT the values won't store in database.
The doucmentation is not available in English version, if yo want to see the similar once check
SD_SALESDOCUMENT_CHANGE function module, both will do same work. You can get the
documentation
for this function module in GOTO-->DOCUMENTAION.
regards
Persistent key
-----Original Message----Subject: persistent key
Hi all,
i'm new in bapi programming, i'm trying to call GetList method from
GeneralLedgerAccount Business Object, and got this error message 'The
persistent key for an bussiness object instance of type GeneralLedgerAccount
has not been set. Cannot invoke method GetList'.
How can i set the persistent key, and what is the persistent key exactly ?
How can i check the persistent key in the BOR ?
I'm using SAP R/3 version 3.1g and VB version 6.0
-----Reply Message----Subject: RE: persistent key
Although we are currently using SAP 4.0B, the GeneralLedgerAccount BAPI has not changed
significantly (if at all). I have had this error message many times working with HR BAPI's and it
took a lot of research to finally puzzle out what SAP actually wants in these situations. On the
other hand, I took a look at the GetList method for this BAPI and I cannot see why you would
be getting this error! There are three kinds of BAPI's I have encountered so far - those that
return actual tables of data based on key fields you fill in (ie. Employee.GetList), those
that return tables of keys that point to the actual data within SAP (think of C pointers! ie.
EmployeePersonalData.GetList), and BAPI's that have no input parameters at all but can retrieve
extra information directly related to a particular 'instance' of a business object that you have
previously 'instantiated' (translation - the last 'record' you 'read' from the table! ie.
EmployeePersonalData.GetDetail). GeneralLedgerAccount is of the first type, while the error you get
is related to BAPI's of the third type. It is usually caused by calling a GetDetail method without
calling GetSAPObject with a complete, unique key value first. The following code fragment
shows how I read Employee.GetList - this may shed some light on what you might be missing. The
second fragment shows how to 'instantiate' a 'persistant' object (don't we just love this
terminology?) before calling a GetDetail BAPI. Hope this helps you out!
===================================================
Dim oBapiControl As Object
Dim oConnection As Object
Dim oEmployee As Object
Dim oReturn As Object
Dim otabPersonalData As Object
Dim otabOrgAssignment As Object
Dim oRow As Object
oBapiControl = CreateObject("SAP.BAPI.1")
Set oConnection = oBapiControl.Connection
'SET UP ALL oConnection PARAMETERS HERE AND CALL oConnection.Logon(0, True)
Set oEmployee = oBapiControl.GetSAPObject("Employee")
oEmployee.Getlist Lastname:="*", _
Return:=oReturn, _
PersonalData:=otabPersonalData, _
OrgAssignment:=otabOrgAssignment
For Each oRow In otabPersonalData.Rows
Print "Personnel Number = " + oRow.Value("PERNO")
...
Next oRow
- Substitute the word 'GeneralLedgerAccount' for 'Employee' and this should work for you!
===================================================
Private Sub LoadFamily(sPerno As String)
Dim cSep
As String * 1
Dim sToday
As Date
Dim oCol
As Object
Dim oDelRow
As Object
Dim oReturn
As Object
Dim oFReturn
As Object
Dim otabFKeyList As Object
Dim oFamilyKey As Object
Dim oFamilyMem As Object
Dim sFirstName As String
Dim sSecondName As String
Dim sLastName
As String
Dim sGender
As String
Dim sBirthdate As Date
cSep = Chr(9)
sToday = Date
' RETRIEVE ALL FAMILY MEMBERS FOR A GIVEN PERSONNEL NUMBER.
' NOTE THAT THE BAPI RETURNS A TABLE OF KEYS (Familykey) AND
' NOT THE ACTUAL DATA!
Set otabFKeyList = Nothing
oFamilyMembers.Getlist EmployeeNumber:=sPerno, _
Subtype:="", _
Timeintervallow:=sToday, _
Timeintervalhigh:=sToday, _
Return:=oFReturn, _
Familykey:=otabFKeyList
If oFReturn.Value("TYPE") <> "E" Then
'IF THE CALL SUCCEEDED,
For Each oFamilyKey In otabFKeyList.Rows
THEN FOR EACH KEY IN THE TABLE...
On Error Resume Next
' INSTANTIATE A PERSISTANT LOCAL BUSINESS OBJECT HERE USING THE
' FULL KEY VALUE
Set oFamilyMem = oBapiControl.GetSAPObject("EmployeeFamilyMember", _
oFamilyKey.Value("EMPLOYEENO"), _
oFamilyKey.Value("SUBTYPE"), _
oFamilyKey.Value("OBJECTID"), _
oFamilyKey.Value("LOCKINDIC"), _
oFamilyKey.Value("VALIDEND"), _
oFamilyKey.Value("VALIDBEGIN"), _
oFamilyKey.Value("RECORDNR"))
If Err.Number = 0 Then
' AND IF THAT WORKED, THEN FINALLY
' WE CAN GET THE INFORMATION WE WANT BY CALLING GETDETAIL. THIS BAPI
' USES THE KEY INFORMATION IN THE FamilyMem OBJECT TO IDENTIFY THE SAP
' DATA THAT SHOULD BE RETURNED....VERY COMPLEX!!!
oFamilyMem.GetDetail Return:=oReturn, _
Firstname:=sFirstName, _
Initials:=sSecondName, _
Lastname:=sLastName, _
Gender:=sGender, _
Dateofbirth:=sBirthdate
If oReturn.Type <> "E" Then
Print #2, sPerno; cSep; _
sFirstName; cSep; _
sSecondName; cSep; _
sLastName; cSep; _
sGender; cSep; _
sBirthdate; cSep; _
""
End If
Else
Err.Clear
End If
Next oFamilyKey
End If
End Sub
===================================================
-----End of Message----Read function module definition
-----Original Message----Subject: read function module definition
hi,
did someone know, where the import, export, tables, exception definition
of a function module is storeed?
I try to write a RFC call to read the interface of a function module (or
BAPI) to generate a C++ interface.
Therefore I write a function in Abap, which could be called via RFC.
Thx
-----Reply Message----Subject: RE: read function module definition
Try RFC_GET_FUNCTION_INTERFACE
-----End of Message----Difference Between BAPI and RFC
What is the main difference between BAPI and RFC and difference between BAPI and BDC?
BAPI is used only when it is available for the particular transaction like Delivery Sales order. but BDC can
be used for any
transaction which have screen and fields.
BAPI is directly updated the database instead BDC run through the screen flow.
So BAPI can't handle all the flow logic checking and enhancement put by programmer to faciliate the user
requirement.
prepare new BDC we cant use the old BDC pgm. But in BAPI, SAP promises that they are going to keep the
old BAPI and for new functionality they will provide an upgraded BAPI. Until we write a new BAPI pgm, we
can use the exisitng BAPI pgm.
BAPI ActiveX Control
-----Original Message----Subject: BAPI ActiveX Control
Hi!
Where can I find the BAPI ActiveX Control ?
Thanks in advance
-----Reply Message----Subject: RE: BAPI ActiveX Control
Hi!
All necessary files for using BAPI are installed together with the SAP
GUI on your PC (from 3.1H on).
If it does not work or you can not find any SAP ActiveX Control you have to
install the SAP GUI again.
The BAPI ActiveX Control might be the file "wdobapi.ocx ".
ODBC and MsAccess
-----Original Message---Subject: ODBC and MsAccess
Hello All,
We are building an interface between R/3 and an application a company build
for us in Ms. Access. Since they build the application for us we want to
subcontract this interface to this company. The consultant came to with the
idea of using ODBC to read/write directly to the Oracle database.
Can this be done ???? (I thought not !)
anybody has experience with Access/R/3
Thanks !
-----Reply Message---Subject: RE: ODBC and MsAccess
Hello!
Dont write directly to the SAP database because you can get inconsistent
information in your system. Always use the standard functionality with its
checks. For this reason you can use the BAPI-method.
-----End of Message-----
Then in SAP [after getting back that IDoc from NON-SAP((ware house management) ], the status of that
delivery number will changes to "Confirmed". We can see that in SAP through transaction code : vl33n.
> -----------------------------I am not so familiar with VL33N, so I could not find this status change. Am I right to think that this status is
stored in table LIKP field VLSTK ( Distribution Status (Decentralized Warehouse
Processing) ).
NOW , I need one BAPI which I can use from NON-SAP, to get back the status of that delivery number. My
idoc sending from NON-SAP, since it is through idoc , it is not returning back the delivery number's status
from SAP, I need to use one BAPI from nonsap (java prg) which takes input as delivery number and gives
2) What is RFC sever programming ? In which language is it in? I am an ABAP programmer. How can I deal
that issue please guide me .
> -----------------------------Ahah. RFC ! So, RFC's are actually function modules, but in the Attributes tab you enable 'Remote-enabled
module' and you enable 'Start Immediately'. RFC's are created with SE37, you can also create them with
SE80.
In the import section you would create a p_vbeln like likp-vbeln, in the export section you would create a
p_status like likp-vlstk.
In the source code you would have something like
select single vlstk
into p_status
from likp
where vbeln eq p_vbeln.
And then in JCO you call this Function Module/RFC. The java person should know how to do this.
How to Find Bapi for Particular Transaction in SAP
How to find function module or Bapi for particular transaction in sap?
If you mean that you need to know what BAPI's a particular tranx uses, which I can only assume that's what
you mean, then you should access the code behind the transaction and search for 'CALL'. That normally is
the standard method that think that most people use.
Suppose you want to find the bapi for creating a sales order, you usually use transaction VA01 for this.
1. Find out the package of the transaction.
Start Va01 go to system --> status.
Double click on transaction
Package is VA
Open this package in SE80
Open business engineering-->Business object types
Find the BO which sounds the most appropriate
I would suggest BUS2032 Sales Order
Double click.
Open methods.
Find the released method with from data or something similar in the name
, Createfromdat2
Position the cursor in it and click the program button
Scroll down to find the bapi used in this method
With this way you can also find out programs and FM's
2. Start va01 go to system-->status
Double click transaction VA01
Double click on package
Read the application component. (this is SD-SLS Sales)
Then open the transaction BAPI
Sales and distribution-->Sales-->sales order
createfromdat2
plant(4),
"Plant
material(18),
"Material Number
qty(13),
"Quantity
recv_loc(4),
"Receiving Location
issue_loc(4),
"Issuing Location
pur_doc(10),
"Purchase Document No
po_item(3),
"Purchase Document Item No
del_no(10),
"Delivery Purchase Order Number
del_item(3),
"Delivery Item
prod_doc(10),
"Production Document No
scrap_reason(10),
"Scrap Reason
upd_sta(1),
"Update Status
end of pcitab.
call function 'WS_UPLOAD'
exporting
filename
= p-file
filetype
= 'DAT'
* IMPORTING
* FILELENGTH
=
tables
data_tab
= pcitab
* EXCEPTIONS
* FILE_OPEN_ERROR
=1
* FILE_READ_ERROR
=2
* NO_BATCH
=3
* GUI_REFUSE_FILETRANSFER
=4
* INVALID_TYPE
=5
* OTHERS
=6
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
endif.
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '01'. "01 - MB01 - Goods Receipts for Purchase Order
loop at pcitab.
itab-move_type = pcitab-mvt_type.
itab-mvt_ind = 'B'.
itab-plant
= pcitab-plant.
itab-material = pcitab-material.
itab-entry_qnt = pcitab-qty.
itab-move_stloc = pcitab-recv_loc.
itab-stge_loc = pcitab-issue_loc.
itab-po_number = pcitab-pur_doc.
itab-po_item = pcitab-po_item.
concatenate pcitab-del_no pcitab-del_item into itab-item_text.
itab-move_reas = pcitab-scrap_reason.
append itab.
endloop.
loop at itab.
write:/ itab-material, itab-plant, itab-stge_loc,
itab-move_type, itab-entry_qnt, itab-entry_uom,
itab-entry_uom_iso, itab-po_number, itab-po_item,
pcitab-ext_doc.
endloop.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header
= gmhead
goodsmvt_code
= gmcode
* TESTRUN
=''
* IMPORTING
goodsmvt_headret
= mthead
* MATERIALDOCUMENT
=
* MATDOCUMENTYEAR
=
tables
goodsmvt_item
= itab
* GOODSMVT_SERIALNUMBER
=
return
= errmsg
.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
else.
write:/ mthead-mat_doc, mthead-doc_year.
perform upd_sta.
endif.
endif.
*---------------------------------------------------------------------*
*
FORM UPD_STA
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
form upd_sta.
loop at pcitab.
pcitab-upd_sta = 'X'.
modify pcitab.
endloop.
call function 'WS_DOWNLOAD'
exporting
filename
= p-file
filetype
= 'DAT'
* IMPORTING
* FILELENGTH
=
tables
data_tab
= pcitab
* EXCEPTIONS
* FILE_OPEN_ERROR
=1
* FILE_READ_ERROR
=2
* NO_BATCH
=3
* GUI_REFUSE_FILETRANSFER
* INVALID_TYPE
=5
=4
* OTHERS
.
=6
endform.
*--- End of Program
INT_MAT-SPRAS = MAKT-SPRAS.
INT_MAT-MAKTX = MAKT-MAKTX.
"Language key
"Material description
APPEND INT_MAT.
CLEAR INT_MAT.
ENDSELECT.
ENDFORM.
FORM DOWNLOAD_FILE.
call function 'WS_DOWNLOAD'
EXPORTING
FILENAME
= F_FILE
FILETYPE
= 'DAT'
* FILETYPE
= 'WK1'
tables
data_tab
= INT_MAT
EXCEPTIONS
FILE_OPEN_ERROR
=1
FILE_WRITE_ERROR
=2
INVALID_FILESIZE
=3
INVALID_TYPE
=4
NO_BATCH
=5
UNKNOWN_ERROR
=6
INVALID_TABLE_WIDTH
=7
GUI_REFUSE_FILETRANSFER
=8
CUSTOMER_ERROR
=9
OTHERS
= 10.
IF SY-SUBRC = 0.
FORMAT COLOR COL_GROUP.
WRITE:/ 'Data Download Successfully to your local harddisk'.
SKIP.
ENDIF.
ENDFORM.
FORM UPLOAD_FILE.
call function 'WS_UPLOAD'
EXPORTING
FILENAME
= F_FILE
FILETYPE
= 'DAT'
* FILETYPE
= 'WK1'
tables
data_tab
= INT_MAT
EXCEPTIONS
FILE_OPEN_ERROR
=1
FILE_WRITE_ERROR
=2
INVALID_FILESIZE
=3
INVALID_TYPE
=4
NO_BATCH
=5
UNKNOWN_ERROR
=6
INVALID_TABLE_WIDTH
=7
GUI_REFUSE_FILETRANSFER
=8
CUSTOMER_ERROR
=9
OTHERS
= 10.
IF SY-SUBRC = 0.
FORMAT COLOR COL_GROUP.
WRITE:/ 'Data Upload Successfully from your local harddisk'.
SKIP.
ENDIF.
ENDFORM.
FORM UPDATE_MM.
LOOP AT INT_MAT.
* Header
BAPI_HEAD-MATERIAL
= INT_MAT-MATNR.
BAPI_HEAD-IND_SECTOR
= INT_MAT-MBRSH.
BAPI_HEAD-MATL_TYPE
= INT_MAT-MTART.
BAPI_HEAD-BASIC_VIEW
= 'X'.
BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
* Material Description
REFRESH INT_MAKT.
INT_MAKT-LANGU
= INT_MAT-SPRAS.
INT_MAKT-MATL_DESC
= INT_MAT-MAKTX.
APPEND INT_MAKT.
* Client Data - Basic
BAPI_MARA1-MATL_GROUP = INT_MAT-MATKL.
BAPI_MARA1-BASE_UOM
= INT_MAT-MEINS.
BAPI_MARA1-UNIT_OF_WT = INT_MAT-GEWEI.
BAPI_MARA1-DIVISION
= INT_MAT-SPART.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-DIVISION = 'X'.
* Plant - Purchasing
BAPI_MARC1-PLANT
= INT_MAT-WERKS.
BAPI_MARC1-PUR_GROUP = INT_MAT-EKGRP.
BAPI_MARCX-PLANT
= INT_MAT-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = INT_MAT-WERKS.
BAPI_MBEW1-PRICE_CTRL = INT_MAT-VPRSV.
BAPI_MBEW1-STD_PRICE = INT_MAT-STPRS.
BAPI_MBEW1-PRICE_UNIT = INT_MAT-PEINH.
BAPI_MBEWX-VAL_AREA = INT_MAT-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
BAPI_MBEWX-PRICE_UNIT = 'X'.
WRITE:/ BAPI_HEAD, BAPI_MARC1.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
STORAGETYPEDATA
=
STORAGETYPEDATAX
=
IMPORTING
RETURN
= BAPI_RETURN
TABLES
MATERIALDESCRIPTION
= INT_MAKT
UNITSOFMEASURE
=
UNITSOFMEASUREX
=
INTERNATIONALARTNOS
=
MATERIALLONGTEXT
=
TAXCLASSIFICATIONS
=
RETURNMESSAGES
=
PRTDATA
=
PRTDATAX
=
EXTENSIONIN
=
EXTENSIONINX
=
.
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error Message ', BAPI_RETURN.
ENDIF.
ENDLOOP.
ENDFORM.
*---End of Program
BAPI_MATERIAL_MAINTAINDATA_RT
-----Original Message----Subject: BAPI_MATERIAL_MAINTAINDATA_RT
I'm attempting to use the 'BAPI_MATERIAL_MAINTAINDATA_RT' BAPI function.
Does anyone know what goes in the 'Function' field of the main import table. The same field also appears in
the parameter
tables.
Any idea, anyone.
-----Reply Message----Subject: RE: BAPI_MATERIAL_MAINTAINDATA_RT
check out transaction WE60 basic type ARTMAS01. This will give you documentation related to the idoc
basic type for this
function.
The segment documentation will give you the required values.
Regards,
-----End of Message----Material Master creation/change
-----Original Message----Subject: Material Master creation/change
Hi,
I would like to know if there is any BAPI in 4.5B for Material Master creation/change. i would really
appreciate if anyone
could help me out on this.
Thanks
-----Reply Message----Subject: RE: Material Master creation/change
BAPI_MATERIAL_SAVEDATA
-----End of Message---Material Master
-----Original Message----Subject: Material Master
Hi
I am trying to retrieve all material in the SAP system,
but the only Business object I have found (Material)
requires a key (Material Number)
I can not force it to retrieve all materials
Is there is a way I can use to retrieve all materials
If yes can you provide me with an example
Thankx in advance
-----Reply Message----Subject: RE: Material Master
Hi!
you have to use the Method MATERIAL.GETLIST. It gives you the material numbers
of all your material. Then you have to get the detail material data with
MATERIAL.GETDETAIL(material number).
MATERIAL ( BUS1001 ) is a Business Object in the BOR.
-----End of Message----Sample Abap code on BAPI_PO_CHANGE
DELETING PURCHASE ORDERS
*&---------------------------------------------------------------------*
*& Report ZMMR_DELETEPO
*
*&---------------------------------------------------------------------*
*& Author
: Bikash Agarwal
*& Description
: VTLS PO Change
*& Program Objective
: Places a DELETION indicator for the PO
*&
items given in the VTLS data
*& Remarks
: NA
*&---------------------------------------------------------------------*
EXPORTING
file
= l_filename
RECEIVING
result
= l_result
EXCEPTIONS
cntl_error
=1
error_no_gui
=2
wrong_parameter
=3
not_supported_by_gui = 4
OTHERS
= 5.
IF sy-subrc <> 0.
MESSAGE s007 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ELSEIF l_result IS INITIAL.
MESSAGE s008 DISPLAY LIKE c_e.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
" validate_pre_file_hdr
*&--------------------------------------------------------------------*
*&
Form validate_app_file
*&--------------------------------------------------------------------*
*
text - Checks if the path entered and filename is correct
*---------------------------------------------------------------------*
FORM validate_app_file USING fp_file TYPE FILENAME-FILEINTERN.
data : l_fname(60).
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = FP_FILE
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME
= L_FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC = '0'.
OPEN DATASET L_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
MESSAGE s007 DISPLAY LIKE c_e.
ELSE.
CLOSE DATASET l_fname.
ENDIF.
ENDIF.
ENDFORM.
" validate_app_file
*&--------------------------------------------------------------------*
*&
Form upload_file
*&--------------------------------------------------------------------*
*
Routine to upload data from file to tables.
*---------------------------------------------------------------------*
*
-->P_fp_flatfile
*
-->P_fp_file
*
<--P_fp_rc
*---------------------------------------------------------------------*
FORM upload_file TABLES fp_flatfile
USING fp_file TYPE string
CHANGING fp_rc TYPE sy-subrc.
IF fp_flatfile[] IS INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename
= fp_file
filetype
= c_filetype
has_field_separator = c_x
TABLES
data_tab
= fp_flatfile
EXCEPTIONS
file_open_error
=1
file_read_error
=2
no_batch
=3
gui_refuse_filetransfer = 4
invalid_type
=5
no_authority
=6
unknown_error
=7
bad_data_format
=8
header_not_allowed
=9
separator_not_allowed = 10
header_too_long
= 11
unknown_dp_error
= 12
access_denied
= 13
dp_out_of_memory
= 14
disk_full
= 15
dp_timeout
= 16
OTHERS
= 17.
MOVE sy-subrc TO fp_rc.
ENDIF.
ENDFORM. " upload_file
*&--------------------------------------------------------------------*
*&
Form upload_file_app
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
*
-->FP_FLATFILEtext
*
-->FP_FILE text
*
-->FP_RC
text
*---------------------------------------------------------------------*
FORM upload_file_app TABLES fp_flatfile
USING fp_file TYPE FILENAME-FILEINTERN
CHANGING fp_rc TYPE sy-subrc.
DATA: l_string TYPE tedata-data.
DATA: wa_data_file TYPE tp_flatfile_vtls,
l_wllength TYPE i,
FNAME(60).
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = FP_FILE
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME
= FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC = 0.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
* *C-- commented by Bikash
*
MESSAGE s107(yaero_ps) DISPLAY LIKE c_e.
message e008.
ELSE.
DO.
CLEAR: l_string.
READ DATASET FNAME INTO l_string LENGTH l_wllength.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT l_string AT con_tab INTO wa_data_file-ebeln
wa_data_file-ebelp.
APPEND wa_data_file TO fp_flatfile.
ENDIF.
ENDDO.
CLOSE DATASET FNAME.
ENDIF.
ENDIF.
ENDFORM. " upload_file_app
*&--------------------------------------------------------------------*
*&
Form get_podata
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
form get_podata.
select *
into table t_update
from zvtls_sap
for all entries in t_flatfile_vtls1
where itemvtls = t_flatfile_vtls1-item
and povtls = t_flatfile_vtls1-po.
sort t_update by posap itemsap.
loop at t_update.
at new posap.
t_poheader-po = t_update-posap.
append t_poheader.
clear t_poheader.
endat.
t_poitem-po = t_update-posap.
t_poitem-item = t_update-itemsap.
append t_poitem.
clear t_poitem.
t_update-paedt = sy-datum.
t_update-loekz = 'X'.
modify t_update.
endloop.
modify zvtls_sap from table t_update.
endform.
"get_podata
*&--------------------------------------------------------------------*
*&
Form move_to_bapi
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
form move_to_bapi.
t_bapi_poheader-po_number = t_poheader-po.
CLEAR t_bapi_poheaderx.
PERFORM fill_check_structure USING c_bapimepoheaderx
c_t_bapi_poheader
c_t_bapi_poheaderx
c_x.
refresh : t_bapi_poitem,t_bapi_poitemx.
loop at t_poitem where po = t_poheader-po.
clear t_bapi_poitem.
t_bapi_poitem-po_item = t_poitem-item.
t_bapi_poitem-delete_ind = 'X'.
CLEAR t_bapi_poitemx.
PERFORM fill_check_structure USING c_bapimepoitem
c_t_bapi_poitem
c_t_bapi_poitemx
c_x.
t_bapi_poitemx-po_item = t_poitem-item.
t_bapi_poitemx-po_itemx = c_x.
APPEND t_bapi_poitem.
APPEND t_bapi_poitemx.
clear t_bapi_poitem.
clear t_bapi_poitemx.
endloop.
endform.
"move_to_bapi
*&--------------------------------------------------------------------*
*&
Form call_bapi
*&--------------------------------------------------------------------*
*
This form Routine is used to commit the data records
*----------------------------------------------------------------------*
FORM call_bapi .
DATA : l_msgty
TYPE c,
l_msgid(2) TYPE c,
l_msgno(3) TYPE c,
l_msgtx(100) TYPE c,
l_errflag TYPE c.
CLEAR: t_bapireturn.
REFRESH: t_bapireturn.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = T_POHEADER-PO
POHEADER
= T_BAPI_POHEADER
POHEADERX = T_BAPI_POHEADERX
TABLES
RETURN
= T_BAPIRETURN
POITEM
= T_BAPI_POITEM
POITEMX
= T_BAPI_POITEMX.
READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ENDIF.
*C-- Write messages
WRITE: / 'PO Number', t_poheader-po.
clear : t_update,w_povtls.
read table t_update with key posap = t_poheader-po.
w_povtls = t_update-povtls.
CLEAR l_errflag.
LOOP AT t_bapireturn.
CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.
l_msgty = t_bapireturn-type.
l_msgid = t_bapireturn-id.
l_msgno = t_bapireturn-number.
l_msgtx = t_bapireturn-message.
WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.
if l_msgtx cs t_poheader-po.
w_count = w_count + 1.
loop at t_update.
if sy-tabix = w_count.
t_message-item = t_update-itemvtls.
endif.
endloop.
endif.
t_message-msgty = l_msgty.
t_message-msgid = l_msgid.
t_message-msgno = l_msgno.
t_message-msgtx = l_msgtx.
t_message-po = w_povtls.
append t_message.
clear t_message.
IF l_msgty EQ c_err.
l_errflag = c_x.
ENDIF. " l_msgty EQ 'E'
ENDLOOP.
ULINE.
IF l_errflag NE c_x.
w_success = w_success + 1.
ENDIF. " l_errflag NE C_X
endform.
"call_bapi
*&--------------------------------------------------------------------*
*&
Form fill_check_structure
*&--------------------------------------------------------------------*
*
This form Routine will check whether the specified structure
*
exist/active
*---------------------------------------------------------------------*
FORM fill_check_structure USING fp_tabname TYPE any
fp_orgtabname TYPE any
fp_chktabname TYPE any
fp_check TYPE c.
FIELD-SYMBOLS : <fs_chk>, <fs_org>.
DATA: l_char1(61) TYPE c,
l_char2(61) TYPE c.
DATA: BEGIN OF tl_nametab OCCURS 60.
INCLUDE STRUCTURE x031l.
DATA: END OF tl_nametab.
REFRESH tl_nametab.
CALL FUNCTION 'RFC_GET_NAMETAB'
EXPORTING
tabname
= fp_tabname
TABLES
nametab
= tl_nametab
EXCEPTIONS
table_not_active = 1
OTHERS
= 2.
IF sy-subrc <> 0.
CLEAR tl_nametab.
ENDIF.
LOOP AT tl_nametab.
CLEAR: l_char1, l_char2.
CONCATENATE fp_chktabname c_hyp tl_nametab-fieldname INTO l_char1.
ASSIGN (l_char1) TO <fs_chk>.
CONCATENATE fp_orgtabname c_hyp tl_nametab-fieldname INTO l_char2.
ASSIGN (l_char2) TO <fs_org>.
IF <fs_org> IS NOT INITIAL.
<fs_chk> = fp_check.
ENDIF.
ENDLOOP.
ENDFORM.
" fill_check_structure
*&--------------------------------------------------------------------*
*&
Form STORE_MESSAGES
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
*
-->FP_MESSAGEStext
*---------------------------------------------------------------------*
FORM STORE_MESSAGES TABLES FP_MESSAGES STRUCTURE T_MESSAGE.
DATA: wl_output_data LIKE t_MESSAGE.
DATA: l_catstr TYPE string.
DATA: l_fieldvalue TYPE string.
DATA: l_index TYPE i VALUE 1.
DATA: L_FNAME(60).
FIELD-SYMBOLS <fs>.
CLEAR l_catstr.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = '/USR/SAP/VTLS/POCHANGE/LOG'
OPERATING_SYSTEM = SY-OPSYS
IMPORTING
FILE_NAME
= L_FNAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS
= 2.
IF SY-SUBRC = '0'.
IF fp_messages[] IS NOT INITIAL.
OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
LEAVE LIST-PROCESSING.
ELSE.
LOOP AT fp_messages INTO wl_output_data.
DO.
ASSIGN COMPONENT l_index OF STRUCTURE wl_output_data TO <fs>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
MOVE <fs> TO l_fieldvalue.
IF l_catstr IS NOT INITIAL.
ENDFORM.
"STORE_MESSAGES
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* ORDER_CCARD =
* ORDER_TEXT =
* ORDER_KEYS =
* EXTENSIONIN =
* PARTNERADDRESSES =
.
-----Reply Message----Subject: RE: BAPI to create Sales Order with reference
FM BAPI_SALESDOCUMENT_COPY is what you are looking for. Don't know when SAP
released this one, but its not there in 4.0B and is available in rel 4.6C
-----End of Message----BAPI_SALESORDER_CREATEFROMDAT2 - Sales Order Create
Please help with an exact code which this BAPI is used for creating Sales order so that I can refer.
*&---------------------------------------------------------------------*
*& Report ZBAPI_SALESORDER_CREATE
*&
*&---------------------------------------------------------------------*
*&
*& Author : Karthik
*&---------------------------------------------------------------------*
REPORT ZBAPI_SALESORDER_CREATE.
data : ORDER_HEADER_IN like BAPISDHD1.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
header line.
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LINE.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
data : BEGIN OF TAB OCCURS 0,
SRNO(4),
DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
DIVISION like ORDER_HEADER_IN-DIVISION,
*
REQ_DATE_H(10),
PURCH_DATE(10),
PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
ITM_NUMBER like BAPISDITM-ITM_NUMBER,
CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
PLANT LIKE ORDER_ITEMS_IN-PLANT,
TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
END OF TAB.
data: itab1 like alsmex_tabline occurs 0 with header
line.
DATA: gd_currentrow type i.
data : PURCHASEORDER like ekko-ebeln.
Data: tot_rec type i, "Total Records
gd_update type i, "Main Table Increement Counter
gd_lines type i, "Success Table increement Counter
w_textout like t100-text. "VARIABLE TO GET ERRORLOG
data : begin of it_success occurs 0,
SALESDOCUMENT LIKE BAPIVBELN-VBELN, "PROJECT
end of it_success.
data : begin of it_error occurs 0,
srno(4),
err_msg(73) TYPE c, "TO RETREIVE ERROR MESSAGES
end of it_error.
data : srno(4).
DATA : SALESDOCUMENT LIKE BAPIVBELN-VBELN.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename
= p_infile
i_begin_col
= '1'
i_begin_row
= '2' "Do not require
headings
i_end_col
= '22'
i_end_row
= '10000'
TABLES
intern
= itab1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole
=2
others
= 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading
Excel Spreadsheet
endif.
*perform open_group.
sort itab1 by row col.
* Get first row retrieved
read table itab1 index 1.
* Set first row retrieved to current row
gd_currentrow = itab1-row.
loop at itab1.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
AT END OF SRNO.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN
=
ORDER_HEADER_IN
= ORDER_HEADER_IN
ORDER_HEADER_INX
=
SENDER
=
BINARY_RELATIONSHIPTYPE
=
INT_NUMBER_ASSIGNMENT
=
BEHAVE_WHEN_ERROR
=
LOGIC_SWITCH
=
TESTRUN
=
CONVERT
=''
IMPORTING
SALESDOCUMENT
= SALESDOCUMENT
TABLES
RETURN
= RETURN
ORDER_ITEMS_IN
= ORDER_ITEMS_IN
ORDER_ITEMS_INX
=
ORDER_PARTNERS
= ORDER_PARTNERS
ORDER_SCHEDULES_IN
= ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX
=
ORDER_CONDITIONS_IN
=
ORDER_CONDITIONS_INX
=
ORDER_CFGS_REF
=
ORDER_CFGS_INST
=
ORDER_CFGS_PART_OF
=
ORDER_CFGS_VALUE
=
ORDER_CFGS_BLOB
=
ORDER_CFGS_VK
=
ORDER_CFGS_REFINST
=
ORDER_CCARD
=
ORDER_TEXT
=
*
*
ORDER_KEYS
= ORDER_KEYS
EXTENSIONIN
=
PARTNERADDRESSES
=
.
CLEAR it_success.
ENDLOOP.
WRITE:/ sy-uline(15).
REFRESH: it_success.
FORMAT COLOR COL_BACKGROUND.
ENDFORM.
"
DISPLAY_REPORT
*&---------------------------------------------------------------------*
*&
Form errorreport
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM errorreport.
LOOP AT it_error.
WRITE:/
sy-vline,
(10) it_error-SRNO, sy-vline,
(40) it_error-err_msg, sy-vline.
ENDLOOP.
WRITE:/ sy-uline(104).
REFRESH: it_error.
endform.
"errorreport
*&---------------------------------------------------------------------*
*&
Form ERRORHEADINGS
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM ERRORHEADINGS.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during
update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/
sy-vline,
(10) 'ERROR.'(009), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM.
"ERRORHEADINGS
**&--------------------------------------------------------------------**
**&
Form value_help
**&--------------------------------------------------------------------**
**
text
**---------------------------------------------------------------------**
** --> p1
text
** <-- p2
text
**---------------------------------------------------------------------**
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH
=''
MASK
= ',*.*,*.*.'
MODE
= 'O'
TITLE
=''
IMPORTING
FILENAME
= p_infile
EXCEPTIONS
INV_WINSYS
=1
NO_BATCH
=2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS
= 5.
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.
"value_help
return
= i_return[].
loop at i_customermaterialinfodetail.
write:/ i_customermaterialinfodetail-customer,' - ',i_customermaterialinfodetail-material,' - ',
i_customermaterialinfodetail-mat_nr_cus.
endloop.
end-of-selection.
FUNCTION zbapi_project_maintain.
*"---------------------------------------------------------------------*"*"Local interface:
*" IMPORTING
*" VALUE(WBS_ELEMENT) LIKE BAPI_WBS_ELEMENT-WBS_ELEMENT
*" VALUE(WBS_ELEMENT_DESCRIPTION) LIKE
*"
BAPI_PROJECT_DEFINITION-DESCRIPTION
*" VALUE(WBS_ELEMENT1) LIKE BAPI_WBS_ELEMENT-WBS_ELEMENT
*" VALUE(PROJECT_DEFINITION) LIKE
*"
BAPI_WBS_ELEMENT-PROJECT_DEFINITION
*" VALUE(DESCRIPTION) LIKE BAPI_PROJECT_DEFINITION-DESCRIPTION
*" VALUE(NETWORK) LIKE BAPI_NETWORK-NETWORK
*" VALUE(NETWORK1) LIKE BAPI_NETWORK-NETWORK
*" VALUE(NETWORK_TYPE) LIKE BAPI_NETWORK-NETWORK_TYPE
*" VALUE(PROFILE) LIKE BAPI_NETWORK-PROFILE
*" VALUE(ACTIVITY) LIKE BAPI_NETWORK_ACTIVITY-ACTIVITY
*" VALUE(CONTROL_KEY) LIKE BAPI_NETWORK_ACTIVITY-CONTROL_KEY
*" VALUE(ACT_DESC) LIKE BAPI_NETWORK_ACTIVITY-DESCRIPTION
*" VALUE(NETWORK_PREDECESSOR) LIKE
*"
BAPI_NETWORK_RELATION-NETWORK_PREDECESSOR
*" VALUE(ACTIVITY_PREDECESSOR) LIKE
*"
BAPI_NETWORK_RELATION-ACTIVITY_PREDECESSOR
*" VALUE(NETWORK_SUCCESSOR) LIKE
*"
BAPI_NETWORK_RELATION-NETWORK_SUCCESSOR
*" VALUE(ACTIVITY_SUCCESSOR) LIKE
*"
BAPI_NETWORK_RELATION-ACTIVITY_SUCCESSOR
*" VALUE(RELATION_TYPE) LIKE BAPI_NETWORK_RELATION-RELATION_TYPE
*" VALUE(ELEMENT) LIKE BAPI_ACT_ELEMENT-ELEMENT
*" VALUE(UP) LIKE BAPI_WBS_HIERARCHIE-UP
*" VALUE(DOWN) LIKE BAPI_WBS_HIERARCHIE-DOWN
*" VALUE(LEFT) LIKE BAPI_WBS_HIERARCHIE-LEFT
*" VALUE(RIGHT) LIKE BAPI_WBS_HIERARCHIE-RIGHT
*" VALUE(UP1) LIKE BAPI_WBS_HIERARCHIE-UP
*" VALUE(DOWN1) LIKE BAPI_WBS_HIERARCHIE-DOWN
*" VALUE(LEFT1) LIKE BAPI_WBS_HIERARCHIE-LEFT
*" VALUE(RIGHT1) LIKE BAPI_WBS_HIERARCHIE-RIGHT
*" VALUE(VPLANT) LIKE BAPI_NETWORK-PLANT
*" VALUE(VPROJ_TYPE) LIKE BAPI_WBS_ELEMENT-PROJ_TYPE
*" TABLES
*"
WBS_CREATE_ERROR STRUCTURE BAPI_METH_MESSAGE OPTIONAL
*"
NETWORK_CREATE_ERROR STRUCTURE BAPI_METH_MESSAGE OPTIONAL
*"
WBS_HIERARCHY_ERROR STRUCTURE BAPI_METH_MESSAGE OPTIONAL
*"
ACTIVITY_CREATE_ERROR STRUCTURE BAPI_METH_MESSAGE OPTIONAL
*"
ACTIVITY_RELATION_ERROR STRUCTURE BAPI_METH_MESSAGE OPTIONAL
*"---------------------------------------------------------------------DATA : BEGIN OF itproj OCCURS 0.
INCLUDE STRUCTURE bapi_project_definition.
DATA :END OF itproj.
DATA : BEGIN OF itprojupd OCCURS 0.
INCLUDE STRUCTURE bapi_project_definition_up.
DATA :END OF itprojupd.
DATA : BEGIN OF itwbsmethod OCCURS 0.
INCLUDE STRUCTURE bapi_method_project.
DATA :END OF itwbsmethod.
DATA : BEGIN OF itwbs OCCURS 0.
INCLUDE STRUCTURE bapi_wbs_element.
DATA :END OF itwbs.
DATA : BEGIN OF itnetmethod OCCURS 0.
INCLUDE STRUCTURE bapi_method_project.
DATA :END OF itnetmethod.
DATA : BEGIN OF itnetwork OCCURS 0.
INCLUDE STRUCTURE bapi_network.
DATA :END OF itnetwork.
DATA : BEGIN OF itwbshierarchy OCCURS 0.
INCLUDE STRUCTURE bapi_wbs_hierarchie.
DATA :END OF itwbshierarchy.
DATA : BEGIN OF iterr OCCURS 0.
INCLUDE STRUCTURE bapi_meth_message .
DATA :END OF iterr.
DATA : iterr1 LIKE bapi_meth_message OCCURS 0 WITH HEADER LINE.
DATA : itemsg LIKE bapi_meth_message OCCURS 0 WITH HEADER LINE.
DATA : itemsg1 LIKE bapi_meth_message OCCURS 0 WITH HEADER LINE.
DATA : itemsg2 LIKE bapi_meth_message OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF itactivity OCCURS 0.
INCLUDE STRUCTURE bapi_network_activity.
DATA :END OF itactivity.
DATA : BEGIN OF itactmethod OCCURS 0.
INCLUDE STRUCTURE bapi_network_activity_up.
DATA :END OF itactmethod.
DATA :BEGIN OF itrelation OCCURS 0.
INCLUDE STRUCTURE bapi_network_relation.
DATA :END OF itrelation.
DATA : v_str(100) TYPE c.
DATA : v_str1(34) TYPE c.
IF NOT wbs_element IS INITIAL AND
NOT project_definition IS INITIAL.
* AND NOT description IS INITIAL.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
ENDIF.
LOOP AT iterr.
MOVE : iterr-method to wbs_create_error-method,
iterr-object_type to wbs_create_error-OBJECT_TYPE,
iterr-internal_object_id to
wbs_create_error-INTERNAL_OBJECT_ID,
iterr-external_object_id to
wbs_create_error-EXTERNAL_OBJECT_ID,
iterr-message_id to wbs_create_error-MESSAGE_ID,
iterr-message_number to wbs_create_error-MESSAGE_NUMBER,
iterr-message_type to wbs_create_error-MESSAGE_TYPE,
iterr-message_text to wbs_create_error-MESSAGE_TEXT.
append wbs_create_error.
clear iterr.
endloop.
COMMIT WORK .
WAIT UP TO 1 SECONDS.
ENDIF. " if not wbs_element initial
************ create network ***********
if not network is initial.
MOVE '000001' TO itnetmethod-refnumber.
MOVE 'NETWORK' TO itnetmethod-objecttype.
MOVE 'CREATE' TO itnetmethod-method.
MOVE network TO itnetmethod-objectkey.
APPEND itnetmethod.
MOVE '000000' TO itnetmethod-refnumber.
MOVE ' ' TO itnetmethod-objecttype.
MOVE 'SAVE' TO itnetmethod-method.
MOVE ' ' TO itnetmethod-objectkey.
APPEND itnetmethod.
MOVE network TO itnetwork-network.
MOVE network_type TO itnetwork-network_type.
MOVE vplant TO itnetwork-plant.
MOVE 'NEW NETWORK' TO itnetwork-short_text.
MOVE wbs_element TO itnetwork-wbs_element.
MOVE '001' TO itnetwork-mrp_controller.
MOVE project_definition TO itnetwork-project_definition.
MOVE profile TO itnetwork-profile.
APPEND itnetwork.
REFRESH itemsg.
*
*
*
*
*
*
*
*
*
*
*
I_RELATION
=
I_RELATION_UPDATE
=
e_message_table
= itemsg.
I_ACTIVITY_ELEMENT
=
I_ACTIVITY_ELEMENT_UPDATE =
I_ACTIVITY_MILESTONE
=
I_ACTIVITY_MILESTONE_UPDATE =
IF sy-subrc = 0.
ENDIF.
LOOP AT itemsg.
MOVE : itemsg-method to network_create_error-method,
itemsg-object_type to network_create_error-OBJECT_TYPE,
itemsg-internal_object_id to
network_create_error-INTERNAL_OBJECT_ID,
itemsg-external_object_id to
network_create_error-EXTERNAL_OBJECT_ID,
itemsg-message_id to network_create_error-MESSAGE_ID,
itemsg-message_number to
network_create_error-MESSAGE_NUMBER,
itemsg-message_type to network_create_error-MESSAGE_TYPE,
itemsg-message_text to network_create_error-MESSAGE_TEXT.
append network_create_error.
clear itemsg.
endloop.
COMMIT WORK .
WAIT UP TO 1 SECONDS.
endif. "if not network is initial.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
COMMIT WORK .
WAIT UP TO 1 SECONDS.
*********************** create network relationship*********************
CLEAR : itnetmethod,itemsg2,itnetwork,itrelation.
REFRESH :itnetmethod,itemsg2,itnetwork,itrelation.
MOVE '000001' TO itnetmethod-refnumber.
MOVE 'NETWORKRELATION' TO itnetmethod-objecttype.
MOVE 'CREATE' TO itnetmethod-method.
CONCATENATE relation_type network_predecessor activity_predecessor
network_successor activity_successor INTO v_str1.
MOVE v_str1 TO itnetmethod-objectkey.
APPEND itnetmethod.
CLEAR itnetmethod.
MOVE 'SAVE' TO itnetmethod-method.
APPEND itnetmethod.
CLEAR itnetmethod.
MOVE network1 TO itnetwork-network.
APPEND itnetwork.
CLEAR itnetwork.
MOVE network_predecessor TO itrelation-network_predecessor.
MOVE activity_predecessor TO itrelation-activity_predecessor.
MOVE network_successor TO itrelation-network_successor.
MOVE activity_successor TO itrelation-activity_successor.
MOVE relation_type TO itrelation-relation_type.
APPEND itrelation.
CLEAR itrelation.
*
*
*
*
*
*
*
*
*
*
append activity_relation_error.
clear itemsg2.
endloop.
.
COMMIT WORK .
WAIT UP TO 1 SECONDS.
ENDFUNCTION.
Loading Purchase Orders Using BAPI_PO_CREATE
Pls check if this code. I used this to upload po.
*&---------------------------------------------------------------------*
*& Report ZBAPI_PO_CRATE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZBAPI_PO_CRATE.
data : PO_HEADER like BAPIEKKOC.
data : PO_HEADER_ADD_DATA like BAPIEKKOA.
data : PO_ITEMS like BAPIEKPOC occurs 0 with header
line.
data : PO_ITEM_SCHEDULES like BAPIEKET occurs 0 with
header line.
data : RETURN like BAPIRETURN occurs 0 with header
line.
DATA : BEGIN OF TAB OCCURS 0,
PO_NUMBER like BAPIEKKOC-PO_NUMBER,
DOC_DATE(10),
DOC_TYPE like BAPIEKKOC-DOC_TYPE,
CO_CODE like BAPIEKKOC-CO_CODE,
PURCH_ORG like BAPIEKKOC-PURCH_ORG,
PUR_GROUP like BAPIEKKOC-PUR_GROUP,
VENDOR like BAPIEKKOC-VENDOR,
PMNTTRMS like BAPIEKKOA-PMNTTRMS,
INCOTERMS1 like BAPIEKKOA-INCOTERMS1,
INCOTERMS2 like BAPIEKKOA-INCOTERMS2,
PO_ITEM like BAPIEKPOC-PO_ITEM,
MATERIAL like BAPIEKPOC-MATERIAL,
PUR_MAT like BAPIEKPOC-PUR_MAT,
ITEM_CAT like BAPIEKPOC-ITEM_CAT,
PLANT like BAPIEKPOC-PLANT,
NET_PRICE like BAPIEKPOC-NET_PRICE,
TAX_CODE like BAPIEKPOC-TAX_CODE,
DELIV_DATE(10),
QUANTITY like BAPIEKET-QUANTITY,
end of tab.
data: itab1 like alsmex_tabline occurs 0 with header
line.
DATA: gd_currentrow type i.
data : PURCHASEORDER like ekko-ebeln.
Data: tot_rec type i, "Total Records
gd_update type i, "Main Table Increement
Counter
gd_lines type i, "Success Table increement
Counter
w_textout like t100-text. "VARIABLE TO GET ERROR
LOG
data : begin of it_success occurs 0,
PURCHASEORDER LIKE ekko-ebeln, "PROJECT
end of it_success.
data : begin of it_error occurs 0,
pono like ekko-ebeln,
err_msg(73) TYPE c, "TO RETREIVE ERROR
MESSAGES
end of it_error.
data : pono like ekko-ebeln.
selection-screen begin of block b1 with frame.
skip 3.
parameter:p_infile like rlgrap-filename obligatory.
skip 3.
selection-screen end of block b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
PERFORM value_help.
start-of-selection.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename
= p_infile
i_begin_col
= '1'
i_begin_row
= '2' "Do not require
headings
i_end_col
= '22'
i_end_row
= '10000'
TABLES
intern
= itab1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole
=2
others
= 3.
if sy-subrc <> 0.
message e010(zz) with text-001. "Problem uploading
Excel Spreadsheet
endif.
*perform open_group.
sort itab1 by row col.
* Get first row retrieved
read table itab1 index 1.
* Set first row retrieved to current row
gd_currentrow = itab1-row.
loop at itab1.
* Reset values for next row
if itab1-row ne gd_currentrow.
append tab .
clear tab.
gd_currentrow = itab1-row.
endif.
case itab1-col.
when '0001'. "PGNAM
TAB-PO_NUMBER = itab1-value.
when '0002'. "RONAM
TAB-DOC_DATE = itab1-value.
when '0003'. "JVLEVEL
TAB-DOC_TYPE = itab1-value.
when '0004'. "FTTYPE
TAB-CO_CODE = itab1-value.
when '0005'. "LANG
TAB-PURCH_ORG = itab1-value.
when '0006'. "LTEXT
TAB-PUR_GROUP = itab1-value.
when '0007'. "LTEXT
TAB-VENDOR = itab1-value.
when '0008'. "LTEXT
TAB-PMNTTRMS = itab1-value.
when '0009'. "LTEXT
TAB-INCOTERMS1 = itab1-value.
when '0010'. "FTTYPE
TAB-INCOTERMS2 = itab1-value.
when '0011'. "FTTYPE
TAB-PO_ITEM = itab1-value.
when '0012'. "FTTYPE
TAB-MATERIAL = itab1-value.
when '0013'. "FTTYPE
TAB-PUR_MAT = itab1-value.
when '0014'. "FTTYPE
TAB-ITEM_CAT = itab1-value.
when '0015'. "FTTYPE
shift itab1-value left deleting leading space.
TAB-PLANT = itab1-value.
when '0016'. "FTTYPE
TAB-NET_PRICE = itab1-value.
when '0017'. "FTTYPE
TAB-TAX_CODE = itab1-value.
when '0018'. "FTTYPE
TAB-DELIV_DATE = itab1-value.
when '0019'. "FTTYPE
TAB-QUANTITY = itab1-value.
endcase.
endloop.
append tab.
clear tab.
sort tab by PO_NUMBER.
DELETE TAB WHERE PO_NUMBER = SPACE.
loop at tab.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-material
IMPORTING
OUTPUT = tab-material.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-PUR_MAT
IMPORTING
OUTPUT = tab-PUR_MAT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = tab-vendor
IMPORTING
OUTPUT = tab-vendor.
concatenate tab-doc_DATE+4(4) tab-doc_DATE+2(2)
tab-doc_DATE+0(2)
into tab-doc_DATE.
concatenate tab-DELIV_DATE+4(4)
tab-DELIV_DATE+2(2)
tab-DELIV_DATE+0(2) into tab-DELIV_DATE.
pono = tab-PO_NUMBER.
if tab-po_number = pono.
PO_HEADER-DOC_DATE = tab-DOC_DATE.
PO_HEADER-DOC_TYPE = tab-DOC_TYPE.
PO_HEADER-CO_CODE = tab-CO_CODE.
PO_HEADER-PURCH_ORG = tab-PURCH_ORG.
PO_HEADER-PUR_GROUP = tab-PUR_GROUP.
PO_HEADER-VENDOR = tab-VENDOR.
PO_HEADER-PO_NUMBER = tab-PO_NUMBER.
PO_HEADER_ADD_DATA-PMNTTRMS = tab-PMNTTRMS.
PO_HEADER_ADD_DATA-INCOTERMS1 = tab-INCOTERMS1.
PO_HEADER_ADD_DATA-INCOTERMS2 = tab-INCOTERMS2.
PO_ITEMS-PO_ITEM = tab-PO_ITEM.
PO_ITEMS-MATERIAL = tab-MATERIAL.
PO_ITEMS-PUR_MAT = tab-PUR_MAT.
PO_ITEMS-ITEM_CAT = tab-ITEM_CAT.
PO_ITEMS-PLANT = tab-PLANT.
PO_ITEMS-NET_PRICE = tab-NET_PRICE.
PO_ITEMS-TAX_CODE = tab-TAX_CODE.
append po_items.
PO_ITEM_SCHEDULES-PO_ITEM = tab-PO_ITEM.
PO_ITEM_SCHEDULES-DELIV_DATE = tab-DELIV_DATE.
PO_ITEM_SCHEDULES-QUANTITY = tab-QUANTITY.
append PO_ITEM_SCHEDULES.
endif.
at end of PO_NUMBER.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER
= PO_HEADER
PO_HEADER_ADD_DATA
=
PO_HEADER_ADD_DATA
*
HEADER_ADD_DATA_RELEVANT
=
*
PO_ADDRESS
=
*
SKIP_ITEMS_WITH_ERROR
= 'X'
*
ITEM_ADD_DATA_RELEVANT
=
*
HEADER_TECH_FIELDS
=
IMPORTING
PURCHASEORDER
=
PURCHASEORDER
TABLES
PO_ITEMS
= PO_ITEMS
PO_ITEM_ADD_DATA
=
PO_ITEM_SCHEDULES
=
PO_ITEM_SCHEDULES
*
PO_ITEM_ACCOUNT_ASSIGNMENT
*
PO_ITEM_TEXT
=
RETURN
= RETURN
*
PO_LIMITS
=
*
PO_CONTRACT_LIMITS
=
*
PO_SERVICES
=
*
PO_SRV_ACCASS_VALUES
=
*
PO_SERVICES_TEXT
=
*
PO_BUSINESS_PARTNER
=
*
EXTENSIONIN
=
*
POADDRDELIVERY
=
.
"errorreport
*&---------------------------------------------------------------------*
*&
Form ERRORHEADINGS
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM ERRORHEADINGS.
SKIP.
WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
SKIP.
WRITE:2 'The following records failed during
update:'(008).
WRITE:/ sy-uline(104).
FORMAT COLOR COL_HEADING.
WRITE:/
sy-vline,
(10) 'ERROR.'(009), sy-vline.
WRITE:/ sy-uline(104).
FORMAT COLOR COL_NORMAL.
ENDFORM.
"ERRORHEADINGS
**&--------------------------------------------------------------------**
**&
Form value_help
**&--------------------------------------------------------------------**
**
text
**---------------------------------------------------------------------**
** --> p1
text
** <-- p2
text
**---------------------------------------------------------------------**
FORM value_help .
CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH
=''
MASK
= ',*.*,*.*.'
MODE
= 'O'
TITLE
=''
IMPORTING
FILENAME
= p_infile
EXCEPTIONS
INV_WINSYS
=1
NO_BATCH
=2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS
= 5.
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.
"value_help
What is BDC?
Batch Data Communication or BDC is a batch interfacing technique that SAP developed. It is mainly used
for uploading data into the SAP R/3 system. BDC works by simulating the user input from transactional
screen via an ABAP program.
The data input data file will come in the form of a flat file which the user save as file type txt file or prn file
from the Microsoft Excel program. An Abaper will create a program to read the text file and upload into the
SAP system.
Normally, the tcode SHDB will be used to record the transaction code the user used. After, the simulation,
the Abaper can generate a sample program and modify from there. It makes the programming easier and
faster.
Learning BDC Programming
I want to learn how to upload data using BDC. If I have a excel data file how will upload it using BDC.
I don't know the full process of doing it, if someone help me in this. I want it using BDC session
process and processing that session. I was trying to upload material master other day. But could not
follow the process of uploading using BDC though I know LSMW. Please explain me the BDC
process in details with examples.
For a BDC upload you need to write a program which created BDC sessions.
Steps:
1. Work out the transaction you would use to create the data manually.
2. Use transaction SHDB to record the creation of one material master data.
Click the New recording button or the Menu - Recording - Create
3. Save the recording, and then go back a screen and go to the overview.
4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer
from recording.
5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to
make the following changes:
5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB
separated).
5.2 After the open-group, Loop on the uploaded data. For each line, perform validation checks on the data,
then modify the perform bdc_field commands to use the file data.
5.3. After perform bdc_transaction, add the endloop.
Execute the program. It will have options to create a batch session or to process directly.
These are all my finds . Might be it will be useful to you.
Direct call of transactions, session handling:
/nxxxx This terminates the current transaction, and starts transaction xxxx
/n This terminates the transaction. This generally corresponds to pressing F15 to go back.
/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff).
/nex This terminates all separate sessions and logs off immediately (without any warning!).
/oxxxx This opens a new session and starts transaction xxxx in This session.
/o This lists existing sessions and allows deletion or opening of a new session.
/i This terminates the current session (corresponds to System End
/i1, /i2,... This terminates the session with the number given.
.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon
and is provided more for emergencies (such as a defective mouse).
Batch
The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only')
when processing a batch input session:
/n This terminates the current batch input transaction and characterizes it as
/bdel This deletes the current batch input transaction.
/bend This terminates batch input processing and sets the session to Failed
/bda This switches from Display errors only to Process in foreground
/bde This switches from Process in foreground to Display errors only
ABAP/4
/h This switches into debugging mode.
/hs This switches into debugging mode and activates the debugging of system functions.
Buffer
WARNING: Resetting buffers can significantly change the performance of the entire system for a long time.
It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator
authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log.
/$SYNC This resets all buffers of the application server
/$CUA This resets the CUA buffer of the application server
/$TAB This resets the TABLE buffers of the application server
/$NAM This resets the nametab buffer of the application server
/$DYNP This resets the screen buffer of the application server
What is recording?
As the word record implies, it mean recording the keystroke of the user input of a SAP transaction screen.
Why it is used?
It is normally used for mass update or uploading of data to the system.
What is its need?
It help to save time for the users who need to mass change the system data. For e.g. tax rate change
announce by the country government.
How it is related with bdc?
It is related to bdc because bdc programming allows recording of user inputs
Question About BDC Program
What is bdc_okcode?
It is the user command that was executed. eg. '/00' means Enter command.
The user command can varies during a bdc program. Therefore, we need to used tcode shdb to check what
it actually contains.
What is the function key values of BDC_OKCODE ie '/00' what this is for?
How will we handle the errors in call transaction method?
'/00' is generally the BDC_OKCODE for the ENTER key.
You don't need to know the list of the BDC_OKCODE s.
You go to the transaction SHDB.
You can execute any transaction here.
Then you can replay the execution of the trasaction afterwards.
Select 'display all screens' mode.
BDC_OKCODEs for each one functions you use is displayed on the screen.
Now, regarding the error handling in call transaction.
The BDCMSGCOLL does not have the messages text. It has only the message type, number and message
parameters.
You have to read the message text. (recall that the database table T100 stores all the messages.)
There are more than one method of doing this.
Following is the psuedocode for one of the methods.
LOOP for the internal table IT1 which has data value from flat file.
A: SAP standard program RSBDCSUB helps you to schedule the job. Create a variant for RSBDCSUB with
the BDC session name.
Q: How can we send a mail to the user intimating him that his report/BDC is completed in
background?
A: You can use FUNCTION RS_SEND_MAIL_FOR_SPOOLLIST
If UNIX is being used, you may send a report to any internet mail with the following:
REPORT ZSNDMAIL.
DATA: COMND (200) type c.
DATA: RESULT (200) type c occurs 100 with header line.
PARAMETERS: FILE (60) type c lower case default '/sapdata/sd_outbound/testmail.dat'.
PARAMETERS: SUBJECT (60) type c lower case.
PARAMETERS: EMAIL (60) type c lower case.
INITIALIZATION.
TRANSLATE EMAIL TO LOWER CASE.
START-OF-SELECTION.
TRANSLATE EMAIL TO LOWER CASE.
CONCATENATE 'cat' FILE '| elm -s "' subject '"' email into comnd seperated by space.
CALL 'SYSTEM' ID 'COMMAND' FIELD comnd 'TAB' FIELD UNIX_RESULTS-*SYS*.
Loop at Results.
write: /1 results.
endloop
end-of-selection.
Interview Question on BDC
What is BDC- its use, and how to use it?
It is Batch Data conversion used for transferring some data other than sap into sap ... this is also a work of
an ABAPer.
What is "UTS" Or may be it is "UST", something called Unit test?
Use: After developing any object we should write a test case proving that the object is working properly or
not. This is done by the ABAPer. This is UNIT TEST CASE.
In BDC how can we handle Table Controls?
When you do your recording you will have a tab for Next line or Insert. You have to capture that in your
recording. If your transaction code doesn't have that in the recording then you have to set up a page down
(=P+) and loop it based on the line entries u c on teh screen.
Suppose we are transfer data through BDC from leagacy to SAP and their is some duplicate data in
legacy system but we don't want this in SAP system .So how can we check that this data is already
exist?
In BDC you would have all your legacy data in an internal table. Use Delete Adjacent dulpicates syntax to
delete duplicate entries.
Can we use two transaction code in one BDC like XK01 & XD01 if yes how?
Yes, we can do that by combining the two bdc program codes together. Then you perform the program
routine accordingly. However, it will make your BDC program very long and complex.
How can we handle errors in Function Module?
Can anybody tell me, if we are using excel sheet as a data provider for BDC Program, then how to
define a delimiter so that my BDC programe should automatically split the field.
You either save the excel sheet as Tab delimited file or .csv file. and declare your internal table to get the
corresponding the contents from the file. Then when its tab delimited or .csv, SPLIT the contents into
respective fields.
Here is a sample for CSV file :
*declaration of internal tables.
DATA : BEGIN OF IT_DUMMY OCCURS 0,
TEXT(500),
END OF IT_DUMMY.
DATA : BEGIN OF IT_MAIN OCCURS 0,
MATNR LIKE RMMG1-MATNR,
"material selection to change
DISLS LIKE MARC-DISLS,
"lot size key
END OF IT_MAIN.
*
error session opened (' ' or 'X')
DATA: E_GROUP_OPENED.
*
message texts
TABLES: T100.
*----------------------------------------------------------------------*
* at selection screen
*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
* group and user must be filled for create session
IF SESSION = 'X' AND
GROUP = SPACE OR USER = SPACE.
MESSAGE E613(MS).
ENDIF.
*----------------------------------------------------------------------*
* open dataset
*
*----------------------------------------------------------------------*
FORM OPEN_DATASET USING P_DATASET.
OPEN DATASET P_DATASET IN TEXT MODE.
IF SY-SUBRC <> 0.
WRITE: / TEXT-E00, SY-SUBRC.
STOP.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
* close dataset
*
*----------------------------------------------------------------------*
FORM CLOSE_DATASET USING P_DATASET.
CLOSE DATASET P_DATASET.
ENDFORM.
*----------------------------------------------------------------------*
* create batchinput session
*
* (not for call transaction using...)
*
*----------------------------------------------------------------------*
FORM OPEN_GROUP.
IF SESSION = 'X'.
SKIP.
WRITE: /(20) 'Create group'(I01), GROUP.
SKIP.
* open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = GROUP
USER = USER
KEEP = KEEP
HOLDDATE = HOLDDATE.
WRITE: /(30) 'BDC_OPEN_GROUP'(I02),
(12) 'returncode:'(I05),
SY-SUBRC.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
* end batchinput session
*
* (call transaction using...: error session)
*
*----------------------------------------------------------------------*
FORM CLOSE_GROUP.
IF SESSION = 'X'.
* close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
(12) 'returncode:'(I05),
SY-SUBRC.
ELSE.
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /.
WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
ENDIF.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
*
Start new transaction according to parameters
*
*----------------------------------------------------------------------*
FORM BDC_TRANSACTION USING TCODE.
DATA: L_MSTRING(480).
DATA: L_SUBRC LIKE SY-SUBRC.
* batch input session
IF SESSION = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = TCODE
TABLES DYNPROTAB = BDCDATA.
IF SMALLLOG <> 'X'.
WRITE: / 'BDC_INSERT'(I03),
TCODE,
'returncode:'(I05),
SY-SUBRC,
'RECORD:',
SY-INDEX.
ENDIF.
* call transaction using
ELSE.
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE CTUMODE
UPDATE CUPDATE
MESSAGES INTO MESSTAB.
L_SUBRC = SY-SUBRC.
IF SMALLLOG <> 'X'.
*
WRITE: / 'CALL_TRANSACTION',
*
TCODE,
*
'returncode:'(I05),
*
L_SUBRC,
*
'RECORD:',
*
SY-INDEX.
IF SY-SUBRC = 0.
FORMAT COLOR OFF.
WRITE:/ 'Successfully Process ', MESSTAB, RECORD.
ELSE.
FORMAT COLOR COL_NEGATIVE.
WRITE:/ 'Failed Process ', MESSTAB, RECORD.
ENDIF.
LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
ELSE.
WRITE: / MESSTAB.
ENDIF.
ENDLOOP.
SKIP.
ENDIF.
** Erzeugen fehlermappe ************************************************
IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
IF E_GROUP_OPENED = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = E_GROUP
USER = E_USER
KEEP = E_KEEP
HOLDDATE = E_HDATE.
E_GROUP_OPENED = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = TCODE
TABLES DYNPROTAB = BDCDATA.
ENDIF.
ENDIF.
REFRESH BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
*
Start new screen
*
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
*
Insert field
*
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
N+(N/2) th record if not ok goto N-(N/2) th record where N is the curent record number in the flat file . In
about 4 or five checks you will converge on the last uploaded record.
Now from the flat file, remove the lines till the upload is ok & then re-run BDC.
Even here a record may be uploaded partially which has to be manually edited thru se16.
Method..2
Have a zee table for uploads. Just after uploading a record into the sap table, fill this zeetable with few fields
of each the records. In an abort situation this table will tell the story of the update status. Take care to empty
this table occasionally.
What Are RSBDCBTC_SUB and RSBDCSUB Use For
By: Mike
Explain briefly about RSBDCSUB and it uses.
Program rsbdcsub is to execute the session method in background and in foreground, for this you need to
create a session in sm35.
To carry out postings, you can have the system run the batch input sessions automatically. To do this, use
report RSBDCSUB.
To process batch input sessions manually, proceed as follows:
- Choose System -> Services -> Batch input -> Sessions.
The system displays a list of those batch input sessions that meet your selection criteria. Enter the relevant
data for selecting the session.
- Select the session you require and choose Session -> Process.
The system displays a dialog box where you can specify how the session is to be processed. You generally
select the Display errors field in order to have the system display any errors in the session.
- Save your entries.
The system posts the documents. You can call up a log of the batch input session by choosing Goto -> Log.
How to run Batch Input Session from a report in Online?
I have created a Batch Input Session through report program. When the report was executed and
once the Batch Input is created, I want the Batch Input which is created by the report program has to
be processed online. How this can be achieved.
Debugging program RSBDCSUB lead me to find out another program called RSBDCBTC_SUB which just
takes the Queue ID of the Batch session and process it in the No screen mode. I copied this standard
program, made changes so that it always pass the mode as 'A' (All Screens) and used it in my program. I
already had the Queue ID and that's all I want to execute ZRSBDCBTC_SUB.
Variant in Job Log
In a job log, TCode SM37, the program name is given as RSBDCBTC_SUB and the variant is given as
&0000000003325.
1) When I go to the program in SE38 and execute the program, on the selection screen no variant is
maintained. Then from where is it picking up this variant? And where can I see, what are the values
in this variant?
2) Every time the job runs, it picks up a new variant. From where is it picking up these new variants
everyday?
When you run the report at SE38 using execute background ,system will take default variant.
In your case someone is running the program(se38) in background, he fill the values in selection screen and
run on background.
In this case variant is not requeired.
Difference between RSBDCSUB and RSBDCBTC :
RSBDCSUB - You can start the processing of the sessions using this.
RSBDCBTC - This has something to do with the Queues of the batch input sessions, you cannot start any
session using this.
RSBDCSUB is used for executing BDC sessions, e.g. you create BDC sessions in a user exit and want to
execute them once every day. You can schedule RSBDCSUB to execute you BDC sessions at a particular
time.
When the program is processed and waiting for the session to be released, if we use RSBDCSUB then the
Whole sessions created for the program are released at a single go, Whereas if we use RSBDCBTC, each
session is given a Unique Session ID and it can be released automatically regardless of the program name.
RSBDCSUB - Processing Sessions Automatically
In most cases, batch input sessions can be processed automatically. It is not necessary for a session to wait
until a system administrator explicitly starts the processing of the session.
The ABAP program RSBDCSUB must be scheduled as a periodic job in the R/3 background processing
system. RSBDCSUB checks for and starts any batch input sessions that have not yet been run. It schedules
such sessions for immediate execution in the background processing system.
Schedule RSBDCSUB to run periodically in one or more background jobs.
If you have regularly scheduled batch input runs, you can schedule separate jobs for each of the scheduled
data transfers. The start time for the RSBDCSUB job can be set according to the batch input schedule. And
you can use a variant to restrict RSBDCSUB only to the batch input sessions that you expect.
With RSBDCSUB, you can use all of the selection criteria offered on the batch input main menu to select
sessions to run:
- session name
- date and time of generation
- status: ready to run or held in the queue because of errors
Batch input sessions are started automatically rather than by hand. The RSBDCSUB program can be set up
to start all sessions that arrive in an R/3 System, or it can be fine-tuned to start only batch input sessions
that you expect.
ABAP syntax - submit BDC - help
I am using the SAP program RSBDCBTC to submit a BDC session from within my program that is running in
the foreground. So I am submitting the program with following syntax:
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 99.
*
IF SY-SUBRC EQ 0. "Job_open OK
*
SUBMIT (SUBREPORT)
USER SY-UNAME
VIA JOB JNAME
NUMBER JNUMB
WITH QUEUE_ID EQ QID
WITH MAPPE EQ GROUPID
WITH MODUS EQ 'N'
WITH LOGALL EQ LMODUS
AND RETURN.
*
IF SY-SUBRC EQ 0. "submit OK
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JNUMB
JOBNAME = JNAME
STRTIMMED = X
IMPORTING
JOB_WAS_RELEASED = JOBRELE
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 99.
IF SY-SUBRC EQ 0. "Job_close is OK
IF JOBRELE EQ X. "job is release/
ENDIF.
ENDIF.
ENDIF.
ENDIF
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = L_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB[] "Write here the name of your internal table + []
* EXCEPTIONS
* PROGRAM_ERROR = 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.
*-- Bulent
Upload Logo for REUSE_ALV_COMMENTARY_WRITE
For those who wish to upload and use a picture in your ALV abap reports.
Steps for uploading Logo :-:
1. Goto the transaction OAER
2. Enter the class name as 'PICTURES'
3. Enter the class type as 'OT'
4. Enter the object key as the name of the logo you wish to give
5. Execute
6. Then in the new screen select Standard doc. types in bottom window
Click on the Screen icon
Now, it will ask for the file path where you have to upload the logo
7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE
or
Import Logo and Background Picture for Reporting
In this step, you can import a customer-specific logo and a background picture into the R/3 System. These
will be displayed in the header area of reports in HR Funds and Position Management.
if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used
in day to day applications).
the synatx is :call method grid (name of grid )->refresh_table_display
exporting
IS_STABLE = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)
I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).
Sample programs on ALV Grid
report zbnstest.
************************************************************************
* TABLES AND DATA DECLARATION.
************************************************************************
*TABLES: mara,makt.",marc.
data syrepid like sy-repid.
data sydatum(10). " LIKE sy-datum.
data sypagno(3) type n.
* WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
* GROUP (TYPE-POOLS--------->SLIS)
type-pools : slis.
************************************************************************
* INTERNAL TABLE DECLARATION.
************************************************************************
* INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
data: begin of t_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
matkl like mara-matkl,
end of t_mara.
* INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
data : begin of t_marc occurs 0,
matnr like mara-matnr,
werks like marc-werks,
minbe like marc-minbe.
data: end of t_marc.
* INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
data : begin of t_makt occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
spras like makt-spras,
end of t_makt.
* INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
data: begin of itab1 occurs 0,
************************************************************************
* START-OF-SELECTION. *
************************************************************************
start-of-selection.
* SUBROUTINE TO POPULATE THE COLORSTRUCT
perform fill_colorstruct using colorstruct.
* SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
perform populate_fieldcatalog.
************************************************************************
* FORMS
************************************************************************
* IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
* OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
* COLUMN JUSTIFICATION.
form populate_fieldcatalog.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATNR' 'X' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MEINS' ' '.
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MAKTX' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MTART' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MATKL' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'SPRAS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'WERKS' ' ' .
perform fill_fields_of_fieldcatalog tables fieldcatalog
using 'ITAB1' 'MINBE' ' ' .
endform. " POPULATE_FIELDCATALOG
*---------------------------------------------------------------------*
* FORM FILL_FIELDS_OF_FIELDCATALOG *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> FIELDCATALOG *
* --> P_TABNAME *
* --> P_FIELDNAME *
* --> P_KEY *
* --> P_KEY *
*---------------------------------------------------------------------*
form fill_fields_of_fieldcatalog tables fieldcatalog
structure fieldcatalog
using p_tabname
p_fieldname
p_key.
* p_no_out.
fieldcatalog-tabname = p_tabname.
fieldcatalog-fieldname = p_fieldname.
fieldcatalog-key = p_key.
fieldcatalog-emphasize = '1234'.
*fieldcatalog-no_out = p_no_out.
append fieldcatalog.
endform. " FILL_FIELDSOFFIELDCATALOG
*---------------------------------------------------------------------*
* FORM POPULATE_LAYOUT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> FIELDLAYOUT *
*---------------------------------------------------------------------*
form populate_layout using fieldlayout type slis_layout_alv.
fieldlayout-f2code = '&ETA' .
fieldlayout-zebra = 'X'.
* FOR THE WINDOW TITLE.
fieldlayout-window_titlebar = 'ALV with Events'.
fieldlayout-colwidth_optimize = 'X'.
fieldlayout-no_vline = ' '.
*fieldlayout-no_input = 'X'.
fieldlayout-confirmation_prompt = ''.
fieldlayout-key_hotspot = 'X'.
* This removes the column headings if the flag is set to 'X'
fieldlayout-no_colhead = ' '.
*fieldlayout-hotspot_fieldname = 'MAKTX'.
fieldlayout-detail_popup = 'X'.
* fieldlayout-coltab_fieldname = 'X'.
endform. " POPULATE_LAYOUT
*---------------------------------------------------------------------*
* FORM SELECTDATA_AND_SORT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form selectdata_and_sort.
select matnr meins mtart matkl from mara
into corresponding fields of t_mara
up to 500 rows .
select matnr maktx spras from makt
into corresponding fields of t_makt
where matnr = t_mara-matnr and
spras = sy-langu.
select matnr werks minbe from marc
into corresponding fields of t_marc
where matnr = t_mara-matnr.
append t_marc.
endselect.
append t_makt.
endselect.
append t_mara.
endselect.
perform populate_itab1.
sort itab1 by matnr.
endform. " SELECTDATA_AND_SORT
*---------------------------------------------------------------------*
* FORM MERGE_FIELDCATALOG *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form merge_fieldcatalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = syrepid
i_internal_tabname = 'ITAB1'
* i_structure_name = 'COLORSTRUCT'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = syrepid
changing
ct_fieldcat = fieldcatalog[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
endform. " MERGE_FIELDCATALOG
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = itab1
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_ALV_LIST
*&---------------------------------------------------------------------*
*& Form POPULATE_ITAB1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form populate_itab1.
loop at t_mara.
loop at t_makt where matnr = t_mara-matnr.
loop at t_marc where matnr = t_mara-matnr.
move-corresponding t_mara to itab1.
move-corresponding t_makt to itab1.
move-corresponding t_marc to itab1.
append itab1.
endloop.
endloop.
endloop.
endform. " POPULATE_ITAB1
*&---------------------------------------------------------------------*
*& Form FILL_EVENTSTAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EVENTSTAB text *
*----------------------------------------------------------------------*
form fill_eventstab tables p_eventstab structure eventstab.
* WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
* INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
* AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
* EVENTS NAME.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_eventstab[]
exceptions
list_type_wrong = 1
others = 2.
* BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
* THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
* WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
* FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
* IS DYNAMICALY CALLED.
read table p_eventstab with key name = slis_ev_top_of_page.
if sy-subrc = 0 .
endform.
*&---------------------------------------------------------------------*
*& Form FILL_COLORSTRUCT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_COLORSTRUCT text *
*----------------------------------------------------------------------*
form fill_colorstruct using p_colorstruct type slis_coltypes .
p_colorstruct-heacolfir-col = 6.
p_colorstruct-heacolfir-int = 1.
p_colorstruct-heacolfir-inv = 1.
endform. " FILL_COLORSTRUCT
*---------------------------------------------------------------------*
* FORM TOP_OF_COVERPAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form top_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading1[]
exceptions
others = 1.
endform.
*---------------------------------------------------------------------*
* FORM END_OF_COVERPAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form end_of_coverpage.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading2[]
exceptions
others = 1.
endform.
*---------------------------------------------------------------------*
* FORM FOREIGN_TOP_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form foreign_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = heading3[]
exceptions
others = 1.
endform.
*---------------------------------------------------------------------*
* FORM FOREIGN_END_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form foreign_end_of_page.
endform.
"e06_comment_build
Suman Tyagi
An Example:
REPORT ZALV_GRID.
TABLES :vbap.
type-pools : slis.
data i_events TYPE slis_t_event.
DATA : my_alv TYPE REF TO cl_gui_alv_grid.
TYPES : BEGIN OF itab,
vbeln LIKE vbap-vbeln,
arktx LIKE vbap-arktx,
END OF itab.
TYPES : itab1 TYPE TABLE OF itab.
DATA : display TYPE itab1.
DATA : fcat TYPE SLIS_T_FIELDCAT_ALV.
DATA : wa LIKE LINE OF FCAT.
DATA WA1 LIKE VBAP.
DATA: container TYPE REF TO cl_gui_custom_container.
data report_id like sy-repid.
SELECT-OPTIONS s_vbeln FOR vbap-vbeln.
report_id = sy-repid.
SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE display WHERE
vbeln IN s_vbeln.
wa-fieldname = 'VBELN'.
wa-tabname = 'VBAP'.
wa-key = 'X'.
WA-HOTSPOT = 'X'.
wa-text_fieldname = 'Doc no.'.
APPEND wa TO fcat.
CLEAR wa.
wa-fieldname = 'ARKTX'.
wa-tabname = 'VBAP'.
wa-text_fieldname = 'Item Text'.
APPEND wa TO fcat.
PERFORM f0650_build_event USING 'USER_COMMAND'
'F0750_USER_COMMAND'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY '
EXPORTING
I_CALLBACK_PROGRAM = report_id
IT_FIELDCAT = FCAT
IT_EVENTS = i_events
TABLES
t_outtab = DISPLAY
.
" FIELDCATALOG
it_fieldcat
= gt_fieldcat
i_default
=''
i_save
= 'A'
i_tabname_header
= v_headers_itable
i_tabname_item
= v_items_itable
i_structure_name_header
= v_headers_table
i_structure_name_item
= v_items_table
is_keyinfo
= gs_keyinfo
i_bypassing_buffer
= 'X'
TABLES
t_outtab_header
= i_headers
*
t_outtab_item
= i_result
t_outtab_item
= i_report
EXCEPTIONS
program_error
=1
OTHERS
= 2.
The field cat creation worked like this :
FORM fieldcat.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_internal_tabname = v_items_itable
i_structure_name = v_items_table
CHANGING
ct_fieldcat
= gt_fieldcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_internal_tabname = v_headers_itable
i_structure_name = v_headers_table
CHANGING
ct_fieldcat
= gt_fieldcat.
ENDFORM.
and of course you need to tell the thing what is key and item
gs_keyinfo-header01 = 'PA'.
gs_keyinfo-item01 = 'PA'.
gs_keyinfo-item02 = 'SAPDOC'.
PERFORM fieldcat.
I hope this helps you and not confuse you,
Cheers.
Display a Secondary List using ALV Grid
To display a secondary list when you click on one of the row items in an alv grid. The secondary list should
also be an alv.
Try out this code. You will have to make a structure ZSTR same as the output internal table.
REPORT ZTEST_REP1 .
TABLES : MARA,
BHDGD,
zstr.
TYPES:
BEGIN OF T_MARA,
MATNR LIKE MARA-MATNR,
ERNAM LIKE MARA-ERNAM,
END OF T_MARA.
W_FLAG,
W_TEMP_VAL
TYPE I.
*---------------------------------------------------------------------*
* Definition:
*---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_TOP_OF_PAGE
FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID,
HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_TOP_OF_PAGE.
PERFORM F_GET_HEADER.
ENDMETHOD.
"handle_top_of_page
METHOD HANDLE_DOUBLE_CLICK.
* The event DOUBLE_CLICK provides parameters for row and column
* of the click. We use row parameter to select a line of the
* corresponding internal table.
* read selected row from internal table
READ TABLE I_MARA INDEX E_ROW-INDEX INTO WA_MARA.
IF SY-SUBRC <> 0.
*
message i001. " Cursor position not correct.
ELSE.
*
call dialog screen and display the details
call screen 200 starting at 10 5.
ENDIF.
ENDMETHOD.
"handle_double_click
ENDCLASS.
*----------------------------------------------------------------------* start-of-selection.
*----------------------------------------------------------------------START-OF-SELECTION.
SELECT MATNR ERNAM FROM MARA INTO TABLE I_MARA.
*---------------------------------------------------------------------* End-of-Selection.
*---------------------------------------------------------------------END-OF-SELECTION.
ENDFORM.
" f_get_header
*&---------------------------------------------------------------------*
*&
Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STAT'.
SET TITLEBAR 'TITL'.
ENDMODULE.
" STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM .
WHEN C_EXIT OR C_BACK OR C_CANC.
IF NOT W_CONTAINER IS INITIAL.
CALL METHOD W_CONTAINER->FREE.
ENDIF.
LEAVE TO SCREEN 0.
WHEN C_PGTOP.
WA_GRIDROW-INDEX = 1.
WHEN C_PGUP.
IF WA_GRIDROW-INDEX <= 15.
WA_GRIDROW-INDEX = 1.
ELSE.
WA_GRIDROW-INDEX = WA_GRIDROW-INDEX - 15.
ENDIF.
WHEN C_PGDN.
PERFORM F_GET_NO_ROWS.
W_TEMP_VAL = W_LN - WA_GRIDROW-INDEX.
IF W_TEMP_VAL < 15.
WA_GRIDROW-INDEX = W_LN.
ELSE.
WA_GRIDROW-INDEX = WA_GRIDROW-INDEX + 15.
ENDIF.
WHEN C_PGEND.
PERFORM F_GET_NO_ROWS.
WA_GRIDROW-INDEX = W_LN.
ENDCASE.
ENDMODULE.
" USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*&
Form f_get_no_rows
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM F_GET_NO_ROWS.
DESCRIBE TABLE I_MARA LINES W_LN.
ENDFORM.
" f_get_no_rows
*&---------------------------------------------------------------------*
*&
Module DISPLAY_0100 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE DISPLAY_0100 OUTPUT.
IF NOT WA_GRIDROW IS INITIAL
AND NOT WA_GRIDCOL IS INITIAL.
CALL METHOD W_GRID->SET_SCROLL_INFO_VIA_ID
EXPORTING
IS_ROW_INFO = WA_GRIDROW
IS_COL_INFO = WA_GRIDCOL .
CALL METHOD W_GRID->SET_CURRENT_CELL_VIA_ID
EXPORTING
IS_ROW_ID = WA_GRIDROW
IS_COLUMN_ID = WA_GRIDCOL .
ENDIF.
CALL METHOD W_GRID->GET_SCROLL_INFO_VIA_ID
IMPORTING
ES_ROW_INFO = WA_GRIDROW
ES_COL_INFO = WA_GRIDCOL .
CALL METHOD W_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = I_GT_SELROWS[].
* Build the fieldcat according to structure
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'ZSTR'
CHANGING
CT_FIELDCAT
= I_FIELDCAT[].
LOOP AT I_FIELDCAT.
W_INDEX = SY-TABIX.
CASE I_FIELDCAT-FIELDNAME.
WHEN 'MATNR'.
I_FIELDCAT-SCRTEXT_S = 'MATNR'.
I_FIELDCAT-KEY
= ' '.
I_FIELDCAT-COL_POS = '1'.
WHEN 'ERNAM'.
I_FIELDCAT-SCRTEXT_S = 'ERDAT'.
I_FIELDCAT-OUTPUTLEN = '18'.
I_FIELDCAT-COL_POS = '2'.
ENDCASE.
MODIFY I_FIELDCAT INDEX W_INDEX.
ENDLOOP.
READ TABLE I_FIELDCAT INDEX 1 .
IF W_CALL = 1.
PERFORM F_STD_HEADER.
CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT
= W_VARIANT
I_SAVE
= W_SAVE
CHANGING
IT_OUTTAB
= I_MARA[]
IT_FIELDCATALOG
= I_FIELDCAT[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR
=2
OTHERS
= 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
EXIT.
ENDIF.
CREATE OBJECT W_EVENT_REC.
SET HANDLER W_EVENT_REC->HANDLE_TOP_OF_PAGE FOR W_GRID.
CREATE OBJECT W_EVENT_REC.
SET HANDLER W_EVENT_REC->HANDLE_DOUBLE_CLICK FOR W_GRID.
W_FLAG = C_RESET.
ENDMODULE.
" DISPLAY_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
Form f_std_header
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM F_STD_HEADER.
ENDFORM.
" f_std_header
*&---------------------------------------------------------------------*
*&
Module DYNPRONR_CHECK_500 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE DYNPRONR_CHECK_500 OUTPUT.
* if w_dynpronr is initial.
* w_dynpronr = '0100'.
* endif.
ENDMODULE.
" DYNPRONR_CHECK_500 OUTPUT
*&---------------------------------------------------------------------*
*&
Module create_objects_0100 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE create_objects_0100 OUTPUT.
check w_container is initial .
create object w_container
exporting
container_name = 'CC'.
create object w_grid
exporting
i_parent = w_container.
w_flag = c_set.
w_flag = w_flag.
ENDMODULE.
" create_objects_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ST20'.
SET TITLEBAR '200'.
zstr-matnr = wa_mara-matnr.
zstr-ernam = wa_mara-ernam.
ENDMODULE.
" STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*&
Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.
move ok_code to w_ok_code.
clear ok_code.
case w_ok_code.
when c_back or c_exit or c_canc.
leave to screen 0.
endcase.
clear w_ok_code.
ENDMODULE.
" USER_COMMAND_0200 INPUT
*-- End of Program
Download a report to excel with format (border, color cell, etc)
Try this program...it may help you to change the font ..etc.
Code:
REPORT ZSIRI NO STANDARD PAGE HEADING.
* this report demonstrates how to send some ABAP data to an
* EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
* handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT,
" Excel object
H_MAPL TYPE OLE2_OBJECT,
" list of workbooks
H_MAP TYPE OLE2_OBJECT,
" workbook
H_ZL TYPE OLE2_OBJECT,
" cell
H_F TYPE OLE2_OBJECT.
" font
TABLES: SPFLI.
DATA H TYPE I.
* table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Event START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* read flights
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
* display header
ULINE (61).
WRITE: / SY-VLINE NO-GAP,
(3) 'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(4) 'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(8) 'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
ULINE /(61).
* display flights
LOOP AT IT_SPFLI.
WRITE: / SY-VLINE NO-GAP,
IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE /(61).
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
*
PERCENTAGE = 0
TEXT
= TEXT-007
EXCEPTIONS
OTHERS = 1.
* start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
* PERFORM ERR_HDL.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
* CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
.
* PERFORM ERR_HDL.
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
*
PERCENTAGE = 0
TEXT
= TEXT-008
EXCEPTIONS
OTHERS = 1.
* get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
*
PERCENTAGE = 0
TEXT
= TEXT-009
EXCEPTIONS
OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
* changes by Kishore - start
* CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP EXPORTING #1 = 2.
PERFORM ERR_HDL.
* tell user what is going on
SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
*
PERCENTAGE = 0
TEXT
= TEXT-009
EXCEPTIONS
OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
* changes by Kishore - end
* disconnect from Excel
*
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'C:\SKV.XLS'.
FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
*---------------------------------------------------------------------*
*
FORM FILL_CELL
*
*---------------------------------------------------------------------*
*
sets cell at coordinates i,j to value val boldtype bold
*---------------------------------------------------------------------*
FORM FILL_CELL USING I J BOLD VAL.
************************************************************************
** Notes:
**
** this program shows how we can use hashed tables to improve **
** the responce time.
**
** It shows,
**
**
1. how to declare hashed tables
**
**
2. a cache-like technique to improve access to master data **
**
3. how to collect data using hashed tables
**
**
4. how to avoid deletions of unwanted data
**
************************************************************************
** Results: the test we run read about 31000 rows from mkpf, 150000 **
**
rows from mseg, 500 rows from makt and 400 from lfa1. **
**
it filled ht_lst with 24500 rows and displayed them in **
**
alv grid format.
**
**
**
**
It took about 65 secodns to perform this task (first time **
**
we run it when all the db buffers are empty.
**
**
**
**
The same program with standard tables needed 140 seconds **
**
to run with the same recordset and with buffers filled in **
**
**
**
A simmilar test over more than a million rows
************************************************************************
** Objetive: show a list that consists of all the material movements **
**
'101' - '901' for a certain range of dates in mkpf-budat. **
** the columns to be displayed are:
**
**
mkpf-budat,
**
**
mkpf-mblnr,
**
**
mseg-lifnr,
**
**
lfa1-name1,
**
**
mkpf-xblnr,
**
**
mseg-zeile
**
**
mseg-charg,
**
**
mseg-matnr,
**
**
makt-maktx,
**
**
mseg-erfmg,
**
**
mseg-erfme.
**
** or show a sumary list by matnr - menge
**
**
**
** You'll have to create a pf-status called vista **
** See form set_pf_status for details
**
************************************************************************
** tables used tables: mkpf,
mseg,
lfa1,
makt.
** global hashed tables used
*
data: begin of wa_mkpf, "header
mblnr like mkpf-mblnr,
mjahr like mkpf-mjahr,
budat like mkpf-budat,
xblnr like mkpf-xblnr,
end of wa_mkpf.
data: ht_mkpf like hashed table of wa_mkpf
with unique key mblnr mjahr
with header line.
data: st_mkpf like standard table of wa_mkpf
with header line.
*
data: begin of wa_mseg, " line items
mblnr like mseg-mblnr,
mjahr like mseg-mjahr,
zeile like mseg-zeile,
bwart like mseg-bwart,
charg like mseg-charg,
matnr like mseg-matnr,
lifnr like mseg-lifnr,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
end of wa_mseg.
data ht_mseg like hashed table of wa_mseg
with unique key mblnr mjahr zeile
with header line.
data st_mseg like standard table of wa_mseg
with header line.
** cache structure for lfa1 records
data: begin of wa_lfa1,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of wa_lfa1.
data ht_lfa1 like hashed table of wa_lfa1
with unique key lifnr
with header line.
** cache structure for material related data
data: begin of wa_material,
matnr like makt-matnr,
maktx like makt-maktx,
end of wa_material.
data: ht_material like hashed table of wa_material
with unique key matnr
with header line.
** result table
data: begin of wa_lst, "
budat like mkpf-budat,
mblnr like mseg-mblnr,
lifnr like mseg-lifnr,
name1 like lfa1-name1,
xblnr like mkpf-xblnr,
zeile like mseg-zeile,
charg like mseg-charg,
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
erfme like mseg-erfme,
mjahr like mseg-mjahr,
end of wa_lst.
data: ht_lst like hashed table of wa_lst
with unique key mblnr mjahr zeile
with header line.
data: begin of wa_lst1, " sumary by material
matnr like mseg-matnr,
maktx like makt-maktx,
erfmg like mseg-erfmg,
form get_data.
select mblnr mjahr budat xblnr
into table ht_mkpf
from mkpf
where budat in so_budat. " make use of std index.
** have we retrieved data from mkpf?
describe table ht_mkpf lines g_lines.
if g_lines > 0.
** if true then retrieve all related records from mseg.
** Doing this way we make sure that the access is by primary key
** of mseg.
** The reason is that is faster to filter them in memory
** than to allow the db server to do it.
select mblnr mjahr zeile bwart charg
matnr lifnr erfmg erfme
into table ht_mseg
from mseg
for all entries in ht_mkpf
where mblnr = ht_mkpf-mblnr
and mjahr = ht_mkpf-mjahr.
endif.
** fill t_lst or t_lst1 according to user's choice.
if gp_bymat = ' '.
perform fill_ht_lst.
else.
perform fill_ht_lst1.
endif.
endform.
form fill_ht_lst.
refresh ht_lst.
** Example: how to discard unwanted data in an efficient way.
loop at ht_mseg.
* filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* read header line.
read table ht_mkpf with table key mblnr = ht_mseg-mblnr
mjahr = ht_mseg-mjahr.
clear ht_lst.
* * note : this may be faster if you specify field by field.
move-corresponding ht_mkpf to ht_lst.
move-corresponding ht_mseg to ht_lst.
perform read_lfa1 using ht_mseg-lifnr changing ht_lst-name1.
perform read_material using ht_mseg-matnr changing ht_lst-maktx.
insert table ht_lst.
endloop.
endform.
form fill_ht_lst1.
data: colorear.
refresh ht_lst1.
** Example: how to discard unwanted data in an efficient way.
**
hot to simulate a collect in a faster way
loop at ht_mseg.
* filter unwanted data
check ht_mseg-bwart = '101' or ht_mseg-bwart = '901'.
check ht_mseg-matnr in so_matnr.
* * note : this may be faster if you specify field by field.
* IS_PRINT
=
* IS_REPREP_ID
=
* I_BUFFER_ACTIVE
=
* I_BYPASSING_BUFFER
=
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER
=
* ES_EXIT_CAUSED_BY_USER
=
tables
t_outtab_header
= st_mkpf
t_outtab_item
= st_mseg
* EXCEPTIONS
* PROGRAM_ERROR
=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.
endform.
form show_ht_lst.
"needed because the FM can't use a hashed table.
it_lst[] = ht_lst[].
perform fill_layout using 'full display'
changing ls_layout.
perform fill_columns_lst.
* perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout
= ls_layout
it_fieldcat
= it_fieldcat_lst[]
*
it_sort
= it_sort_lst
tables
t_outtab
= it_lst
exceptions
program_error
=1
others
= 2.
endform.
form show_ht_lst1.
"needed because the FM can't use a hashed table.
it_lst1[] = ht_lst1[].
perform fill_layout using 'Sumary by matnr'
changing ls_layout.
perform fill_columns_lst1.
* perform sort_lst.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout
= ls_layout
it_fieldcat
= it_fieldcat_lst1[]
*
it_sort
= it_sort_lst
tables
t_outtab
exceptions
program_error
others
= it_lst1
=1
= 2.
endform.
form fill_layout using p_window_titlebar
changing cs_layo type slis_layout_alv.
clear cs_layo.
cs_layo-window_titlebar
= p_window_titlebar.
cs_layo-edit
= 'X'.
cs_layo-edit_mode
= space.
MOVE 'COLOR_LINE' TO cs_layo-info_fieldname.
* Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO cs_layo-coltab_fieldname.
* move 'CELLTAB' TO cs_layo-stylefname.
endform.
" armar_layout_stock
ELSE.
v_dnm = v_donem.
ENDIF.
SELECT SINGLE * FROM t009b WHERE periv = i_tab-periv
AND bdatj = s_budat-low+0(4)
AND poper = v_dnm.
"'K4'
t009b-butag = t009b-butag + 1.
IF s_budat-low+6(2) NE t009b-butag.
v_date_high = s_budat-low - 1.
IF v_donem = 1.
v_date_low = s_budat-low.
v_date_low+4(4) = '0101'.
ELSE.
CONCATENATE t009b-bdatj t009b-bumon t009b-butag INTO
v_date_low.
ENDIF.
SELECT * FROM bsad WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
IF bsad-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsad-dmbtr ).
ELSEIF bsad-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsad-dmbtr ).
ENDIF.
ENDSELECT.
SELECT * FROM bsid WHERE bukrs EQ i_tab-bukrs "IN s_bukrs
AND kunnr = i_tab-kunnr
AND budat BETWEEN v_date_low AND
v_date_high
AND umskz = space
AND blart IN s_blart.
*
AND gsber IN gsber.
IF bsid-shkzg = 'S'.
i_tab-dmbtr_s = i_tab-dmbtr_s + ( bsid-dmbtr ).
ELSEIF bsid-shkzg = 'H'.
i_tab-dmbtr_h = i_tab-dmbtr_h + ( bsid-dmbtr ).
ENDIF.
ENDSELECT.
ENDIF.
"opening balance ( irket bazl )z1 degeri
i_tab-z1 = i_tab-z1 + ( knc1-umsav + i_tab-dmbtr_s - i_tab-dmbtr_h ).
* for israel
i_tab-dmbtril_s = i_tab-dmbtr_s .
i_tab-dmbtril_h = i_tab-dmbtr_h .
ENDSELECT.
type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
perform build_print_params.
perform build_sortcat.
perform display_alv_report.
end-of-selection.
*TOP-OF-PAGE.
* PERFORM top-of-page.
end-of-page.
*&---------------------------------------------------------*&
Form build_fieldcatalog
*&---------------------------------------------------------*
text
*----------------------------------------------------------* --> p1
text
* <-- p2
text
*----------------------------------------------------------form build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
fieldcatalog-do_sum = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
endform.
" top-of-page
*---------------------------------------------------------------------*
*
FORM user_command
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> R_UCOMM
*
* --> RS_SELFIELD
*
*---------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
when 'ULHAS'.
if rs_selfield-fieldname = 'EBELN'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
set parameter id 'BES' field wa_ekko-ebeln.
call transaction 'ME23N' and skip first screen.
endif.
endcase.
endform.
*---------------------------------------------------------------------*
*
FORM set_pf_status
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> RT_EXTAB
*
*---------------------------------------------------------------------*
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'ZNEWSTATUS'.
endform.
*&---------------------------------------------------------------------*
*&
Form build_events
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type
=0
importing
et_events
= gt_events[]
* EXCEPTIONS
* LIST_TYPE_WRONG
=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.
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform.
" build_events
*&---------------------------------------------------------------------*
*&
Form build_print_params
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform.
" build_print_params
*---------------------------------------------------------------------*
*
FORM END_OF_PAGE
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
form end_of_page.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip. write:/40 'Page:', sy-pagno .
endform.
*---------------------------------------------------------------------*
*
FORM END_OF_LIST
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
form end_of_list.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip. write:/40 'Page:', sy-pagno .
endform.
*&---------------------------------------------------------------------*
*&
Form build_sortcat
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form build_sortcat.
wa_sort-spos
= 1.
wa_sort-fieldname = 'EBELN'.
append wa_sort to it_sortcat.
wa_sort-spos
= 2.
wa_sort-fieldname = 'EBELP'.
append wa_sort to it_sortcat.
endform.
" build_sortcat
Test ALV Display With Header & Footer
*Program to Test ALV Display With Header & Footer.
*&---------------------------------------------------------------------*
*& Report ZRJR02
*
*&---------------------------------------------------------------------*
REPORT ZRJR02
.
*Table declaration.
TABLES:ZEMP_MST,ZDEPT_MST,ZDESG_MST,ZSL_TXN.
*Varriable declaration.
TYPE-POOLS SLIS.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= REPID
IT_FIELDCAT
= F1
*
IT_SORT
= GT_SORT
I_SAVE
= 'X'
IT_EVENTS
= GT_EVENTS[]
TABLES
T_OUTTAB
= ITAB.
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.
" LAYOUT
*&---------------------------------------------------------------------*
*&
Form FCAT
*&---------------------------------------------------------------------*
FORM FCAT USING P_FIELD P_TABLE P_SUM P_TEXT P_RFIELD P_RTABLE P_DISP.
ADD 1 TO POS.
F2-COL_POS
= POS.
F2-FIELDNAME = P_FIELD.
F2-TABNAME
= P_TABLE.
F2-SELTEXT_L = P_TEXT.
F2-REF_FIELDNAME = P_RFIELD.
F2-REF_TABNAME = P_RTABLE.
F2-DO_SUM
= P_SUM.
F2-NO_OUT
= P_DISP.
APPEND F2 TO F1.
CLEAR F2.
ENDFORM.
" FCAT
*&---------------------------------------------------------------------*
*&
Form LSORT
*&---------------------------------------------------------------------*
*FORM LSORT USING P_FIELD P_TABLE P_UP.
* ADD 1 TO L_POS.
* IT_SORT-SPOS
= L_POS.
* IT_SORT-FIELDNAME = P_FIELD.
* IT_SORT-TABNAME = P_TABLE.
* IT_SORT-UP
= P_UP.
* APPEND IT_SORT.
*ENDFORM.
" LSORT
*------------FORM F_BUILD_EVENTCAT .
CLEAR: GT_EVENTS. REFRESH: GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.
FS_EVENTCAT-FORM = 'F_REPORT_HEADER_ALV'.
APPEND FS_EVENTCAT TO GT_EVENTS.
CLEAR: FS_EVENTCAT.
FS_EVENTCAT-NAME = 'END_OF_LIST'.
FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.
APPEND FS_EVENTCAT TO GT_EVENTS.
ENDFORM.
" F_BUILD_EVENTCAT
FORM F_REPORT_HEADER_ALV.
CALL FUNCTION 'Z_YHEAD_PRINT'
EXPORTING
TITLE1
= 'XYZ Limited'
TITLE2
= 'Employee Master'
TITLE3
= 'Created on '
COLOR
= 'X'
.
ENDFORM.
*&---------------------------------------------------------------------*
*&
Form F_WRITE_SUMMARY
*&---------------------------------------------------------------------*
*
Write summary before exit
*----------------------------------------------------------------------*
FORM F_WRITE_SUMMARY .
write:/ 'Welcome to XYZ Limited'.
write:/ 'This is a test program to display Report in ALV Format'.
Use Simple ALV Functions to Make Reporting Easy
*&---------------------------------------------------------------------*
*& Report ZBC_ALV_EXAMPLE
*
*&
*
*&---------------------------------------------------------------------*
* This program explains how we can use simple ALV functions to make *
* reporting easy and looks pretty
************************************************************************
* Programmer
: Venkat Reddy
ETA
*
* Date
: 10/02/04
*
************************************************************************
* Maintenance Log
*
*----------------------------------------------------------------------*
* Changed By
Date
Transport# Description
*
*------------ ---------------------------------------------------------*
* Venkat Reddy 10/02/04 EGD913575 Changed program to avoid *
*----------------------------------------------------------------------*
REPORT ZBC_ALV_EXAMPLE.
************************************************************************
*
D-A-T-A D-E-C-L-A-R-A-T-I-O-N-S
*
************************************************************************
tables: sflight.
**-- TYPE-POOLS Definition
**Includes the types and constants of a type group. Since the types and
*constants specified in a type group have global validity, you cannot
*use the statement within a FORM or FUNCTION.
type-pools: slis.
PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
**-- ALV variables
*****- Field Catalog structure
data: ls_fieldcat type slis_fieldcat_alv,
endif.
endif.
************************************************************************
*
S-T-A-R-T O-F S-E-L-E-C-T-I-O-N
*
************************************************************************
start-of-selection.
**-- Read Flight information.
perform read_flight_info.
**-- Fill ALV field catalog and display report.
if not lt_sflight[] is initial.
perform dislay_alv_report.
endif.
*======================================================================*
*
FORMS / SUB ROUTINES
*
*======================================================================
*&---------------------------------------------------------------------*
*&
Form initialize_fieldcat
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_GT_FIELDCAT[] text
*----------------------------------------------------------------------*
form initialize_fieldcat using l_fieldcat type slis_t_fieldcat_alv.
clear ls_fieldcat.
* Air line
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-key
= 'X'.
ls_fieldcat-col_pos = 1.
ls_fieldcat-seltext_s = 'Airline'.
ls_fieldcat-seltext_l = 'Airline'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Flight Number
ls_fieldcat-fieldname = 'CONNID'.
ls_fieldcat-key
= 'X'.
ls_fieldcat-col_pos = 2.
ls_fieldcat-seltext_s = 'Flight Number'.
ls_fieldcat-seltext_l = 'Flight Number'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Flight date
ls_fieldcat-fieldname = 'FLDATE'.
ls_fieldcat-key
= 'X'.
ls_fieldcat-col_pos = 3.
ls_fieldcat-seltext_s = 'Flight date'.
ls_fieldcat-seltext_l = 'Flight date'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Airfare
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-col_pos = 4.
ls_fieldcat-do_sum
= 'X'.
ls_fieldcat-seltext_s = 'Airfare'.
ls_fieldcat-seltext_l = 'Airfare'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Local Currency
ls_fieldcat-fieldname = 'CURRENCY'.
ls_fieldcat-col_pos = 5.
ls_fieldcat-seltext_s = 'Local Currency'.
ls_fieldcat-seltext_l = 'Local Currency'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Plane Type
ls_fieldcat-fieldname = 'PLANETYPE'.
ls_fieldcat-col_pos = 6.
ls_fieldcat-seltext_s = 'Plane type'.
ls_fieldcat-seltext_l = 'Plane type'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Maximum capacity
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-col_pos = 7.
ls_fieldcat-seltext_s = 'Max. seats'.
ls_fieldcat-seltext_l = 'Max. seats'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Occupied seats
ls_fieldcat-fieldname = 'SEATSOCC'.
ls_fieldcat-col_pos = 8.
ls_fieldcat-seltext_s = 'Seats occupied'.
ls_fieldcat-seltext_l = 'Seats occupied'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Total
ls_fieldcat-fieldname = 'PAYMENTSUM'.
ls_fieldcat-col_pos = 9.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_s = 'Total amount'.
ls_fieldcat-seltext_l = 'Total amount'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Total
ls_fieldcat-fieldname = 'PAYMENTSUM'.
ls_fieldcat-col_pos = 9.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-seltext_s = 'Total amount'.
ls_fieldcat-seltext_l = 'Total amount'.
append ls_fieldcat to l_fieldcat.
clear ls_fieldcat.
* Max. Capacity, Buss. Class
ls_fieldcat-fieldname = 'SEATSMAX_B'.
ls_fieldcat-col_pos = 10.
ls_fieldcat-seltext_s = 'Max.Buss.class cap.'.
ls_fieldcat-seltext_l = 'Max.Buss.class cap.'.
FORM dislay_alv_report .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK
=''
* I_BYPASSING_BUFFER
=
* I_BUFFER_ACTIVE
=''
I_CALLBACK_PROGRAM
= g_repid
* I_CALLBACK_PF_STATUS_SET
=''
* I_CALLBACK_USER_COMMAND
=''
I_STRUCTURE_NAME
= 'sflight'
* IS_LAYOUT
=
IT_FIELDCAT
= gt_fieldcat
* IT_EXCLUDING
=
* IT_SPECIAL_GROUPS
=
* IT_SORT
=
* IT_FILTER
=
* IS_SEL_HIDE
=
I_DEFAULT
= 'X'
I_SAVE
= 'A'
IS_VARIANT
= GX_VARIANT
* IT_EVENTS
=
* IT_EVENT_EXIT
=
* IS_PRINT
=
* IS_REPREP_ID
=
* I_SCREEN_START_COLUMN
=0
* I_SCREEN_START_LINE
=0
* I_SCREEN_END_COLUMN
=0
* I_SCREEN_END_LINE
=0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER
=
* ES_EXIT_CAUSED_BY_USER
=
TABLES
T_OUTTAB
= lt_sflight
EXCEPTIONS
PROGRAM_ERROR
=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.
ENDFORM.
" dislay_alv_report
*&---------------------------------------------------------------------*
*&
Form initialize_variant
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM initialize_variant .
g_save = 'A'.
clear g_variant.
g_variant-report = g_repid.
gx_variant = g_variant.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = g_save
changing
cs_variant = gx_variant
exceptions
not_found = 2.
if sy-subrc = 0.
p_vari = gx_variant-variant.
endif.
ENDFORM.
" initialize_variant
new_menu->add_function
EXPORTING fcode = 'delete'
text = text-003.
CALL METHOD new_menu->add_submenu
EXPORTING menu = new_menu
text = text-005.
ENDFORM
SYNTAX FOR STATUS ICON:
CALL FUNCTION 'ICON_CREATE'
EXPORTING
NAME = 'icon name'
TEXT = 'text to be displayed'
INFO = 'tooltip text'
Use SAP code to list how many documents in the folder on your PC
PC Folder List with ABAP
Use function module TMP_GUI_DIRECTORY_LIST_FILES to get a list of files on any given path on the
presentation server.
Sample Code:
data : file_table like table of SDOKPATH.
data : dir_table like table of SDOKPATH.
CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
EXPORTING
DIRECTORY = 'C:\export\'
FILTER = '*.TXT'
* IMPORTING
* FILE_COUNT =
* DIR_COUNT =
TABLES
FILE_TABLE = file_table
DIR_TABLE = dir_table
* EXCEPTIONS
* CNTL_ERROR = 1
* OTHERS = 2.