_______________________________________________________________________________________________________________________

Home :: Sample Code :: Tutorials :: Interview FAQs :: Material :: SAP Books :: About :: Contact :: Links :: Disclaimer
_______________________________________________________________________________________________________________________

Jan 21, 2008

Cerate a Custom Pattern for ABAP Programs

Depending upon the coding standards set by the Project Leads or Clients, ABAPers would have to stick to a fixed pattern of coding their programs to adhere to those set standards. Most of the time we end up doing the formatting or rather beautification separately for each program, in turn wasting a lot of valuable time.

As time is the most valuable asset during any SAP project, it is a wise move to use time optimally. So, by creating our own custom patterns based on the set standards, we can apply these to all of our custom developments with just a click.

Want to know how? Go ahead and read this post...

  • While creating the first custom program for any project, after you give the program name, description and other attributes, get into the edit mode, on the main menu, go to Utilities -> More Utilities -> Edit Pattern -> Create Pattern as shown below


  • A screen will popup, name your pattern and hit Enter

  • Now in the Create/Edit Pattern Screen, enter your pattern, the way your ABAP code is to be formatted and Save. (I have created the pattern I use for programs on this blog)

  • That's it! Get back to your program, go to Pattern -> Other patterns and enter your pattern name as shown below

  • Your new ABAP programs will look just teh way your leaders want them to look. ENJOY!







Jan 14, 2008

Links

SAP Training CD ROMs
Computer Based Training on SAP Functional, Basis Administration and ABAP/4 Programming

Understanding SAP
Sams Teach Yourself SAP in 24 Hours (2nd Edition)
SAP R/3 for Everyone : Step-by-Step Instructions, Practical Advice, and Other Tips and Tricks for Working with SAP
Getting Started With Sap R/3 (Prima Techs Sap Book Series)
Anticipating Change: Secrets Behind the SAP Empire
Experience SAP
Flying Start SAP(R) R/3(R): A Guide to Get You Up and Running
The Whirlwind Series of SAP: In the Path of the Whirlwind: An Apprentice Guide to SAP
SAP: An Executive's Comprehensive Guide
SAP(R) Process, Analyze and Understand SAP(R) Processes with Knowledge Maps
Special Edition Using Sap R/3: The Most Complete Reference (Special Edition Using SAP R/3)
Xylem Structure and the Ascent of Sap
SAP: Inside the Secret Software Power
SAP IT Service & Application Management

Implementing SAP
Sap R/3 Implementation: Methods and Tools
Implementing SAP R/3: The Guide for Business and Technology Managers (Other Programming)
SAP Planning: Best Practices in Implementation
SAP(R) R/3 Implementation Guide
Successful SAP R/3 Implementation: Practical Management of ERP Projects
Implementing Sap R/3 : How to Introduce a Large System into a Large Organization, 2nd Edition
Enterprise Management with SAP SEM / Business Analytics
Why ERP? A Primer on SAP Implementation
Capturing the whirlwind : your field guide for a successful SAP implementation
Getting Maximum Value from SAP R/3

Dynamic, Accelerated SAP Implementation
Dynamic Implementation of SAP(R) R/3(R)
Asap Implementation at the Speed of Business: Implementation at the Speed of Business (Sap)
Implementing Sap With an Asap Methodology Focus
Preconfigured Client Made Easy 4.6C

SAP Business
SAP Blue Book, A Concise Business Guide to the World of SAP
Sap R/3 Business Blueprint: Understanding the Business Process Reference Model
What Every Business Needs to Know About SAP (Prima Tech's SAP Book Series)
SAP R/3 Business Blueprint - The Complete Video Course

Supporting SAP
SAP Service and Support
Supporting Sap R/3

SAP Quick Reference
Common Sap R/3 Functions Manual (Springer Professional Computing)
Instant Access: SAP, Reference Card of R/3

SAP Career
Five Steps to an Sap Career: Your Guide to Getting into Sap

SAP Consultant
SAP Consultant Handbook
Becoming an SAP Consultant
The Sap Consultant Handbook: Your Sourcebook to Lasting Success in an Sap Consulting Career

SAP Data Migration Tools
Migrating Your SAP Data
Data Transfer Made Easy 4.0B/4.5x
Testing SAP(R) R/3(R) Systems: Using the Computer Aided Test Tool

SAP Reporting Tools
SAP Query Reporting
SAP R/3 Reporting Made Easy, 4.6C:Fundamentals and Development Tools
Reporting Made Easy Guidebook series, Release 4.0B
SAP R/3 Reporting Made Easy: 4.6C SET
SAP R/3 Reporting & eBusiness Intelligence
Afp Printing for Sap Using R/3 and R/2

Internet Technology of SAP
The E-Business Workplace: Discovering the Power of Enterprise Portals
Roadmap to mySAP.com
mySAP.com Industry Solutions: New Strategies for Success with SAP's Industry Business Units
SAP R/3 Reporting & eBusiness Intelligence
The SAP R/3 on the Internet
Online Store Made Easy 4.6B ¿ Accelerated Internet Selling
E-Business and ERP: Transforming the Enterprise

SAP Workflow
SAP Workflow Interview Questions, Answers, and Explanations
Practical Workflow for SAP - Effective Business Processes using SAP's WebFlow Engine
Workflow Management With Sap Webflow: A Practical Manual
Optimising Business Performance With Standard Software Systems: How to Reorganise Workflows by Chance of Implementing New Erp-Systems (Sap, Baan, Peoplesoft, Navision ...) or New Releases

ABAP Certification
SAP ABAP Certification Review: SAP ABAP Interview Questions, Answers, and Explanations
ABAP Programming: A Guide to the Certification Course

SAP ABAP/4
Introduction to ABAP/4 Programming for SAP, Revised and Expanded Edition
Developing Sap's R/3 Applications With Abap/4
ABAP/4, Second Edition: Programming the SAP(R) R/3(R) System
The Official ABAP Reference

Advanced ABAP Programming
Advanced ABAP Programming for SAP
Enhancing the Quality of ABAP Development
SAP Interface Programming

ABAP Data Dictionary and Quick Reference
Software Development for Sap R/3: Data Dictionary, Abap/4, Interfaces
Sap Abap Command Reference
ABAP Language Quick-Reference

SAP ABAP Objects
ABAP Objects: Introduction to Programming SAP Applications with CDROM
ABAP Objects Reference Book

SAPscripts
SAPscript Made Easy 4.6

Smartforms
SAP Smart Forms

SAP BAPI
SAP R/3 Interfacing Using BAPIs; A Practical Guide to Working within the SAP Business Framework with CDROM

SAP JAVA
The ABAP Developer's Guide to Java (SAP Press)
Foundations of Java for ABAP Programmers (Foundations)
Enterprise Java for SAP
JAVA Programming With the SAP Web Application Server (Hardcover)

SAP Visual Basic
Professional Visual Basic SAP R/3 Programming
SAP R/3 Data Integration Techniques using ABAP/4 and Visual Basic

SAP Web Programming
Web Programming with the SAP Web Application Server

SAP NetWeaver
SAP NetWeaver For Dummies
SAP NetWeaver TM For Dummies [DOWNLOAD: ADOBE READER]
SAP NetWeaver Roadmap

SAP Financial Accounting
SAP R/3 Complete FI / CO Certification Curricumum - Video Training CDS (11 CDS)
SAP FICO Interview Questions, Answers, and Explanations: SAP FICO Certification Review
Configuring SAP R/3 FI/CO: The Essential Resource for Configuring the Financial and Controlling Modules
SAP(R) R/3(R) Financial Accounting: Making It Work For Your Business
Using Sap R/3 Fi: Beyond Business Process Reengineering
Accounting Information Systems with SAP CD-ROM, Third Edition


Disclaimer


By accessing this Blog you accept and agree to comply with all of the Terms. If you do not agree with these Terms, please do not use this Blog and exit immediately.
The material in this Blog has been compiled/adopted from a variety of sources. Hence the Blog may include technical inaccuracies or typographical errors. Everything on the Blog is provided to you “as is” without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose or non-infringement.
This Blog may contain links which lead to servers maintained by external individuals or organizations who are in no way attached to this Blog. Since we have no control over extraneous factors, no warranties or representations are made as to the accuracy, timeliness, suitability or any other aspect of the information located on such servers. This Blog does not monitor or endorse such servers or contents accessible in these servers or sites.
All articles in this Blog are published by its author(s) and can only be reproduced, given the author's permission. All rights reserved.
All Trademarks referred to are the property of their respective owners.

This Blog does not host any files on its server. Please report any broken links in comment.

The Blog http://allaboutsap.blogspot.com/ is no way affiliated with SAP AG.

For more info, contact us.

About

About

Contact

Please feel free to drop a line... Your feedback is important to improve this blog to best suit your needs.


Jan 4, 2008

Creating Search Helps - Elementary & Collective

First things first...

Elementary search helps define the standard flow of an input help. Components of this flow include:

  • the sources data displayed in the hit list (selection method)
  • information that should be displayed in the dialog box for value selection and in the hit list (search help parameters)
  • field contents that can be taken into account for hit list selections and which values in the hit list can be returned to the screen fields (search help parameters)
  • dialog steps that should be executed in the input help (dialog behavior)
Collective search helps can combine more than one elementary search helps. Thus enabling the user to choose one of several alternative search paths with a collective search help.

When you define a collective search help, you only have to specify the search helps that are to be combined in the collective search help. In the input help, the values are transported between the elementary search help selected by the user and the input template using the collective search help. This is why a collective search help also has an interface for transporting the values.

***********************************************

Creation of Search Helps: A Simple Elementary Search Help

Go to SE11 -> Select radio button "Search Help" -> enter a name


You will see a popup window (as shown below), select "Elementary Search Help" radio button and hit "Enter"



-> Enter "Short description", "Selection method**" (MARA in this case) and fields that should be displayed in the Search Help.

Selection method** You can enter the name of a table or a view (database view, projection view or help view) here. If you enter a table that has a text table, the name of the text table is automatically entered in the corresponding field.

Notice that the text table of MARA (MAKT) has automatically been included as we entered MARA in the Selection Method

-> "Save" -> "Check" -> "Activate" -> "Execute". You will see a popup window (as shown below) with all the fields you added. Press F4 on any of them to see how your first Elementary Search Help looks.

Below is how it looks. CONGRATS! Your first Elementary Search Help is ready and looks good


***********************************************
Creation of Search Helps: A Simple Collective Search Help

Go to SE11 -> Select radio button "Search Help" -> enter a name


Select "Elementary Search Help" radio button (on the popup) and hit "Enter"

-> Enter "Short description" and fields that should be displayed in the Search Help in the Definition Tab.


-> Now go to the "Included Search Helps" tab and enter the names of the Elementary Search Helps you wish to include into your Collective Search Help (ZKAR_SHLP in this case).

-> Now select the line which contains your Elementary Search Help and click on "Param. Assignment**"

Position the cursor one after the other on each allocated search help and choose Parameter assignment.


In the next screen, enter the parameter names of the elementary search helps to which the corresponding parameters of the collective search help should be assigned in the field Reference parameter. You can select the parameters contained in the included search help using the input help. Create a proposal for the assignment with Proposal.




-> "Save" -> "Check" -> "Activate" -> "Execute". You will see a popup window (as shown below) with all the fields you added. Press F4 on any of them to see how your first Collective Search Help looks.

Below is how it looks. CONGRATS! Your first Collective Search Help is ready and looks good
***********************************************
Once done, you can attach the search help to:
  • A data element
  • A check table
  • A table field
  • A screen field

Updating database without writing code

Below are two ways to edit database records without having to write a single line of code. The examples use the table MARA for editing

Procedure 1: This is suitable for updating & one record in a table at once. Multiple records can also be updated by repeating the procedure for each record.

Go to transaction SE12 -> Enter Table name and hit “Display”



-> Show Contents (Ctrl + Shift + F10)


-> Enter a key field (MATNR in this case) of the record which you wish to edit and hit F8


Select the record and click on “Choose” or simply double click on the record


Once chosen, type /H in the command field to debug and hit "Enter"


Select the user command field and change it from “SHOW” to “EDIT”



Lo! You can edit the contents of that record now and hit “SAVE” to update the database record

****************************************************

Procedure 2: This is suitable for updating & deleting multiple records in a table at once.

Go to transaction SE16N -> Enter table name MARA




Enter &SAP_EDIT in the command field and click on execute or hit F8

In this way, you can edit multiple entries of a database table.

ENJOY SAP!

Sep 27, 2007

Convert Smartforms to PDF and save as local file

*&---------------------------------------------------------------------*
*& Report ZKAR_SF_PDF
*&---------------------------------------------------------------------*
*& + This program demonstrates how easy it is to convert Smartforms to
*& and save as local file
*& + This example also demostrates how to skip the PRINT PREVIEW screen
*& where we give the default printer name. The name is set in the program.
*&

*& NOTE: The smartform called here is an example with no relation to the
*& standard forms. You will have to do the Smartform data population
*& befoer you use the code for PDF Conversion. Data can be sent to the
*& smartform through the Function Module G_FM_NAME's EXPORTING or
*& TABLES section
*&---------------------------------------------------------------------*
*& Written by: Karthik Potharaju
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT ZKAR_SF_PDF.

*--- Internal tables, Structures and Variables used for PDF conversion
DATA: IT_OTF TYPE STANDARD TABLE OF ITCOO,
IT_DOCS TYPE STANDARD TABLE OF DOCS,
IT_LINES TYPE STANDARD TABLE OF TLINE,
ST_JOB_OUTPUT_INFO TYPE SSFCRESCL,
ST_DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
ST_JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
ST_OUTPUT_OPTIONS TYPE SSFCOMPOP,
ST_CONTROL_PARAMETERS TYPE SSFCTRLOP,
V_LEN_IN TYPE SO_OBJ_LEN,
V_LANGUAGE TYPE SFLANGU VALUE 'E',
V_E_DEVTYPE TYPE RSPOPTYPE,
V_BIN_FILESIZE TYPE I,
V_NAME TYPE STRING,
V_PATH TYPE STRING,
V_FULLPATH TYPE STRING,
V_FILTER TYPE STRING,
V_UACT TYPE I,
V_GUIOBJ TYPE REF TO CL_GUI_FRONTEND_SERVICES,
V_FILENAME TYPE STRING.


*--- Perform to download the smartform as PDF
*--- This can be placed after the Form data population routines

PERFORM DL_SMARTFORM.


*&---------------------------------------------------------------------*
*& Form DL_SMARTFORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*

FORM DL_SMARTFORM .
*--- Data Declarations
data: C_FORMNAME TYPE TDSFNAME.
DATA: G_FM_NAME TYPE RS38L_FNAM.
c_formname = 'ZKAR_SF2PDF_EXMPL'.


*--- To get output device type
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
I_LANGUAGE = V_LANGUAGE
I_APPLICATION = 'SAPDEFAULT'
IMPORTING
E_DEVTYPE = V_E_DEVTYPE.
ST_OUTPUT_OPTIONS-TDPRINTER = V_E_DEVTYPE.
ST_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
ST_CONTROL_PARAMETERS-GETOTF = 'X'.


*--- Call Function to get the Function Module name for the smart form
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = C_FORMNAME
IMPORTING
FM_NAME = G_FM_NAME.
IF SY-SUBRC <> 0.
*--- Check for Errors
ENDIF.

*--- Call Smartform function module without hard coding
CALL FUNCTION G_FM_NAME
EXPORTING
CONTROL_PARAMETERS = ST_CONTROL_PARAMETERS
OUTPUT_OPTIONS = ST_OUTPUT_OPTIONS
* USER_SETTINGS = 'X'
* ADD YOUR DATA STRUCTURES HERE

IMPORTING
DOCUMENT_OUTPUT_INFO = ST_DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = ST_JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = ST_JOB_OUTPUT_OPTIONS
* TABLES
* ADD YOUR DATA TABLES

EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
*--- On Failure display standard Message
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.


*--- Convert OTF to PDF
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
BIN_FILESIZE = V_BIN_FILESIZE
TABLES
OTF = ST_JOB_OUTPUT_INFO-OTFDATA
DOCTAB_ARCHIVE = IT_DOCS
LINES = IT_LINES
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


*--- Get filename to store
CONCATENATE 'Converted_Smartform' '.pdf' INTO V_NAME.
CREATE OBJECT V_GUIOBJ.
CALL METHOD V_GUIOBJ->FILE_SAVE_DIALOG
EXPORTING
DEFAULT_EXTENSION = 'pdf'
DEFAULT_FILE_NAME = V_NAME
FILE_FILTER = V_FILTER
CHANGING
FILENAME = V_NAME
PATH = V_PATH
FULLPATH = V_FULLPATH
USER_ACTION = V_UACT.
IF V_UACT = V_GUIOBJ->ACTION_CANCEL.
EXIT.
ENDIF.


*--- Download PDF to local PC
MOVE V_FULLPATH TO V_FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = V_BIN_FILESIZE
FILENAME = V_FILENAME
FILETYPE = 'BIN'
TABLES
DATA_TAB = IT_LINES
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.
ENDIF.

ENDFORM. " DL_SMARTFORM

Sep 17, 2007

SAP Query Step-By-Step

T-code: SQVI
For Creating New SAP Query choose “CREATE”
Give a name and click Create
Here we are creating SAP Query under the name “SAPQUERY” & ensure the description & the Data Source is been defined. In Data Source you have four options

1. Logical Database
2. SAP Query Info set
3. Table
4. Table Join

You can also choose “BASIS MODE” or “LAYOUT MODE”

Note: You can find the difference between “BASIS MODE” or “LAYOUT MODE” from the following screen shots.

Here I am Selecting Basis mode and select table join if more than two tablesAfter defining the selection criterions then you get the below screen for inserting the Tables from were you to have extract the Query.

Now Click on Insert table button on top, and choose the table you require. In this example we are inserting two Tables VBRK and VBRP.Choose Insert table Again and choose VBRP



Note: Ensure that when you join more than one tables the Primary keys should have linkage as in the below case the field name “VBELN” is the primary key were it is linked in both the tables.
Now Click on Check button for join conditions
Once you get the message “Defined Join conditions are correct”. In the bottom
of the screen then you can go back by clicking the back button.
When you drill down you will find the list of fields used for the particular table in that we can select whether the particular field is only the listed field or the selection field or both.
Listed field is the Output field & the selection field is the Input field which has to be keyed in when generating the Query.

Below screen shot is shown for Table VBRK in that few fields are been selected for Listing as well as selectionAfter selecting the Listed & selected fields either by Basis or Layout mode check out for any errors click the check button.
After clicking you ensure that you get a message “NO errors were found during consistency checks” is seen at the bottom of the screen after seeing this message the Query can be saved by clicking the SAVE button


Adjust the number of records
Below screen appears in SAP List viewer
The output

Sep 14, 2007

Upgrade - Transaction SPDD, SPAU

Support Packs are the upgrades we get for one release of SAP. For example, for component 4.7 you have support pack levels too (you can see this in Transaction SPAM)। SAP releases support packs for standard corrections which you can also implement separately through OSS notes (if you do not want the import the support pack). OSS notes might not carry all the changes that the SP might bring.

These are the two activities that an ABAPer does during upgrade:

1. SPDD: This is for data dictionary corrections. If any standard tables have been modified, then that object appears in the list and you have to adjust it again after comparing the versions.

2. SPAU: This is for repository objects (programs, functions, classes, etc.). These have to be compared to the previous versions too and any missing bespoke code is to re-inserted. However, there are a few cases where it need not.

Steps :

  • All Z programs and customization are adjusted in repository.
  • Using these transaction the sap prepare phase undertakes all these.
  • Then u might have to take the Combined and Unicode C process which is like combined upgrade and uniconverison as well.
  • First step is to change all ABAP programs to Unicode enabled.
  • You have to run a upgrade tool called SPUM4.
  • Then u have to do data maintainence consistency check etc.
  • Actually all this is done automatically when you run SAPUP and sapprepare.
  • Run SPDD and SPAU transaction for data dictionary correction and repository.

Sep 6, 2007

Dynamic Selection Screen Fields (properties)

*&---------------------------------------------------------------------*
*& Report ZKAR_DYN_SELSCR.
*&---------------------------------------------------------------------*
*& This program demonstrates how easy it is to set selection screen
*& element properties dynamically
*&
*& The program uses 3 radio buttons to set the display and input
*& properties of selection screen fields dynamically
*&---------------------------------------------------------------------*
*& Written by: Karthik Potharaju
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT ZKAR_DYN_SELSCR.
*----------------------------------------------------------------------*
* DATABASE TABLES
*----------------------------------------------------------------------*

tables : mara.
*----------------------------------------------------------------------*
* SELECTION SCREEN
*----------------------------------------------------------------------*

selection-screen begin of block b1 with frame.
*--- Radio buttons to set properties
PARAMETERS:
rad1 RADIOBUTTON GROUP rad default 'X' USER-COMMAND radio,
rad2 RADIOBUTTON GROUP rad,
rad3 RADIOBUTTON GROUP rad.
*--- Selection Screen fields
SELECT-OPTIONS:
s_matnr FOR mara-matnr MODIF ID MI1,
s_mtart FOR mara-mtart MODIF ID MI1,
s_mbrsh FOR mara-mbrsh MODIF ID MI2,
s_matkl FOR mara-matkl MODIF ID MI2.
selection-screen end of block b1.


*----------------------------------------------------------------------*
* AT SELECTION SCREEN
*----------------------------------------------------------------------*

at selection-screen output.
loop at screen.
*--- If Radio Button 1 is checked
IF rad1 = 'X'.
IF screen-group1 = 'MI2'.
*--- Fields with MODIF ID MI2 disappear from the screen
screen-input = 0.
screen-invisible = 1.
ENDIF.
*--- If Radio Button 2 is checked
ELSEIF rad2 = 'X'.
IF screen-group1 = 'MI1'.
*--- Fields with MODIF ID MI1 are input-disabled
screen-input = 0.
ENDIF.
*--- If Radio Button 3 is checked
ELSEIF rad3 = 'X'.
IF screen-group1 = 'MI1' or screen-group1 = 'MI2'.
*--- All fields will appear input-enabled
screen-input = 1.
ENDIF.
ENDIF.
*--- MODIFY SCREEN mandatory addition to apply changes to the screen
Modify screen.
endloop.

Web browser on SAP GUI

*&---------------------------------------------------------------------*
*& Report ZKAR_BROWSERDEMO
*&---------------------------------------------------------------------*
*& This program demonstrates how to add a custom controller to a screen
*& that acts like a nomal web browser. In order to run the program,
*& The following elements are required:
*& + Create SCREEN 100
*& + Create an I/O fieeld with name "EDURL"
*& + Create a custom control with name HTML
*& + Finally an OKCODE variable called FCODE
*&---------------------------------------------------------------------*
*& This code is originally adopted from standard program SAPHTML_DEMO1
*&---------------------------------------------------------------------*
*& Documented by: Karthik Potharaju
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT ZKAR_BROWSERDEMO.
*----------------------------------------------------------------------*
* DATA DECLARATIONS *
*----------------------------------------------------------------------*

DATA: html_control TYPE REF TO cl_gui_html_viewer,
my_container TYPE REF TO cl_gui_custom_container,
fcode LIKE sy-ucomm,
myevent_tab TYPE cntl_simple_events,
myevent TYPE cntl_simple_event,
edurl(2048),
alignment TYPE i.
*****************************************************
* CLASS cl_myevent_handler *
*****************************************************

CLASS cl_myevent_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_navigate_complete
FOR EVENT navigate_complete OF cl_gui_html_viewer
IMPORTING url.
ENDCLASS. "cl_myevent_handler DEFINITION
DATA: evt_receiver TYPE REF TO cl_myevent_handler.
SET SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*

MODULE status_0100 OUTPUT.
SET PF-STATUS 'TESTHTM1'.
SET TITLEBAR '001'.
IF my_container IS INITIAL.
CREATE OBJECT my_container
EXPORTING
container_name = 'HTML'
EXCEPTIONS
others = 1.
CASE sy-subrc.
WHEN 0.
*
WHEN OTHERS.
RAISE cntl_error.
ENDCASE.
ENDIF.
IF html_control IS INITIAL.
CREATE OBJECT html_control
EXPORTING
parent = my_container.
IF sy-subrc NE 0.
RAISE cntl_error.
ENDIF.


* register event
*************************************************************
* DON'T USE the NAVIGATE_COMPLETE event in application logic
*************************************************************

myevent-eventid = html_control->m_id_navigate_complete.
myevent-appl_event = 'X'.
APPEND myevent TO myevent_tab.
CALL METHOD html_control->set_registered_events
EXPORTING
events = myevent_tab.
CREATE OBJECT evt_receiver.
SET HANDLER evt_receiver->on_navigate_complete
FOR html_control.


*--- To load default home page
PERFORM load_home_page.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*

MODULE user_command_0100 INPUT.
CASE fcode.


WHEN 'BACK'.
IF NOT html_control IS INITIAL.
CALL METHOD html_control->free.
FREE html_control.
ENDIF.
IF NOT my_container IS INITIAL.
CALL METHOD my_container->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* MESSAGE E002 WITH F_RETURN.
ENDIF.
FREE my_container.
ENDIF.
LEAVE PROGRAM.


*--- When HOME
WHEN 'HHOM'. " show the home page
CALL METHOD html_control->go_home.
CALL METHOD html_control->get_current_url
IMPORTING
url = edurl.


*--- When BACK
WHEN 'HBAK'.
CALL METHOD html_control->go_back.
CALL METHOD html_control->get_current_url
IMPORTING
url = edurl.


*--- When FORWARD
WHEN 'HFWD'.
CALL METHOD html_control->go_forward.
CALL METHOD html_control->get_current_url
IMPORTING
url = edurl.


*--- When REFRESH
WHEN 'HRFR'.
CALL METHOD html_control->do_refresh.
CALL METHOD html_control->get_current_url
IMPORTING
url = edurl.

WHEN 'HNAV'.
IF NOT edurl IS INITIAL.
CALL METHOD html_control->show_url
EXPORTING
url = edurl
EXCEPTIONS
cnht_error_parameter = 1
OTHERS = 2.
IF sy-subrc GE 2.
RAISE cntl_error.
ENDIF.
ENDIF.

WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR fcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form load_home_page
*&---------------------------------------------------------------------*
* To load default home page
*----------------------------------------------------------------------*

FORM load_home_page.

DATA: doc_url(80).

CALL METHOD html_control->load_html_document
EXPORTING
document_id = 'HTMLCNTL_CNHTTST1_START'
IMPORTING
assigned_url = doc_url
EXCEPTIONS
OTHERS = 1.

IF sy-subrc EQ 0.
CALL METHOD html_control->show_url
EXPORTING
url = doc_url.
ENDIF.

ENDFORM. " LOAD_HOME_PAGE
****************************************************
* cl_myevent_handler implementation *
****************************************************
CLASS cl_myevent_handler IMPLEMENTATION.
*************************************************************
* DON'T USE the NAVIGATE_COMPLETE event in application logic
*************************************************************

METHOD on_navigate_complete.
edurl = url.
ENDMETHOD. "on_navigate_complete
ENDCLASS. "cl_myevent_handler IMPLEMENTATION

Program to create Material Master data using BAPIs

*&---------------------------------------------------------------------*
*& Report ZKAR_MATMAS_BAPI
*&---------------------------------------------------------------------*
*& This program demonstrates how easy it is to create Material master
*& data using BAPI_MATERIAL_SAVEDATA
*&
*& The program also generates a report post-execution displaying errors
*& as well as successful uploads
*&---------------------------------------------------------------------*
*& Written by: Karthik Potharaju
*& URL: http://allaboutsap.blogspot.com
*&---------------------------------------------------------------------*

REPORT ZKAR_MATMAS_BAPI.

*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
* FLAGS *
*----------------------------------------------------------------------*
DATA: F_STOP. " Flag used to stop processing

*----------------------------------------------------------------------*
* DATA DECLARATIONS *
*----------------------------------------------------------------------*
DATA : V_EMPTY TYPE I, " No. of empty records
V_TOTAL TYPE I. " Total no. of records.

*----------------------------------------------------------------------*
* STRUCTURES & INTERNAL TABLES
*----------------------------------------------------------------------*

*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_RETURN LIKE BAPIRET2. " Return Parameter

*--- Internal table to hold excel file data
DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

*--- Internal table to hold Matetrial descriptions
DATA: BEGIN OF IT_MAKT OCCURS 100.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.

*--- Internal to hold the records in the text file
DATA : BEGIN OF IT_DATA OCCURS 100,
WERKS(4), " Plant
MTART(4), " Material type
MATNR(18), " Material number
MATKL(9) , " Material group
MBRSH(1), " Industry sector
MEINS(3), " Base unit of measure
GEWEI(3), " Weight Unit
SPART(2), " Division
EKGRP(3), " Purchasing group
VPRSV(1), " Price control indicator
STPRS(12), " Standard price
PEINH(3), " Price unit
SPRAS(2), " Language key
MAKTX(40), " Material description
END OF IT_DATA.

*----------------------------------------------------------------------*
* SELECTION SCREEN. *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
'C:\Material_master.XLS'.
PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK SCR1.

*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*--- Validating file
PERFORM VALIDATE_FILE USING P_FILE.

*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.

*--- Perform to convert the Excel data into an internal table
PERFORM CONVERT_XLS_ITAB.

IF NOT IT_DATA[] IS INITIAL.
*--- Perform to delete Header lines
PERFORM DELETE_HEADER_EMPTY_RECS.
ENDIF.

*----------------------------------------------------------------------*
* END OF SELECTION. *
*----------------------------------------------------------------------*
END-OF-SELECTION.

*--- Perform to upload Material Master data
PERFORM UPLOAD_MATMAS.

*----------------------------------------------------------------------*
* Form : validate_input_file
*----------------------------------------------------------------------*
* Description : To provide F4 help for file if read from PC
*----------------------------------------------------------------------*
FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
FILE_NAME = F_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.

IF SY-SUBRC <> 0.
MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
ENDIF.

ENDFORM. " validate_input_file

*&---------------------------------------------------------------------*
*& Form CONVER_XLS_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM CONVERT_XLS_ITAB.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = P_BEGCOL
I_BEGIN_ROW = P_BEGROW
I_END_COL = P_ENDCOL
I_END_ROW = P_ENDROW
TABLES
INTERN = IT_INTERN.

IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*--- Perform to move the data into an internal data
PERFORM MOVE_DATA.

ENDFORM. " CONVERT_XLS_ITAB

*&---------------------------------------------------------------------*
*& Form MOVE_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM MOVE_DATA.

DATA : LV_INDEX TYPE I.
FIELD-SYMBOLS <FS>.
*--- Sorting the internal table
SORT IT_INTERN BY ROW COL.
CLEAR IT_INTERN.

LOOP AT IT_INTERN.
MOVE IT_INTERN-COL TO LV_INDEX.
*--- Assigning the each record to an internal table row
ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS>.
*--- Asigning the field value to a field symbol
MOVE IT_INTERN-VALUE TO <FS>.
AT END OF ROW.
APPEND IT_DATA.
CLEAR IT_DATA.
ENDAT.
ENDLOOP.

ENDFORM. " MOVE_DATA

*&---------------------------------------------------------------------*
*& Form DELETE_HEADER_EMPTY_RECS
*&---------------------------------------------------------------------*
* To delete the Header and empty records
*----------------------------------------------------------------------*
FORM DELETE_HEADER_EMPTY_RECS.

DATA: LV_TABIX LIKE SY-TABIX.

IF NOT P_HEADER IS INITIAL.
LOOP AT IT_DATA.
IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
DELETE IT_DATA FROM 1 TO P_HEADER.
* P_HEADER = 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.

CLEAR IT_DATA.
*--- To delete the empty lines from internal table
LOOP AT IT_DATA.
LV_TABIX = SY-TABIX.
IF IT_DATA IS INITIAL.
V_EMPTY = V_EMPTY + 1.
DELETE IT_DATA INDEX LV_TABIX..
ENDIF.
ENDLOOP.

CLEAR IT_DATA.
*--- Total no of recs in file
DESCRIBE TABLE IT_DATA LINES V_TOTAL.
IF V_TOTAL = 0.
MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
F_STOP = 'X'.
STOP.
ENDIF.

ENDFORM. " DELETE_HEADER_EMPTY_RECS

*&---------------------------------------------------------------------*
*& Form UPLOAD_MATMAS
*&---------------------------------------------------------------------*
* to upload Material Master data
*----------------------------------------------------------------------*
FORM UPLOAD_MATMAS .

LOOP AT IT_DATA.

* Header
BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
IT_MAKT-LANGU = IT_DATA-SPRAS.
IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
APPEND IT_MAKT.
* Client Data - Basic
BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
BAPI_MARA1-DIVISION = IT_DATA-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 = IT_DATA-WERKS.
BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.

BAPI_MARCX-PLANT = IT_DATA-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.

BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
BAPI_MBEWX-PRICE_UNIT = 'X'.

*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
PLANTDATA = BAPI_MARC1
PLANTDATAX = BAPI_MARCX
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
* VALUATIONDATA = BAPI_MBEW1
* VALUATIONDATAX = BAPI_MBEWX
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA = BAPI_MVKE1
* SALESDATAX = BAPI_MVKEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
* UNITSOFMEASURE =
* UNITSOFMEASUREX =
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
.

IF BAPI_RETURN-TYPE = 'E'.

WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,it_data-matnr.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created material' ,it_data-matnr.
ENDIF.

ENDLOOP.

ENDFORM. " UPLOAD_MATMAS

Program to find User Exits for a given tcode

*&---------------------------------------------------------------------*
*& Report ZKAR_FINDEXITS
*&---------------------------------------------------------------------*
*& This program helps find Exits for any given transaction
*& This code is originally adopted from http://www.sap-img.com
*&---------------------------------------------------------------------*
REPORT ZKAR_FINDEXITS no standard page heading.
*----------------------------------------------------------------------*
*TABLES
*----------------------------------------------------------------------*

tables :
tstc, " SAP Transaction Codes
tadir, " Directory of Repository Objects
modsapt, " SAP Enhancements - Short Texts
modact, " Modifications
trdir, " System Table TRDIR
tfdir, " Function Module
enlfdir, " Additional Attributes for Function Modules
tstct. " Transaction Code Texts
*----------------------------------------------------------------------*
*INTERNAL TABLES AND STRUCTURES
*----------------------------------------------------------------------*

*** Internal table to hold Repository Objects
data :
it_tadir like tadir occurs 0 with header line.
*----------------------------------------------------------------------*
*Global variables
*----------------------------------------------------------------------*

data :
field1(30),
v_devclass like tadir-devclass. " variable to hold dev. class
*----------------------------------------------------------------------*
*SELECTION-SCREEN
*----------------------------------------------------------------------*

parameters :
p_tcode like tstc-tcode obligatory.
*----------------------------------------------------------------------*
*START-OF-SELECTION
*----------------------------------------------------------------------*

START-OF-SELECTION.
* SELECT construct to get data for a given tcode
select single * from tstc
where tcode eq p_tcode.
if sy-subrc = 0.
* SELECT construct to get program names
select single * from tadir
where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
* Moving the dev. class to v_devclass if program is of type 1
move : tadir-devclass to v_devclass.
if sy-subrc <> 0.
select single * from trdir

where name = tstc-pgmna.
* If Program type = Function Group
if trdir-subc eq 'F'.
select single * from tfdir

where pname = tstc-pgmna.
* SELECT construct to get Attributes for Function Modules
select single * from enlfdir
where funcname = tfdir-funcname.
* SELECT construct to get FM names
select single * from tadir
where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name = enlfdir-area.
* Moving the dev. class to v_devclass if program is of type F
move : tadir-devclass to v_devclass.
endif.
endif.
* SELECT construct to get SAP enhancements for the dev. class
select * from tadir into table IT_tadir
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
* SELECT construct to get t code texts
select single * from tstct
where sprsl = sy-langu
and tcode = p_tcode.
* REPORT OUTPUT
format color 2.
* Displaying t-code name & text
write:/(19) 'T Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
* List headings
if not IT_tadir[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.

loop at IT_tadir.
* SELECT construct to get SAP Enhancements - Short Texts
select single * from modsapt
where sprsl = sy-langu

and name = IT_tadir-obj_name.
format color col_normal intensified off.
* Exit names & texts
write:/1 sy-vline,
2 IT_tadir-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table IT_tadir.
skip.
format color 1 intensified on.
* No of Exits
write:/ 'No of Exits:' , sy-tfill.
else.
format color 3 intensified on.
* If no exits found
write:/(95) 'No User Exit exists'.
endif.
else.
format color 3 intensified on.
* If tcode doesn't exist
write:/(95) 'Transaction Code Does Not Exist'.
endif.
* Call txn SMOD with selected Exit
at line-selection.
get cursor field field1.
check field1(4) = 'IT_tadir'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.

Subscribe to posts via email

Enter your email address:

Delivered by FeedBurner

Blog Owner

Karthik P
Certified SAP Netweaver Consultant

View Karthik Potharaju's profile on LinkedIn