SAP Database - The Unofficial SAP Knowledge Base

Free Business and Tech Magazines and eBooks

Archive for the ‘ABAP Programs’ Category

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>.


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 …


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 …


Create Toolbar in Selection Screen

Print This Post Email This Post Written by rajivsharma.sap on Jul 9th, 2009 | Filed under: ABAP Programs

How to create a toolbar in the selection screen, similar to the one below. Refer the sample code

toolbar-sapdb.info

TABLES: sscrfields.
SELECTION-SCREEN FUNCTION KEY 1.
 
INITIALIZATION.
sscrfields-functxt_01 = 'Tool bar www.sapdb.info'.
 
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
PARAMETERS: vbeln LIKE vbak-vbeln.
SELECTION-SCREEN END OF BLOCK b1.
 
AT SELECTION-SCREEN.
  IF sy-ucomm EQ 'FC01'.
    PERFORM toolbar_test.
  ENDIF.

Like my posts, leave a comment it will motivate me to post more.


How to Display OO ALV in Popup

Print This Post Email This Post Written by rajivsharma.sap on Jul 9th, 2009 | Filed under: ABAP Programs

Guest post by Rajiv

Use the factory method to display the ALV in Popup.

DATA: gr_table           TYPE REF TO cl_salv_table,
*<< Your Custom table, Populate data in it
     gr_master         TYPE STANDARD TABLE OF ymaster,    
     lr_functions       TYPE REF TO cl_salv_functions_list,
     lr_columns         TYPE REF TO cl_salv_columns.
  TRY.
      cl_salv_table=>factory(
        IMPORTING
          r_salv_table = gr_table
        CHANGING
          t_table       = gr_master ).
    CATCH cx_salv_msg.
  ENDTRY.
 
  lr_functions = gr_table->get_functions( ).
  lr_functions->set_all( 'X' ).
 
  lr_columns = gr_table->get_columns( ).
  lr_columns->set_optimize( 'X' ).
 
 gr_table->set_screen_popup(
  start_column = 1
  end_column   = 100
  start_line   = 1
  end_line     = 20 ).
 
  gr_table->display( ).

  • Subscribe to RSS

  • Free Ebooks