Mar 23, 2016

User-exit to verify Valuation Class in MM02

Requirement:
To put a verification/validation when Valuation Class in MM02 is modified/changed.
Check if the new Valuation Class is listed in table T023 for the same Material Group (MARA-MATKL). If not, issue error message.

Solution:
Using EXIT_SAPLMGMU_001. There is changing parameter structure CMARA in this FM which contains VOLUM field. you can change volume by changing this field. The project name is MGA00001 in SMOD transaction.

1. Transaction CMOD. Project name MGA00001


2. Choose Enhancement MGA00001. and click Components

3. Double click on EXIT_SAPLMGMU_001

4. Double click on Include ZXMG0U02

5. Write the Codes, saved and activate.


  DATA lv_t023_bklas TYPE t023-bklas.

  SELECT SINGLE bklas FROM t023 INTO lv_t023_bklas
    WHERE matkl = wmara-matkl.

  IF sy-subrc EQ 0.
    IF wmbew-bklas NE lv_t023_bklas.
      MESSAGE w398(00) WITH 'Invalid valuation class' wmbew-bklas space.
      RAISE APPLICATION_ERROR.
    ENDIF.
  ENDIF.


6. Activate the User-exit.


Testing & result:

1. MM02 for Material. Material 4000000285 with Material Grup 0510150

As known in Table T023, Valuation Class allowed is GP05

2. Valuation Class changed to GP01

3. When saving, error message occurs.



Mar 22, 2016

Custom Print Program of T-Code F.62 (Print Journal Voucher)

Question:
I need to modify the data and the layout of transaction F.62 (Print Journal Voucher).  I have searched information from the web that it is possible to add a custom print program to modify the logic.  I would like to ask what is the transaction code in FI for configuring this Tcode F.62 to use this customize print program. (Like NACE for SD and MM modules). 

Answer:
Transaction OB98



SE38 for program ZFIRGB_0001 



SE71 for the SAPScript Form





Mar 17, 2016

Upload Log Item Text to FI Document

Question:
I need to upload FI document posting using BAPI_ACC_DOCUMENT_POST. However item text that I received is too long and need to store at item long text. So can we use BAPI_ACC_DOCUMENT_POST to upload long text for item text? If this possible, may I know how to do this.

Answer: 
You cannot pass item long text using this BAPI, Call the function module SAVE_TEXT after successfull call of BAPI Call Save_Text with following parameters. Text_ID : 0001 (Notes) Text_object : DOC_ITEM (Line Item Text) Language : EN Text Name : Company code +Document NO + Fiscal Year + Line item ID


Mar 11, 2016

How to Download Files from AL11?

SCN (SAP Community Network) regularly receives the question: how can be files downloaded from the R/3 server via transaction AL11?

Unfortunately there are no standard transactions or reports which could provide such functionality, but there are some "workarounds" which can help with that.
Let's not forget: transaction AL11 just shows the files available on the server, therefore the "workarounds" are simple: let's look for programs which allow downloading files from the server to the front end!

The following chart shows a simplified flow how you can find the ideal download tool - then you can read further information below.




Point 1 - First you need to find out whether component EA-APPL is installed on the SAP system.
This component provides some ready-to-use tools which you can use to easily download files.
The easy way to find this out is to go to menu System -> Status... in any window, then select button "Component information". If EA-APPL is installed, you can see it in the appearing list.
You can see an example here:





The "hard way" is to go to transaction SPAM and press button Package level. You can see EA-APPL here too if it is installed.
For example:





Point 2 - Use transaction CG3Y.
This transaction is easy to use: you just need to enter the path of the required file and the path where the file should be downloaded to the front end. Simple as that! Here is an example:



Point 3 - Use program CACS_FILE_COPY.
You can start it via transaction SE38 or SE80. In the program you can select "Applicn on Presentation Server", and set the Source and Target Files.
E.g.:



Point 4 - Download the file as a simple list.
When you open the file in transaction AL11, you can download it as a simple list via menu System -> List -> Save -> Local file (see the following image).
You can select "unconverted" to save the data as a regular file, or "spreadsheet" to save the data which can be used in Excel.



Point 5 - Problem: downloaded files are truncated.
When you save the file with the method from Point 4, it may happen that the files are truncated.
Read Wiki http://wiki.scn.sap.com/wiki/x/LIH-FQ for the solution.



Point 6 - Use function module ARCHIVFILE_SERVER_TO_CLIENT.
This is an unreleased function module which can be started from transaction SE37. Since this function module was intended for SAP-internal purposes, results may vary.
Starting ARCHIVFILE_SERVER_TO_CLIENT via testing in transaction SE37 looks like this:




Point 7 - Write your own program on OS level.
Unfortunately this point lies far outside the boundaries of this guide: this solution depends on the OS editions, used network protocol, firewall/security settings, etc.
This guide can't help here - however, the other Spaces on SCN might be a good place to start to collect ideas.


Ref: http://scn.sap.com/docs/DOC-55795

ABAP Transaction Codes Related to Java Administration

Applies to:
SAP R/3 servers from 4.6C onwards to the latest NetWeaver releases. Some TCodes can even be used for previous releases; however their functionality (and the transaction code screens) may differ. For more information, visit the Java homepage.

Summary
In a productive landscape, an SAP J2EE server/ SAP Enterprise portal or any other application based on the JAVA engine is in constant interaction with a variety of backend R/3 servers, be it UME related, internet application components (IAC’s) like ESS or MSS, TREX etc. This guide describes the main TCodes from the ABAP end that can be useful to assist troubleshooting in such cases where connection is made from the j2ee server to the R/3 server or vice versa.

Read more at sdn.sap.com
 

Mar 9, 2016

Finding SD User Exits Using SPRO

We can quickly find all user exits available in SD using transaction SPRO.

Step 1:
Go to transaction SPRO and double click on ‘SAP Reference IMG’.

























Step 2:
On the next screen, navigate to “Sales and Distribution > System Modifications > User Exits” to view all user exits (highlighted in the screenshot below) available in SD.













































Step 3:
To view all user exits available for “User Exits for Partner Determination”, please view the documentation (by clicking on the button shown in the screenshot below). The documentation will provide us all user exits available.
























For example, when viewing the documentation of “User Exits for Partner Determination”, we can noticed that the following user exits are available:

EXIT_SAPLV09A_001
EXIT_SAPLV09A_002
EXIT_SAPLV09A_003
EXIT_SAPLV09A_004

Converting Smart Forms to PDF format in SAP

If you want to convert an SAP Smart Forms to PDF format directly, please follows the following steps:

Step 1:
When the smartform is in print preview mode, enter the command ‘PDF!’ in the command bar and press ‘Enter’.
























Step 2:
If adobe acrobat reader is installed correctly on the machine, a PDF version of the smartforms will be generated.


Rapidly Find Node In SmartForms

This is a nice trick to rapidly find any node in a SAP Smart Form using a search functionality (or CTRL + F). To be able to search any SAP smart form node, we will have to enable ‘Additional Control Services’ setting (available in the GUI options).


Step 1: Enable ‘Additional Control Services’ in SAP GUI Options.

Click on the ‘GUI Options’ or ‘Customize Local Layout’ button (please refer to the below screenshot) and select ‘Options’.




On the next screen which appears, click on ‘Control Settings’ and check ‘Enable addition control services’.































Step 2: Generate the Smart form as HTML Page via ‘Print’ option.

Now to search for a specific node in a Smart Form, first expand all the nodes in the Smart Form.
Then right click on any main node and select ‘Services > Print‘ from the list.





















Step 3: Search for a smart form element or node

The smart form will open in ‘Internet Explorer’ as an HTML page. To search for a specific node, just press the button ‘CTRL + F’ and search any required text.






















Voila…

Hope this helps.

Creating Routine Using VOFM

1. Go to the transaction code VOFM.

2. In the menu bar, choose between Table > Display or Table > Maintain

3. The screenshot shows an example when modifying subroutine in VOFM responsible for the Data Transfer > Billing Documents.














4. Below is a list of all the sub routines in this specific VOFM (Data Transfer > Billing Documents)





































5. Here, I will modify the sub routine 913 or 917.

6. To modify a specified sub routine, double click on the sub routine to modify.

Please Note: That you will required an ACCESS KEY in order to be able to make any modifications to the routine. ACCESS KEY is independent for each sub routine.

Important: After transporting modify VOFM subroutines to other environments, please execute the program ”RV80HGEN’  in SE38 to activate all subroutines. If this action is not carried out, the following exception (VOFM Error) will be raised:

The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_FORM', was not caught in procedure "VBRK_VBRP_DATENTRANSPORT" "(FORM)", nor was it propagated by a RAISING clause.

Since the caller of the procedure could not have anticipated that the exception would occur, the current program is terminated. 
The reason for the exception is: The program "SAPLV60A" is meant to execute an external PERFORM, namely the routine "DATEN_KOPIEREN_601" of the program "SAPFV60C", but this routine does not exist.




Smartform Graphics (or Logo) Appearing In Reverse

There is an issue which arises in SAP Smart forms where graphics (or logo) used on smart forms appears in reverse (upside down) when printed on some HP Deskjets.

Issue:
This issue is because we are using the specific SAP driver ‘SAPWIN’ on HP Deskjets printers. The issue was described in the OSS note 683605.

Solution:
The solution is to install and use the appropriate HP printer drivers in SAP.

If the output device ‘LOCL’ is attached to an HP Printer, then the HP driver must be installed. To view which driver is installed on the system, go to transaction SPAD, enter the output driver and press ‘Enter’. On the below screenshot, we can noticed that the driver (device type) is ‘SAPWIN’.

















If an HP Deskjet printer is attached to the output device ‘LOCL’, then graphics used on smart form will appear in reverse. We will have to install the specific HP Deskjet printer driver and assign it to the output device.

The following steps will explain how to install and assign an HP printer driver ‘ZHPP3005’ to the output device.



Installation and assignment of printer driver in SAP:

Step 1: Download Driver (Device Type):

Please download the driver (or Device Type) for the printer being used from HP website. Note that ‘Driver’ is also referred as ‘Device Type’ in SAP.


Step 2: Install the Driver in SAP:

In transaction SPAD, please go to ‘For devices types > Import’:












On the next screen, please selects ‘Device Type’, enter the name of the driver, set the mode to ‘IMPORT’ and execute the program.






















The program will then prompts for the driver downloaded in step 1, please select the downloaded driver.

The following screen will appears showing that the driver was successfully imported in SAP.









Step 3: Assign the driver to the Device Type:

Once we have installed the driver (in step 2) we will have to assign it to the appropriate output device (printer) in transaction SPAD.

In transaction SPAD, please enter the output device (for example LOCL) and click on the button display.
























On the next screen, please select the driver (or Device Type) we have installed in step 2 and save the changes.






















After installing and assigning the new driver, the reverse graphics/logo issue must be solved if you are using an HP Deskject printer.

Upload A Logo in Smartforms via the Transaction Code SE78

To upload a logo in SAP smart form is very easy, just go to transaction SE78 and follow the following steps to upload the logo on SAP:

Step 1: In SE78, double click on ‘BMAP Bitmap Images’:











Step 2: A popup will appears, browse the logo and enter a name.





















Note: If you are uploading a color logo, select the radio button ‘Color Bitmap Image’.

Step 3: Once all the details have been filled, press the button ‘Tick’ or just press ‘Enter’. The graphic/logo will be stored in SAP.

Once the logo/graphic has been uploaded, we will add the logo in a smart form window.

Step 4: Right click on the smart form window in which we want to add the logo/graphic and select ‘Create > Graphic’.
















Step 5: In the general attributes, add the logo information we have uploaded.















Activate the smart form and when viewing the smart form the logo will appear.

Note: Regarding the resolution, we can select the appropriate resolution.



In case we want to find the resolution of the actual logo, we will find it in the logo attributes in SE78.

Step 1: In SE78, search the logo by clicking on the match code:











Step 2: Enter the logo name we want to search:











Step 3: Once SAP found the logo, press ‘Enter’ to display the logo properties.











When the logo properties will appear, we will found the logo resolution in the technical attributes (please refer to the below screenshot).



Read Data From ABAP Stack

When implementing an enhancement, sometimes we need to read a field defined in the main program but which is not available in the enhancement point.

There is a technique which allows us the read the field if it is available in the ABAP stack.

Like for example (please refer to below screenshot), the field ‘TVAK-FPART’ is available in the main program ‘SAPMV45A’, however if the field is not available in the subroutine ‘VBAK_FUELLEN’ (program SAPFV45K) we can still access the field from the ABAP stack using the field symbol technique.




















Please find below a sample source code how to read data from the ABAP stack:

*Data Declarations:
*Constants.
CONSTANTS:
  lc_stack_loc(20) TYPE c VALUE '(SAPMV45A)TVAK-FPART'.

*Field Symbols.
FIELD-SYMBOLS: <fs_stackvalue> TYPE ANY.

*If we have been able to read the required data
*from ABAP stack, proceed.
ASSIGN (lc_stack_loc) TO <fs_stackvalue>.

IF sy-subrc EQ 0
AND <fs_stackvalue> IS NOT INITIAL.

* Write the value read from ABAP stack.
  WRITE <fs_stackvalue>.

ENDIF.


Ref: http://www.abapcookbook.com/sap-abap-tutorials/read-data-from-abap-stack/