ERP Database - The Unofficial ERP Knowledge Base

Facebook Twitter del.icio.us Digg it
ERP Database contains a huge collection of articles related to ERP System and Software. Many of the articles are specifically related to SAP. All these ERP/SAP articles are freely available to everyone.

If you would like to submit an article or share any document related to ERP or any specific ERP software. Please mail it to support@erpdb.info. Please make sure that the documents are not copyrighted.
Social Bookmarks:

Archive for the ‘ABAP Programs’ Category

FIND: ABAP Keyword a Day

Print This Post Email This Post Written by admin on May 24th, 2011 | Filed under: ABAP, ABAP Keywords, ABAP Programs

FIND:  Searches for patterns.

FIND <p> IN [SECTION OFFSET <off> LENGTH <len> OF] <text> 
[IGNORING CASE| RESPECTING CASE] 
[IN BYTE MODE|IN CHARACTER MODE] 
[MATCH OFFSET <0>] 
[MATCH LENGTH <l>].

The system searches the field <text> for the pattern <p>.

  • The SECTION OFFSET <off> LENGTH <len> OF addition tells the system to search only from the <off> position in the length <len>.
  • IGNORING CASE or RESPECTING CASE (default) specifies whether the search is to be case-sensitive.
  • In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions.
  • The MATCH OFFSET and MATCH LENGTH additions set the offset of the first occurrence and length of the search string in the fields <p> and <l>.

Use FIND IN TABLE for searching in the internal table.

DATA: c_erpdb TYPE string value 'ERP',
      result_tab TYPE match_result_tab.
 
FIELD-SYMBOLS <match> LIKE LINE OF result_tab.
 
FIND ALL OCCURRENCES OF c_erpdb IN
     `ERPDB.INFO - Unofficial ERP Knowledge Base`
     RESULTS result_tab.
 
LOOP AT result_tab ASSIGNING <match>.
  WRITE: / <match>-offset, <match>-length.
ENDLOOP.
Share

Working with BADI’s in SAP ABAP

Print This Post Email This Post Written by admin on Mar 12th, 2011 | Filed under: ABAP, ABAP Programs

Business addins are the enhancements to standard SAP’s version. They can be inserted to accommodate the business requirements.  Here are the steps in working with a custom BADI inside SAP.

Defining BADI

1. Go to SE18 and create the BADI definition. Provide appropriate description and the interface will be automatically created.
2. Double click on the interface and create the required methods inside the methods tab and add required parameters.
3.  Activate the BADI Definition.

Implementing BADI

1. Go to SE18, type in the BADI which has already been defined either the one previously created or the one which exists in the system.
2. Click on Menu: Implementation -> Create and provide a implementation name.
3. Double click on the method name and write the required code.

Here is what is usually happening where ever the BADI is called inside the ABAP program.

CL_EXITHANDLE=>GET_INSTANCE
( Exporting exit_name = '<NAME OF BADI>'
               null_instance_accepted = 'X'
  Changing instance   = oref_badi_instance )
"Call to Methods defined in the badi definition
oref_badi_instance->'<any method name>'.
Share

ABAP: How to create a dynamic internal table and work area

Print This Post Email This Post Written by admin on Nov 5th, 2009 | Filed under: ABAP Programs
FIELD-SYMBOLS:<fs_table> TYPE STANDARD TABLE,  <fs_table_wa> TYPE ANY.
DATA:  table_ref TYPE REF TO data, wa_ref TYPE REF TO data.
DATA: l_structure TYPE dd02l-tabname value 'VBAP'.
 
CREATE DATA table_ref TYPE STANDARD TABLE OF (l_structure).
ASSIGN table_ref->* TO <fs_table>.
CREATE DATA wa_ref LIKE LINE OF <fs_table>.
ASSIGN wa_ref->* TO <fs_table_wa>.

Now you have the table <fs_table> and the work area for it <fs_table_wa>.

Share

Generate Temporary ABAP Program

Print This Post Email This Post Written by admin on Sep 10th, 2009 | Filed under: ABAP Programs

Ever had a need to create a temporary program during the run time. Here is a simple program which will allow you to learn that.

REPORT ZSOURCE2501.
* Internal table for source code, field for name of temporary program
DATA: SOURCE_TABLE(72) OCCURS 10 WITH HEADER LINE,
      PROGRAM_NAME LIKE SY-CPROG.
* Building the source code
APPEND 'report test.'                        TO SOURCE_TABLE.
APPEND 'form display.'                       TO SOURCE_TABLE.
APPEND 'write ''I am a temporary program''.' TO SOURCE_TABLE.
APPEND 'endform.'                            TO SOURCE_TABLE.
* Generating the temporary program
GENERATE SUBROUTINE POOL SOURCE_TABLE NAME PROGRAM_NAME.

Continue Reading …

Share

ABAP Program to Send Mail with Attachment

Print This Post Email This Post Written by admin on Aug 27th, 2009 | Filed under: ABAP Programs

This ABAP program use the function module ‘SO_NEW_DOCUMENT_ATT_SEND_API1′ to send the email with attachment. There are five steps involved in sending the email with attachment.

  1. Add Recipients
  2. Put in the mail contents
  3. Create the attachment
  4. Pack the mail contents and attachment
  5. Finally, send the mail out.

Before we start writing the code, ensure that everything is configured correctly in the SCOT. Get in touch with the basis team and they will help you configure it.
Continue Reading …

Share