Tuesday, April 15, 2008

Storing SAP information from a JCo connector

I am using the SAP JCo connector and connecting to SAP through BAPI. Presently, I am storing information of ten items in SAP Systems. One item is not present and I would like to store the information contained in the other nine items but also show user invalid items; any suggestions?

You will need to develop an RFC-wrapper around the BAPI that provides the supporting logic for your JCo application. In this case, you would use the RFC wrapper to invoke the BAPI to attempt to store the ten elements. The wrapper would then identify the error message from the element that failed and return an error message in the return structure to JCo. The Java application invoking the JCo call would then reformat and relay that message to the end-user, dependent on the type of user interface front-end (Web, desktop, Swing etc.).

Configuring the JDBC Connector Service to perform database lookups

This Weblog describes how to activate the JDBC Connector Service in order to perform database lookups (without JDBC adapter) in XI. The standard how-to guide covers almost all steps but falls short in describing some configuration steps.
This weblog outlines the steps that are required to configure the JDBC Connector service for an Oracle database.
The following reference documents were used; this weblog explains the steps that were missed in those documents.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9aedca11-0d01-0010-3b90-9ea04182875f
http://help.sap.com/saphelp_nw2004s/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm

Steps to configure JDBC connector service

1.Download the oracle JDBC driver ojdbc14.jar from the Web site
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
2.Use Visual Administrator to upload the ojdbc14.jar against the JDBC connector service.
3.Select the Service node from the list of nodes shown below.

4.Select the JDBC Connector from the list of services.

5.Place the cursor in the Drivers node in the Runtime tab. Click the create button to add the drivers.

6.Place the cursor in the DataSources to create a new data source.
Enter the following parameters
Application Name
Data source Name
Add alias name ( Do not add jdbc/Name)

since whatever name you add will be registered in the JNDI Registry under jdbc context, while writing the java code access the alias by (jdbc/aliasname).
Subsequently, to check if the alias is registered with JNDI, you can browse to the JNDI Registry node in Visual administrator and locate the alias.

Select the appropriate driver from the list of drivers (from step 5).
Select JDBC Version.
If the version is JDBC 2.0 compliant (Oracle 10.x drivers are compliant), then enter
Object factory - oracle.jdbc.pool.OracleDataSourceFactory
DataSource type – XADataSource
XADS Class name - oracle.jdbc.xa.client.OracleXADataSource
image
7.Select the additional tab to the enter parameters to connect to the database.
Enter the following parameters:

KeyValue
urljdbc:oracle:thin:@::
user
password

SQL Engine : Select Native SQL


8.How to test the data source to be sure it's working fine
In the DB initialization tab, enter a SQL statement to query the table, & press execute butto; it should return the results.
Do not forget to remove the statement after the test.

9.Develop Java code that performs DBLookup, the sample code for the performing the DBLook up is given in the How To Guide Appendix.
10.Follow the procedure as given in the how to guide to Create UDF's.

Best NetWeaver component to add to SAP XI

Currently I am working on SAP XI and I am interested to add one more NetWeaver component to my skill set. Can you please suggest whether I should go with MDM or EP or BI along with XI? Which component is a good combination for XI?

The great thing about XI work is that it rubs up against virtually all of the other NetWeaver components. In terms of actual project work, the most common combination I have seen to date is XI and Portals work. This is often wrapped around a classic "Basis" skill set.

I haven't seen BI and XI together much lately, but I could see that combination work well. I have seen the XI and MDM combination from time to time, but we have yet to see an explosion of MDM job orders. One thing I find is that you don't have to worry too much about chasing something to mix with XI. All you really need to do is work on as many XI projects as you can, and go naturally towards the areas that you are asked to master. For example, what if you decide to pursue BI and XI, but the work you are asked to do involves Portals and XI? Therefore, it pays off to not get too theoretical about what makes the best skills mix. A better idea is to let your project work lead the way.

And of course, the more phone calls you get from recruiters about a particular skill you have, the more you should pursue it. If you let the market decide, you will almost always make a good choice for your skills choice.

Third-party plug-ins to support UML modeling in NetWeaver

How is UML modeling supported in SAP NetWeaver?

At the current time, you'll need to install a 3rd party plug-in to the developer studio (e.g. Borland Together for Java). For ABAP, there is a UML product from ensemble. However, I have no knowledge of the efficacy or otherwise of these tools.

Upgrading to mySAP ERP 2005 ECC 6.0 with NetWeaver 2004S

We need to migrate from a MF/DB2 v8.2 to a HP-UX/Oracle DB. We are running with mySAP ERP 2004, ECC 5.0 with NetWeaver 2004, ABAP stack only, and 5 lower life cycle systems in the landscape. Can we move to mySAP ERP 2005 ECC 6.0 with NetWeaver 2004S? Please explain the timeframe as well as the steps involved.

I do not see any reason why you would not be able to move to ECC 6.0. The first step would be to migrate the SAP environment to HP-Unix / Oracle. Next, the upgrade to ECC 6.0 can be started.

The migration to the new platform will probably take you at least several weeks and up to a couple of months, especially if new hardware needs to be ordered, installed, and configured. Adapting interfaces and output management to the new platform should also not be underestimated. In addition, in-house developed ABAP reports which use database dependent functionality need to be adapted to the new RDBMS.

The time needed for the upgrade to ECC depends on the number of SAP modules in use and the number of modifications to the SAP standard and the in-house developments.

What are the hardware requirements for SAP 6.4 GUI and NetWeaver 2004s?

Where can I find the hardware prerequisites and requirements for SAP 6.4 GUI and NetWeaver 2004s?

The supported platforms are described in the platform matrix (http://service.sap.com/pam), NetWeaver 2004s > operating systems. The SAP GUI requirements are discussed in detail in OSS note 893348: Hardware and software requirement for NW2004s and note 26417: SAP GUI resources: Hardware and software.

Is it wise to convert to an SAP NetWeaver EP/XI career from a Java/J2EE background?

I have approximately two years of experience with Java/J2EE. Recently I received a job offer from a company, but the work will include SAP NetWeaver EP and XI. Is it wise to shift from Java to SAP NetWeaver based on this information?


You will be using some Java/J2EE. EP especially uses lots of J2EE. Also, I think you will earn more money in the SAP world if you were to convert.






How can ABAP developers survive in a NetWeaver era?

SAP's NetWeaver push and SOA (service-oriented architecture) strategy have left ABAP developers confused about their future. In this podcast we talk with SearchSAP.com careers expert, and president of jonerp.com, Jon Reed and Thomas Jung, a NetWeaver product manager with SAP Labs, about how developers can enhance their skills to keep up.

Find the BADI related to your transaction in minutes

These steps should enable you to find any BADI related to any transaction in a matter of minutes.

1) Go to the transaction SE37 to find your function module.
2) Locate the function SXV_GET_CLIF_BY_NAME.
3) Put a breakpoint there.
4) Now open a new session.
5) Go to your transaction.
6) At that time, it will stop this function.
7) Double click on the function field EXIT_NAME.
8) That will give you name of the BADI that is provided in your transaction.

How to switch off message determination in BAPI_PO_CREATE1

Want to switch off message determination in BAPI_PO_CREATE1 and BAPI_PO_CHANGE? The parameter no_messaging permits you to do just this.

Use this parameter to specify whether the message determination should of purchase orders should be deactivated or not.

  • If the value of the parameter is 'X', the purchase order is created without message determination.
  • If the value of the parameter is anything else, the purchase order is created with message determination
Simple as that!

How to include an authorization group restriction in an SAP query

The field 'authorization group' allows you to enter an authorization group up to eight characters long. If you specify an authorization group, it is inherited as an attribute by every report generated for a query via this InfoSet. This means that only users authorized in their user master records to execute programs from this authorization group can execute these queries. Authorization groups thus provide a way of protecting reports generated by the query from unauthorized execution.

In SQ02: Change InfoSet > Goto Global Properties > Enter in Authorization group
In SQ01: Query > More functions > Generate program

How do I avoid running ABAP programs more than once?

There is another way to avoid an ABAP program running more than once, without using the function ENQUEUE_ESINDX? If there is, can you tell me how?

If ENQUEUE_ESINDX causes you problems, why not create your own lock object and use that? I've not encountered the use of this particular FM for locking program runs.

What are some ABAP development resources?

QUESTION POSED ON: 01 September 2006
I have read white papers that claim ABAP development programs need to be object oriented. I have looked for decent examples, but have not found anything except for snippets. I have the ABAP Controls Technology book and Design Patterns in Object Oriented ABAP. I mostly write large table update programs, for example to update the materials or BOM tables using BAPIs or BDCs.

I have looked through the demos and examples within SAP, but still have not found anything I thought appropriate for the type of mass-updating programs I write. Design Patterns is interesting but of course it is a dialog program with lots of user interaction.

Do you know where I can find decent examples of batch processing programs which use and take advantage of classes, methods, inheritance, implementation, and events; i.e., the concepts that fully use the OO advantages?

Most programming problems can be addressed using object methods. The ease with which this can be done, depends considerably on the libraries of classes that are available to the developer. This is one area where ABAP Objects is very deficient, especially in R/3 -- there are few useful classes that you can just pick up and use.

If you have never developed using OO techniques, then I'd suggest NOT starting with ABAP. Rather go through a good Java tutorial, for example Head First Java by Kathy Sierra is excellent. Once you've learned about OO programming, then you can start applying it to the SAP environment. The more recent the release, the easier it is. The new dimension products also contain large amounts of object-oriented development.


How do I run ABAP programs through a Java-based interface?

I have to develop a Web-based application using IBM Websphere Application Server that accesses SAP using J2C connectors. My problem is that I need to run ABAP programs that access (update/insert/delete) custom "Z tables" in SAP. How can I run ABAP programs from VisualAge for Java (using Websphere J2C connector for SAP)?

The best way to run ABAP programs through a Java-based interface is to RFC-enable them. By creating an RFC wrapper around your ABAP programs, you allow the R/3 application server to effectively manage any communication from the outside world. If you have already written the application in ABAP, then you simply need to go into the Function Builder (SE37), create a new RFC with the requisite parameters, insert your ABAP program, and check the 'RFC Enable' box under Administration.

If you are doing simple table lookups, you may want to build your application logic in Java (e.g. when and what data is retrieved) and use RFCs such as RFC_READ_TABLE to connect to R/3. This allows you to maintain your application outside of SAP and means that you can leverage some of the more advanced features of Enterprise Java (messaging, EJBs, etc.).

How can I create a two-dimensional array in ABAP?

ABAP does not use an array concept, but anything you would do with a multidimensional array, you can do with ABAP.

The internal table is like a one-dimensional array of records. For two dimensions, you have a number of choices. You can put the second dimension as another key field. You can use nested tables -- where a field of the record is in a table itself. And if you really want to, you can create dynamic tables -- where the number of fields in a record isn't determined until run time.

Rather than look at the question of how to create a two-dimensional array in ABAP, the question you should be addressing is "How can I solve this business/data problem?" It is a mistake to apply the concepts of one programming language directly to another. A wider view gives better solutions.

Monday, April 14, 2008

Useful standard reports

REKH0004

SAP demo program that shows how to do 2D, 3D, and 4D graphics.

RGUGBR00

Substitution/Validation utility

RHGEN00

Regen PD and PA inconsistencies

RHGRENZ0

Delimit IT1000 and related 1001s. Program will delete any 1001 infotypes whose start date is after the delimit date.

RHGRENZ1

Extend the end date on delimited records. Very useful when you delimit a bunch of records incorrectly, and need to change the end date.

RHGRENZ2

Delimit IT1001 only.

RKCTSEAR

Search source code for up to two strings. Also see RSRSCAN1 and RPR_ABAP_SOURCE_SCAN.

RPDTRA00

List all HR transactions.

RPR_ABAP_SOURCE_SCAN

Search ABAP code for a string. Has many more options for selecting the ABAPs to search than RSRSCAN1 or RKCTSEAR.

RPUAUD00

HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster.

RPUAUDDL

HR Report to delete audit data from the PCL4 Audit Cluster.

RPUDELPN

Delete all info for an employee number, including cluster data and infotypes

RPUP1D00/10

View/Delete data from PCL1 Cluster

RPUP2D00/10

View/Delete data from PCL2 Cluster

RPUP3D00/10

View/Delete data from PCL3 Cluster

RPUP4D00/10

View/Delete data from PCL4 Cluster

RSABAPIV

Mass print/display of ABAP/4 help text

RSAVGL00

Table adjustment across clients

RSBDCBTC

Submit a BDC job with an internal batch number and wait for the end of the batch input session.

RSBDCDRU

Prints the contents of a Batch Input session. No options for error transactions only.

RSBDCOS0

Execute UNIX commands. Looks similar to the old SAPMSOS0 program that disappeared in 3.0

RSBDCSUB

Release batch input sessions automatically

RSBTCDEL

Clean the old background job records

RSSDOCTB

R/3 Table Manual - prints a list of all fields in the selected tables with the field name and the field documentation.

RSCLTCOP

Copy tables across clients

RSDBCREO

Clean batch input session log

RSINCL00

Extended program list

RSNASTED

Process message control output for entries in the NAST table

RSORAREL

Get the Oracle Release

RSPARAM

Display all instance parameters

RSPO0041

Removing old spooling objects

RSRSCAN1

Search source code for a given string. Will also search includes. Also see RKCTSEAR and RPR_ABAP_SOURCE_SCAN.

RSSNAPDL

Clean the old ABAP error dumps

RSTBSERV

Compare a contents of a table between clients

RSTXFCON

Converts SAPScript page formats

RSTXSCRP

Save a SAPScript layout set to disk, and load it back into SAP.

RSTXSCRP

Transport SAPscript files across systems

RSTXSCRP

Upload and download SAPScript layout sets

RSTXTPDF4

Pass the spool number of a report's output to this program to have the output converted to PDF format.

RSTXTRAN

Add standard texts to a transport so they can be moved between systems.

RSUSR003

Check the passwords of users SAP* and DDIC in all clients

RSUSR006

List users last login

RSWBO052

Change development class of a sapscript (provided by Alan Cecchini)

RSWBO060

put objects into a request and transport it to any other system

Interactive Reporting

Requirement:

List the first 100 purchase requsitions at the plant 'PL01' (table EBAN). Then make it possible to change the purchase requisition itself from the list by clicking twice on the row or by using a push-button.

Solution:

In the purchasing (MM modul) you can process the purchase requisitions. The purchase requisitions define primarily the need for a material/service. List the first 100 purchase requsitions at the plant 'PL01' (table EBAN). Then make it possible to change the purchase requisition itself from the list by clicking twice on the row or by using a push-button.

ADDITIONAL REQUIREMENTS TO THE LIST:

1. CONTENT: PURCHASE REQUISITION NUMBER, ITEM NUMBER, DOCUMENT TYPE, MATERIAL, QUANTITY, UNIT OF MEASURE

2. LAYOUT: MAIN HEADER SHOULD INCLUDE

PROGRAM NAME, COMPANY NAME, PLANT, PURCHASE GROUP, CREATION DATE, PAGE NUMBER

3. ONE PAGE SHOULD HAVE 50 LINE ITEM


    report zmjud001 no standard page heading line-size 85 line-count 50.
    * DATA /TABLES DECLARATION*
    tables: eban.
    data: prog_nam(8).
    data: begin of pur_req occurs 100,
    ekgrp like eban-ekgrp,
    werks like eban-werks,
    banfn like eban-banfn,
    bnfpo like eban-bnfpo,
    bsart like eban-bsart,
    estkz like eban-estkz,
    matnr like eban-matnr,
    menge like eban-menge,
    meins like eban-meins,
    numb(3) type n.
data: end of pur_req.
* THE REPORT HEADER
prog_nam = sy-repid.
top-of-page.
perform header_write.
* SELECTION
start-of-selection.
pur_req-numb = 1.
* SELECT ONLY THOSE FIELDS THAT WILL BE USED FROM THE TABLE EBAN, AND ONLY
*THE FIRST100 RECORDS OF THE THE PLANT 'PL01'
select banfn bnfpo bsart ekgrp matnr werks menge meins frgdt estkz
into corresponding fields of eban from eban up to 100 rows
where bsart = 'NB' "document type 'NB' = purchase requisition
and werks = 'PL01'
and statu = 'N' "processing status
and loekz = ' '. "deletion indicator
* THE SELECTED RECORDS SHOULD BE APPENDED TO INTERNAL TABLE 'PUR_REQ'
pur_req-banfn = eban-banfn.
pur_req-matnr = eban-matnr.
pur_req-werks = eban-werks.
pur_req-ekgrp = eban-ekgrp.
pur_req-bnfpo = eban-bnfpo.
pur_req-bsart = eban-bsart.
pur_req-menge = eban-menge.
pur_req-meins = eban-meins.
pur_req-estkz = eban-estkz.
append pur_req.
pur_req-numb = pur_req-numb + 1.
endselect.
* CHECK WHETHER THE TABLE EBAN CONTAINS ANY PURCHASE REQUISITIONS
if sy-subrc ne 0.
write: / 'No Purchase Requisition found.'.
endif.
* PROCESS THE INTERNAL TABLE; WRITE OUT THE REQUIRED FIELDS AND HIDE THE
*FIELDS YOU ARE GOING TO USE LATER
loop at pur_req.
write: /1 pur_req-numb, 9 pur_req-banfn, 21 pur_req-bnfpo, 31 pur_req-bsart, 41 pur_req-matnr,
61 pur_req-menge unit pur_req-meins, 82 pur_req-meins.
hide: pur_req-matnr, pur_req-werks, pur_req-banfn.
endloop.
clear pur_req-banfn. clear pur_req-matnr. clear pur_req-werks.
* IN THE MENU PAINTER (SE41) CREATE A STATUS TO YOUR PROGRAM. HERE YOU CAN
*DEFINE THE PUSH-BUTTON
set pf-status 'basic'.
* CHOOSE A REQUISITION (WITH DOUBLE CLICKING OR PUSH-BUTTON) IN THE LIST! THE
*PURCHASE REQUISITION IS GOING TO COME UP
at line-selection.
if pur_req-banfn <> space.
set parameter id 'BAN' field pur_req-banfn. " parameter id for pruchase req. number
call transaction 'ME52' and skip first screen. "trans. code 'ME52': Change Purchase Requis.
clear pur_req-banfn. clear pur_req-matnr.
clear pur_req-werks.
endif.
* FORM THE HEADER
form header_write.
write: / prog_nam, 32 'FUN-FACTORY',
/ 'Purch.Gr.:', pur_req-ekgrp, 26 'Purchase Requisition List',
61 'As Of Date:', 75 sy-datum,
/ 'Plant:', pur_req-werks, 61 'Page:', 75 sy-pagno.
uline.
write: / text-001,
/ text-002.
uline.
endform.

NOTES:

1. PUSH-BUTTON DEFINITION (SE11)

    In the Menu Painter a status must be created where you can maintain the function keys

2. MAINTAIN THE TEXT ELEMENT TO THE HEADER OF THE LIST

    (SE38 choose the object component 'TEXT ELEMENTS' at the first screen, then the'TEXT SYMBOLS'. Here you can add a number (I.E. 001) to 'TEXT SYMBOL' and write the header title into the text field like this:

001 Numb.__Requisition__Item___Document_____Material_____________________Quantity_Unit_of

002 _________Number_____Num______Type________________________________________Measure

THE FIRST 15 LINE ITEMS OF THE RESULT AND THE HEADERS:

ZMJUD001                     FUN-FACTORY                    
Purch. Gr.: 001 Purchase Requisition List As Of Date: 05/09/1997
Plant: D031 Page: 1
-------------------------------------------------------------------------
Numb. Requisition Item Document Material Quantity Unit of
Number Num Type Measure
-------------------------------------------------------------------------
1       10049227     00010   NB        11141-030       23.000    CS
2 10049223 00010 NB 11141-030 23.000 CS
3 10049225 00010 NB 11141-030 13.000 CS
4 10049226 00010 NB 11141-030 9.000 CS
5 10049224 00010 NB 11141-030 23.000 CS
6 10049222 00010 NB 11141-030 23.000 CS
7 10049221 00010 NB 11141-030 38.000 CS
8 10049228 00010 NB 11141-030 23.000 CS
9 10049229 00010 NB 11141-030 23.000 CS
10 10049230 00010 NB 11141-030 22.000 CS
11 10049231 00010 NB 11141-030 24.000 CS
12 10049232 00010 NB 11141-030 24.000 CS
13 10049233 00010 NB 11141-030 24.000 CS
14 10049234 00010 NB 11141-030 23.000 CS
15 10049235 00010 NB 11141-030 5.000 CS

Batch Input with 'Call Transaction'

Requirement:

Choose a transaction and write a Batch Input program with 'Call Transaction'. Do not use the Message tab feature of 'Call Transaction'. In this case the last error message will be at the SY-MSG* system fields. Recreate the complete error message from table T100! (This example is also used by the demonstration of SY-MSG* system fields)

Solution:
    REPORT ZSYSTEM LINE-SIZE 255.
    TABLES: T100.
    * Batch-input data
    DATA: BEGIN OF G_BDCDATA OCCURS 100.
    INCLUDE STRUCTURE BDCDATA.
    DATA: END OF G_BDCDATA.

    DATA: G_MESSAGE(200).

    PERFORM FILL_BDCDATA.
    CALL TRANSACTION 'FI01' USING G_BDCDATA MODE 'N'.
    * of course it is nicer with a message itab, but this example
    * should also demostrate the use of system variables.
    SELECT SINGLE * FROM T100 WHERE
    SPRSL = 'E'
    AND ARBGB = SY-MSGID
    AND MSGNR = SY-MSGNO.
    G_MESSAGE = T100-TEXT.

    PERFORM REPLACE_PARAMETERS USING SY-MSGV1
    SY-MSGV2
    SY-MSGV3
    SY-MSGV4
    CHANGING G_MESSAGE.

    WRITE: / 'System variables:'.
    SKIP.
    WRITE: / ' Sy-msgty:', SY-MSGTY.
    WRITE: / ' Sy-msgid:', SY-MSGID.
    WRITE: / ' Sy-msgno:', SY-MSGNO.
    WRITE: / ' Sy-msgv1:', SY-MSGV1.
    WRITE: / ' Sy-msgv2:', SY-MSGV2.
    WRITE: / ' Sy-msgv3:', SY-MSGV3.
    WRITE: / ' Sy-msgv4:', SY-MSGV4.
    SKIP.
    WRITE: / 'The transaction was called with a wrong country code.'.
    WRITE: / 'The error message should be either that or that you have'.
    WRITE: / ' no authorisation to execute the transaction'.
    SKIP.
    WRITE: / 'Message:'.
    SKIP.
    WRITE: / SY-MSGTY, G_MESSAGE.

    *---------------------------------------------------------------------*
    * Build up the BDC-table *
    *---------------------------------------------------------------------*
    FORM FILL_BDCDATA.
    REFRESH G_BDCDATA.

    PERFORM BDC_DYNPRO USING 'SAPMF02B' '0100'.
    PERFORM BDC_FIELD USING 'BNKA-BANKS' 'ZZZ'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE' 'QQQQQ'.

    ENDFORM.

    *---------------------------------------------------------------------*
    * FORM BDC_DYNPRO *
    *---------------------------------------------------------------------*
    * Batchinput: Start new Dynpro *
    *---------------------------------------------------------------------*
    FORM BDC_DYNPRO USING P_PROGRAM P_DYNPRO.
    CLEAR G_BDCDATA.
    G_BDCDATA-PROGRAM = P_PROGRAM.
    G_BDCDATA-DYNPRO = P_DYNPRO.
    G_BDCDATA-DYNBEGIN = 'X'.
    APPEND G_BDCDATA.
    ENDFORM. " BDC_DYNPRO

    *---------------------------------------------------------------------*
    * FORM BDC_FIELD *
    *---------------------------------------------------------------------*
    * Batchinput: Feld hinzufugen *
    *---------------------------------------------------------------------*
    FORM BDC_FIELD USING P_FNAM P_FVAL.
    CLEAR G_BDCDATA.
    G_BDCDATA-FNAM = P_FNAM.
    G_BDCDATA-FVAL = P_FVAL.
    APPEND G_BDCDATA.
    ENDFORM. " BDC_FIELD
    *---------------------------------------------------------------------*
    * FORM REPLACE_PARAMETERS *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    * --> P_PAR_1 *
    * --> P_PAR_2 *
    * --> P_PAR_3 *
    * --> P_PAR_4 *
    * --> P_MESSAGE *
    *---------------------------------------------------------------------*
    FORM REPLACE_PARAMETERS USING P_PAR_1
    P_PAR_2
    P_PAR_3
    P_PAR_4
    CHANGING P_MESSAGE.

    * erst mal pruefen, ob numerierte Parameter verwendet wurden
    DO.
    REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDDO.
    DO.
    REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDDO.
    DO.
    REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDDO.
    DO.
    REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ENDDO.
    * falls keine numerierten Parameter vorh., ersetzen wie gehabt
    REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
    CONDENSE P_MESSAGE.
    IF SY-SUBRC EQ 0.
    REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
    CONDENSE P_MESSAGE.
    IF SY-SUBRC EQ 0.
    REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
    CONDENSE P_MESSAGE.
    IF SY-SUBRC EQ 0.
    REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
    CONDENSE P_MESSAGE.
    ENDIF.
    ENDIF.
    ENDIF.

    ENDFORM. "replace_parameters

Hide technique in reports

You use the HIDE technique while creating a list level to store line-specific information for later use. To do so, use the HIDE statement as follows:

HIDE .

This statement places the contents of the variable for the current output line (system field SY­LINNO) into the HIDE area. The variable must not necessarily appear on the current line.

To make your program more readable, always place the HIDE statement directly after the output statement for the variable or after the last output statement for the current line.


As soon as the user selects a line for which you stored HIDE fields, the system fills the variables in the program with the values stored. A line can be selected

· by an interactive event.

For each interactive event, the HIDE fields of the line on which the cursor is positioned during the event are filled with the stored values.

· by the READ LINE statement.

You can think of the HIDE area as a table, in which the system stores the names and values of all HIDE fields for each list and line number. As soon as they are needed, the system reads the values from the table. The example below presents some of the essential features of interactive reporting. The basic list contains summarized information. By means of the HIDE technique, each detail list contains more details.

The following program is connected to the logical database F1S.

REPORT demo_list_hide NO STANDARD PAGE HEADING.

TABLES: spfli, sbook.

DATA: num TYPE i,
dat TYPE d.


START-OF-SELECTION.
num = 0.
SET PF-STATUS 'FLIGHT'.


GET spfli.
num = num + 1.
WRITE: / spfli-carrid, spfli-connid,
spfli-cityfrom, spfli-cityto.HIDE: spfli-carrid, spfli-connid, num.

END-OF-SELECTION.
CLEAR num.


TOP-OF-PAGE. WRITE 'List of Flights'.ULINE. WRITE 'CA CONN FROM TO'. ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-pfkey.


WHEN 'BOOKING'.
WRITE sy-lisel.
ULINE.


WHEN 'WIND'.
WRITE: / 'Booking', sbook-bookid,'Date ', sbook-fldate.ULINE. ENDCASE.

AT USER-COMMAND.
CASE sy-ucomm.


WHEN 'SELE'.


IF num NE 0. SET PF-STATUS 'BOOKING'. CLEAR dat. SELECT * FROM sbook WHERE carrid = spfli-carridAND

IF sbook-fldate NE dat.connid = spfli-connid. dat = sbook-fldate. SKIP. WRITE / sbook-fldate.POSITION 16.

ELSE. NEW-LINE. POSITION 16.

ENDIF.
WRITE sbook-bookid.
HIDE: sbook-bookid, sbook-fldate, sbook-custtype,

sbook-smoker, sbook-luggweight, sbook-class.ENDSELECT. IF sy-subrc NE 0.

WRITE / 'No bookings for this flight'.

ENDIF.

num = 0.

CLEAR sbook-bookid.

ENDIF.
WHEN 'INFO'.

IF NOT sbook-bookid IS INITIAL.

SET PF-STATUS 'WIND'.

SET TITLEBAR 'BKI'.

WINDOW STARTING AT 30 5 ENDING AT 60 10.

WRITE: 'Customer type :', sbook-custtype,

/ 'Smoker :', sbook-smoker,

/ 'Luggage weight :', sbook-luggweight UNIT 'KG',

/ 'Class :', sbook-class.

ENDIF.
ENDCASE.



At the event START-OF-SELECTION, the system sets the status FLIGHT for the basic list. In status FLIGHT, function code SELE (text SELECT) is assigned to function key F2 and to a pushbutton. So the event AT USER-COMMAND is triggered if the user double-clicks, presses F2, or chooses the pushbutton SELECT.

The three fields SPFLI-CARRID, SPFLI-CONNID, and NUM are stored in the HIDE area while creating the basic list. After selecting a line, the system displays the detail list defined in the AT USER-COMMAND event for function code SELE. In the AT USER-COMMAND event, the system refills all fields of the selected line that were stored in the HIDE area. You use NUM to check whether the user selected a line from the actual list. The detail list has status BOOKING, where F2 is assigned to function code INFO (text: Booking Information). The detail list presents data that the program selected by means of the HIDE fields of the basic list. For each list line displayed, the system stores additional information in the HIDE area.

If the user selects a line of the detail list, the system displays the "hidden" information in a dialog box with the status WIND. The status has the type Dialog box, and contains the proposed functions for a list status. The program uses SBOOK­BOOKID to check whether the user selected a valid line.

The program itself sets all page headers and the title bar of the dialog box.

Passing data using SAP memory

There are two cross-program memory areas to which ABAP programs have access that you can use to pass data between programs.

SAP Memory

SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters).

These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens (see below).

ABAP Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse. For further information, refer to Data Clusters in ABAP Memory

ALV Report using REUSE

his program creates an ALV report for Daily Cash Receipts for a selected date range.

REPORT sy-repid.

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

*/ Description :This program creates an ALV report for Daily Cash

* Receipts for a selected date range.

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

* Global data declaration

TYPE-POOLS: slis.

* Global structure of list

TYPES: BEGIN OF i_cust_invoices, "This is a temp-table where SELECT

"data is to be stored.

bkpf LIKE bkpf, "Acct Doc Header structure

bseg LIKE bseg, "Acct Doc Segment struc

kna1 LIKE kna1, "Customer Master struc

skat LIKE skat, "Chart of Accts struc

END OF i_cust_invoices.

TABLES: bkpf, "TABLES: def of Database tables.

bseg,

kna1,

skat.

*/ Selection and Input Parameters

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.

SELECT-OPTIONS: s_belnr FOR bseg-belnr, "Acct Doc number

s_budat FOR bkpf-budat, "Doc Posting Date

s_blart FOR bkpf-blart DEFAULT 'DZ'. "Document Type

SELECTION-SCREEN END OF BLOCK block1.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: gt_outtab TYPE i_cust_invoices OCCURS 0 WITH HEADER LINE.

DATA: g_repid LIKE sy-repid.

DATA: i_bkpf TYPE bkpf OCCURS 0 WITH HEADER LINE.

* Initialization fieldcatalog

INITIALIZATION.

g_repid = sy-repid.

PERFORM fieldcat_init USING gt_fieldcat[].

* Start of Selection

START-OF-SELECTION.

* Data selection

PERFORM select_data TABLES gt_outtab.

* Display list

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = g_repid

it_fieldcat = gt_fieldcat[]

TABLES

t_outtab = gt_outtab.

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

* Forms

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

* Initialization fieldcatalog DEFINITION OF HEADING.

* Fieldnames and ref_fieldnames MUST be UPPER CASE !!

FORM fieldcat_init

USING rt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

DATA: pos TYPE i VALUE 1.

CLEAR ls_fieldcat.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-BUDAT'. "Posting Date

ls_fieldcat-ref_fieldname = 'BUDAT'.

ls_fieldcat-ref_tabname = 'BKPF'.

ls_fieldcat-key = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-BELNR'. "Acct Doc Number

ls_fieldcat-ref_fieldname = 'BELNR'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-HKONT'. "Acct number

ls_fieldcat-ref_fieldname = 'HKONT'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-KOSTL'. "Cost Center

ls_fieldcat-ref_fieldname = 'KOSTL'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'SKAT-TXT20'. "Acct Description

ls_fieldcat-ref_fieldname = 'TXT20'.

ls_fieldcat-ref_tabname = 'SKAT'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'SKAT-TXT50'. "Acct Description

ls_fieldcat-ref_fieldname = 'TXT50'.

ls_fieldcat-ref_tabname = 'SKAT'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

* ls_fieldcat-col_pos = pos.

* ls_fieldcat-fieldname = 'BSEG-AUGBL'. "Clearing Doc

* ls_fieldcat-ref_fieldname = 'AUGBL'.

* ls_fieldcat-ref_tabname = 'BSEG'.

* APPEND ls_fieldcat TO rt_fieldcat.

* CLEAR ls_fieldcat.

* pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-KUNNR'. "Cust number

ls_fieldcat-ref_fieldname = 'KUNNR'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'KNA1-NAME1'. "Customer name

ls_fieldcat-ref_fieldname = 'NAME1'.

ls_fieldcat-ref_tabname = 'KNA1'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-XBLNR'. "Ref Doc (Check) Number

ls_fieldcat-ref_fieldname = 'XBLNR'.

ls_fieldcat-ref_tabname = 'BKPF'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-SHKZG'. "DR/CR ind.

ls_fieldcat-ref_fieldname = 'SHKZG'.

ls_fieldcat-ref_tabname = 'BSEG'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-WRBTR'. "Amt in Doc Currency

ls_fieldcat-ref_fieldname = 'WRBTR'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-WAERS'. "Currency Key

ls_fieldcat-ref_fieldname = 'WAERS'.

ls_fieldcat-ref_tabname = 'BKPF'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-KURSF'. "Exchange Rate

ls_fieldcat-ref_fieldname = 'KURSF'.

ls_fieldcat-ref_tabname = 'BKPF'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-DMBTR'. "Amt in Local Currency

ls_fieldcat-ref_fieldname = 'DMBTR'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-GJAHR'. "Fiscal Year

ls_fieldcat-ref_fieldname = 'GJAHR'.

ls_fieldcat-ref_tabname = 'BSEG'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-BUZEI'. "Doc Line #

ls_fieldcat-ref_fieldname = 'BUZEI'.

ls_fieldcat-ref_tabname = 'BSEG'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-BSCHL'. "Posting Key

ls_fieldcat-ref_fieldname = 'BSCHL'.

ls_fieldcat-ref_tabname = 'BSEG'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

* Cost Center is not needed for cash posting - only expenses.

*

* ls_fieldcat-col_pos = pos.

* ls_fieldcat-fieldname = 'BSEG-KOSTL'. "Cost Center

* ls_fieldcat-ref_fieldname = 'KOSTL'.

* ls_fieldcat-ref_tabname = 'BSEG'.

* APPEND ls_fieldcat TO rt_fieldcat.

* CLEAR ls_fieldcat.

* pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-BUKRS'. "Company Code

ls_fieldcat-ref_fieldname = 'BUKRS'.

ls_fieldcat-ref_tabname = 'BKPF'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-BLART'. "Document Type

ls_fieldcat-ref_fieldname = 'BLART'.

ls_fieldcat-ref_tabname = 'BKPF'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BSEG-SGTXT'. "Item Text

ls_fieldcat-ref_fieldname = 'SGTXT'.

ls_fieldcat-ref_tabname = 'BSEG'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

pos = pos + 1.

ls_fieldcat-col_pos = pos.

ls_fieldcat-fieldname = 'BKPF-USNAM'. "User name

ls_fieldcat-ref_fieldname = 'USNAM'.

ls_fieldcat-ref_tabname = 'BKPF'.

LS_FIELDCAT-NO_OUT = 'X'.

APPEND ls_fieldcat TO rt_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. "fieldcat_init

* Data selection

FORM select_data TABLES rt_outtab LIKE gt_outtab[].

DATA: l_name LIKE tline-tdline.

* IF s_hkont IS INITIAL.

SELECT bukrs belnr blart budat usnam xblnr waers kursf INTO

CORRESPONDING FIELDS OF TABLE

i_bkpf FROM bkpf WHERE belnr IN s_belnr

AND blart IN s_blart

AND budat IN s_budat.

LOOP AT i_bkpf.

SELECT hkont kostl belnr gjahr buzei bschl shkzg dmbtr wrbtr sgtxt

kunnr INTO (bseg-hkont, bseg-kostl, bseg-belnr, bseg-gjahr,

bseg-buzei, bseg-bschl, bseg-shkzg, bseg-dmbtr,

bseg-wrbtr, bseg-sgtxt, bseg-kunnr) FROM bseg

WHERE belnr EQ i_bkpf-belnr.

CLEAR: KNA1, skat.

SELECT SINGLE * FROM skat WHERE SPRAS EQ SY-LANGU

AND KTOPL EQ '7100'

AND SAKNR = bseg-hkont.

"ska1, skb1 account # stored in SAKNR.

"in BSEG, account # stored in HKONT.

if bseg-SHKZG eq 'H'.

multiply : bseg-wrbtr by -1,

bseg-dmbtr by -1.

endif.

MOVE-CORRESPONDING: i_bkpf TO rt_outtab-bkpf,

bseg TO rt_outtab-bseg,

skat TO rt_outtab-skat.

SELECT SINGLE name1 INTO rt_outtab-kna1-name1 FROM KNA1

WHERE kunnr = rt_outtab-bseg-kunnr.

APPEND rt_outtab.

CLEAR: rt_outtab.

ENDSELECT.

ENDLOOP.

ENDFORM. " select_data

Blog Archive