ABAP Codes

Upload and Download ABAP Source Code

Sample program source code for Uploading /Downloading  ABAP reports complete with texts Source Code Listing *———————————————————————-* * Report: ZKBPROGS * *———————————————————————-* * Function : Up/Download ABAP reports complete with texts * *———————————————————————-* * Change Log : * * July 5, 1999 * * – Combined existing programs that did the upload and download into* * […]

ABAP program to send a report to an external mail-id

This source code is an ABAP Program o send a report to an external mail-id REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200. DATA : BEGIN OF ITAB OCCURS 0, PERNR LIKE PA0001-PERNR, ENAME LIKE PA0001-ENAME, END OF ITAB. DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE, receiver_list LIKE soos1 OCCURS 5 WITH HEADER […]

ABAP Program to DIALOGUE FLOW LOGIC

This source code is an ABAP Program to DIALOGUE FLOW LOGIC PROCESS BEFORE OUTPUT.MODULE STATUS_0100.*PROCESS AFTER INPUT.MODULE EXIT_COMMAND AT EXIT-COMMAND.* Data is not in the screen fields until after the field statemeCHAIN.FIELD:S_TANUM,S_TAPOS MODULE VAL_TANUM.ENDCHAIN.* chain ensures all fields are open after an error CHAIN.FIELD: S_ZZTRACKING,S_EXIDV,S_TANUM,S_TAPOS MODULE VAL_ZZTRACKING.ENDCHAIN.* process data enteredMODULE USER_COMMAND_0100

ABAP Program for Execute Unix command from within SAP

This source code is an ABAP Program for Execute Unix command from within SAP REPORT YSMT018AMESSAGE-ID YL.* ABAP to append ribesnsl to ribes* and remove input file using sxpg_command_execute DATA: FILE1(25) VALUE ‘/vmedata/???/file1nsl’.DATA: FILE2(25) VALUE ‘/vmedata/???/file2’.DATA: W_MESSAGE(50).DATA: RLBES LIKE RLBES.FILE1+9(3) = SY-SYSID.FILE2+9(3) = SY-SYSID.* sxpg_command_execute parametersDATA: REMOVE_FILE LIKE SXPGCOLIST-PARAMETERS.DATA: PROTOCOL LIKE BTCXPM OCCURS 0.*OPEN DATASET […]

ABAP Program to Get Output in EXCEL

This source code is an ABAP Program to Get Output in EXCEL REPORT YLMM015A MESSAGE-ID YL. *———————————————————————– * * EDI FORECASTING INTERFACE – SHEILA TITCHENER JAN 1998 * L_IDOC_HEADER_CREATE, L_IDOC_SEGMENT_CREATE & L_IDOC_SEND * left idoc ready to send but did not send automatically. * these were replaced by ALE_MODEL_DETERMINE_IF_TO_SEND * ALE_MODEL_INFO_GET & MASTER_IDOC_DISTRIBUTE * ‘in […]

ABAP Program for Output Table Fields to a List

When you’re looking at the structure of a table, SAP will let you print the structure, but it won’t let you save the structure. This can be annoying. This report outputs the table structure to a list. At this point the user can use the System->List->Save->Local file command to save the list to a file. […]

Source Code of ABAP Program to Browse a file on the application server

Source Code of ABAP Program to Browse a file on the application server REPORT ZBROWSE MESSAGE-ID Z1NO STANDARD PAGE HEADING* LINE-COUNT 65LINE-SIZE 255. *———————————————————————** Topic: Browse a file on the appication server* ** Author: Sheila Titchener* **———————————————————————*DATA: BEGIN OF TAB1 OCCURS 0,LINE(5000),END OF TAB1. DATA: BEGIN OF TAB2 OCCURS 0,LINE(5000),END OF TAB2.DATA: PARCOM_LOC(100) TYPE C.DATA: […]

ABAP Program to Upload table using new function GUI_UPLOAD

Sample ABAP Program to learn how to Upload table using new function GUI_UPLOAD in ABAP programming *& Report ZUPLOAD **& **&———————————————————————**& This program uses the new function GUI_UPLOAD **& Input must be TAB delimited with a blank column at the start **& to allow for MANDT. **& To use this program for any Database Table […]

ABAP Program for Submitting report with selection table

Sample ABAP Program for learning how to Submit report with selection table REPORT submit_with_selection_table.TABLES QMSM.* Work area for internal table IQMSMDATA: BEGIN OF WQMSM, QMNUM LIKE QMSM-QMNUM, MNGRP LIKE QMSM-MNGRP, MNCOD LIKE QMSM-MNCOD, ZZSTAT LIKE QMSM-ZZSTAT, END OF WQMSM. * WORK Area for internal table iseltab.DATA: WSELTAB LIKE RSPARAMS.*———————————————————————-** Internal tables*———————————————————————-** selection table to pass […]

ABAP Program for Sending SAP Mail

Sample ABAP program to show Sending SAP Mail using ABAP programming. *&———————————————————————**& Form SEND_MAIL*&———————————————————————** send email to current user **———————————————————————-*FORM SEND_MAIL. * PARAMETERS FOR SO_NEW_DOCUMENT_SEND_API1DATA: W_OBJECT_ID LIKE SOODK, W_SONV_FLAG LIKE SONV-FLAG.DATA: T_RECEIVERS LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE, W_OBJECT_CONTENT LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE, W_DOC_DATA LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE.*DATA: […]

ABAP Program for Search Layout sets for given String

Sample ABAP program to show how to search in Layout sets for a given string. REPORT Ysearchl LINE-SIZE 132. ************************************************************************** Program : Ysearchl* Authors : Chris Harrop (chris.harrop@bigfoot.com)* Date : March 1999* Purpose : Searches all Y and Z layout sets for a given string*************************************************************************** maintenance history** date author purpose************************************************************************* TABLES: STXL. PARAMETERS:STRING(128). DATA: BEGIN […]

ABAP Program for Sapscript PerForm Module

sample ABAP program to show how to use Sapscript PerForm Module in ABAP programs. REPORT YLSD999A.DATA W_LENGTH TYPE I.* GENERAL PURPOSE SUBROUTINES FOR CALLING FROM SAPSCRIPTS*———————————————————————–*———————————————————————-FORM DISPLAY_POUND TABLES IN_TAB STRUCTURE ITCSYOUT_TAB STRUCTURE ITCSY.DATA: COUNT TYPE P VALUE 16.DATA: W_VALUE(17) TYPE C. “defined as 7 chars to remove penceDATA: W_CHAR TYPE C.DATA: W_DUMMY TYPE C.DATA: W_CURR(3) […]

ABAP Program for Create IDOC

Sample ABAP program to show how to create IDOC using ABAP programs. FUNCTION Y_ISSUE_ROCO_IDOC.*”———————————————————————-*”*”Local interface:*” IMPORTING*” VALUE(I_MODE) LIKE Z1ROCO-ZMODE*” VALUE(I_ROUTE) LIKE Z1ROCO-ROUTE*” VALUE(I_CUT_OFF) LIKE Z1ROCO-CUT_OFF OPTIONAL*” VALUE(I_BEZEI) LIKE Z1ROCO-BEZEI OPTIONAL*” VALUE(I_TROUTE_MON) LIKE Z1ROCO-TROUTE_MON OPTIONAL*” VALUE(I_TROUTE_TUE) LIKE Z1ROCO-TROUTE_TUE OPTIONAL*” VALUE(I_TROUTE_WED) LIKE Z1ROCO-TROUTE_WED OPTIONAL*” VALUE(I_TROUTE_THU) LIKE Z1ROCO-TROUTE_THU OPTIONAL*” VALUE(I_TROUTE_FRI) LIKE Z1ROCO-TROUTE_FRI OPTIONAL*” VALUE(I_TROUTE_SAT) LIKE Z1ROCO-TROUTE_SAT OPTIONAL*” VALUE(I_TROUTE_SUN) […]

ABAP Program for Module Pool containing screen loop processing

Sample ABAP program for showing how to program Module Pool containing screen loop processing PROGRAM YLSDM004.TABLES: LTAP, “Transfer order itemLIPS, “SD doc delivery: item dataMAKT, “material descriptionVEPO, “SD Document: Shipping Unit ItemVEKP, “SD Document: Shipping Unit HeaderUSR01, “USER defaultsZPACKMAT, “Packing material tableT646M, “hazard class descriptionsZCASHAZLAB. “SCasehazardous label tableDATA: OK_CODE(4). DATA: C LIKE SY-INDEX, ” cursor […]

ABAP Program for MB1B Call Transaction

A sample ABAP program to understand how to use MB1B call transaction in ABAP. REPORT YMBIE096 LINE-SIZE 80. *———————————————————————-** Program: YMBIE096* Author: Sheila Titchener* Date: Mar 1999* Purpose: To move stock to new plant*———————————————————————-*TABLES: MCHB. * internal tableDATA: BEGIN OF I_MCHB OCCURS 0,MATNR LIKE MCHB-MATNR,LGORT LIKE MCHB-LGORT,CHARG LIKE MCHB-CHARG,J_2CTRNR LIKE MCHB-J_2CTRNR,J_2CELNG LIKE MCHB-J_2CELNG,CLABS LIKE MCHB-CLABS,END […]

ABAP Program of FTP Function Module

A sample ABAP program for understanding how to program with FTP function Module in ABAP. FUNCTION Y_FTP.*”———————————————————————-*”*”Local interface:*” IMPORTING*” VALUE(USER)*” VALUE(PWD)*” VALUE(HOST)*” TABLES*” COMMANDS*” EXCEPTIONS*” NO_SUCH_FILE*”———————————————————————- DATA: W_USER(12) TYPE C ,W_PWD(20) TYPE C ,W_HOST(64) TYPE C. DATA: HDL TYPE I,KEY TYPE I VALUE 26101957,DSTLEN TYPE I. DATA: BEGIN OF RESULT OCCURS 0,LINE(100) TYPE C,END OF […]

ABAP Program for Lock All Users

This program (un)locks all the users in a client, except for the current user, and the SAP* user. You might want to add somthing like SELECT-OPTIONS EXEMPTUS FOR USR02-BNAME to allow a list of usernames not to be processed. Sometimes it is useful to be able to lock all the users out of a client; […]

‘Hello world’ ABAP program

Call Transaction ‘SE38’. Create a new program. To proceed in an SAP 3.x system you must be registered as a Developer. You get your Developer Key from your Sys. admin in a couple of minutes/hours/days after you applied for it. It must be entered once when you create your first program. Program attributes: Type: 1 […]

ABAP program for Mass Purchase Order History Display

This is a customized ABAP report for mass Purchase Order history display instead of checking one a time. * *  Mass display or print Purchase Order History * *  You can request report by : *  1.  Change date *  2.  User Name *  3.  Purchase Order Number *  4.  Vendor Code REPORT ZPOCHANGE LINE-SIZE […]

ABAP OBJECTS Programming Sample Project with Employee Class

This example is a step by step example, moving from a simple class to more sophisticated classes,and covers inheritance, interfaces and events. Simple class Inheritance and polymorphism Interfaces Events   1. Simple class This example shows how to create a simple employee class. The constructor method is used to initialize number and name of the […]

ABAP program for find the user-exits of a SAP transaction code

*Sample ABAP program for Find the user-exits of a particular SAP transaction code (Tcode) * Enter the transaction code in which you are looking for the user-exit * and it will list you the list of user-exits in the transaction code. * Also a drill down is possible which will help you to branch to […]

Source Code for create subscreen in your ABAP Program

* Source Code for create subscreen in your ABAP Program * * This report will display the user last login date and time. * * Subscreen selection 1 : User Name *                                2 : Last Login Date *                                3 : Class Belong To * REPORT ZSUBSCREEN. TABLES: USR02,       “Logon data         SSCRFIELDS.  “FIELDS ON SELECTION […]

Batch Input with ‘Call Transaction’ – Sample ABAP program Code

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* […]

ABAP SQL Examples – Select Query

Requirement: Select those MM tables which are language dependant (For example you want to translate the customizing in two languages) Solution: report zbctcb96. tables: dd03l, tadir. data: counter type i value 1. select * from tadir where pgmid eq ‘R3TR’ and object eq ‘TABL’ and devclass like ‘M%’. select * from dd03l where tabname eq […]

ABAP Interactive Reporting Sample Code

Interactive reports in SAP ABAP are the kind of reports generated that can interact with user. Means, a user can have the option to select and view more detailed reports based on his selection. The difference between a classical report and an interactive report is that classical report provides a single report. But an interactive […]

ABAP program to load a database table from a UNIX file

Requirement: Write a program to load a database table from a UNIX file. ABAP Source Code: report zmjud001 no standard page heading. tables: z_mver. parameters: test(60) lower case default ‘/dir/judit.txt’. data: begin of unix_intab occurs 100, field(53), end of unix_intab. data: msg(60). ***open the unix file open dataset test for input in text mode message […]

ABAP program for Creating Extract Dataset

Requirement: Write a program that lists the Vendors and their Accounting documents. Create extract dataset from KDF logical database. Loop through the dataset to create the required report. Don’t list those vendors which has no documents ABAP Source Code: report zfwr0001 no standard page heading. tables: lfa1, bsik. field-groups: header, item1, item2. insert lfa1-lifnr bsik-belnr […]

ABAP program for Reading database tables using select

Requirement: Write the a report with a select statement. ABAP Source Code: report zselect1 no standard page heading. tables: lfa1. select * from lfa1 order by name1. write: / lfa1-name1, ‘ ‘, lfa1-lifnr. endselect

Reading logical database using ABAP program

SAP Logical databases are special type of ABAP programs to retrieve (read) database data for reusing in other application programs. it shortly known as ldb. It provides a customized view of the database data. A Logical database structure is a like a tree structure linked with the foreign key relationship between SAP database tables. Following […]