Archive

Posts Tagged ‘ABAP’

Sorting Data in LT06

April 4th, 2011

NOTE:
- SAP Used : SAP R/3 4.6C
- Need access key to change the standard program

How to sort Storage Bin display in transaction LT06.

Include program: ML03TO00_D0142_DATEN
Module: MODULE D0142_DATEN OUTPUT.

Insert this code at the end of the module:
SORT ILQUAUG BY VFDAT LGTYP LGPLA.

If you want to sort the data by expired date, storage type and storage bin.

vera Uncategorized ,

FM to get material stock in WM

September 24th, 2010

GET_SORT_BY_EXP
GET_SORT_BY_GR
GET_SORT_BY_LOC

vera Uncategorized

User Exits

June 5th, 2009

I got the link from: http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

well, who knows I might need it later ;)

TITLE: A Short Tutorial on User Exits

Content Author: Abhishek

1. Introduction:

User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a functionmodule. The code for the function module is writeen by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for functionmodule exits is:
EXIT_
<3 digit suffix>

The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>

Example:

The program for transaction VA01 Create salesorder is SAPMV45A Read more…

vera ABAP ,

Netweaver 7.01 ABAP Trial version

January 29th, 2009

Do you want to play with ABAP at home? Then try to download Netweaver 7.01 from this link:
https://www.sdn.sap.com/downloads/netweaver/abap/disclaimer.html

They also provide tutorial for installing this application. Here’s the link:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/library/elearning/abap/How%20to%20Install%20SAP%20NetWeaver%20Abap%207.0%20SP12%20-%20Trial%20Version/sim/description.htm

Enjoy!

vera ABAP ,

Conversion Exit

January 29th, 2009

If you notice, some fields in SAP tables have different values when you view them in SE16. For example, try to see table IFLO (functional location master) and input the functional location value. In my case, it’s UJ-UTI-GRL. Execute.

The displayed value is not UJ-UTI-GRL, but ‘?0100000000000000162′ instead. ‘UJ-UTI-GRL’ is the external value while ‘?0100000000000000162′ is internal value. When we access the table from the program, it only recognizes internal value. All wee need to do is do the conversion for the field using ‘CONVERSION_EXIT_TPLNR_INPUT’ to get the internal value and ‘CONVERSION_EXIT_TPLNR_OUTPUT’ vice verso.

Here’s the example code:
data: D_TPLNR TYPE TPLNR.
CALL FUNCTION ‘CONVERSION_EXIT_TPLNR_INPUT’
EXPORTING
input = viqmel-tplnr
IMPORTING
OUTPUT = D_TPLNR.

And voila! You’ll get your internal value for functional location stored in D_TPLNR variable.

You can also find other fields conversion exits. Go to SE37 and find other function module containing ‘CONVERSION_EXIT_XXX_INPUT’ where XXX is the field name.

Enjoy!

vera ABAP ,

Getting a field value of a screen field

January 29th, 2009

In dialog programming, the value of a screen field will be moved to the variable in your program after the Process After Input (PAI) is executed. What if you need the value before PAI is executed? For example, you have two fields in your screen: functional location (VIQMEL-TPLNR) and equipment (VIQMEL-EQUNR). You need to implement a search help for equipment number, but you only what to get equipments that is installed in the functional location specified.

When you debug your search help module, you can’t get the value of functional location the user entered. Why? Because your search help module will be placed in Process on value-request (POV), and the POV will be executed before PAI.

How to obtain your screen field value then? Simple. Just execute Function Module ‘GET_DYNP_VALUE’ and you will get what you want. Read more…

vera ABAP , ,

Multiple lines text element

January 27th, 2009

Did you ever need a multiple lines input for your user interface in dialog programming using screen painter? Well, I did. And I spent the whole day searching for a way to implement what I wanted.

Guess what! A few minutes ago I thought why didn’t I use an internal table with one element and put it in my screen? Why didn’t I think of that? Bummer! I had to waste a whole day searching for a “multiple lines text element” :P .

Here’s the code you will need to get what you want:

  1. First, you will need to declare an internal table containing 1 field only. For example:
    data: BEGIN OF T_LINES OCCURS 0,
    lines(100),
    END OF T_LINES.
  2. Read more…

vera ABAP , ,

Simplified PM Service Notification

January 23rd, 2009

I have been searching for BAPI for creating a PM service notification. I found several Function Modules: First I found BAPI_SERVICENOTIFICAT_CREATE and second I found BAPI_SERVNOT_CREATE.

I tried to create notification using BAPI_SERVICENOTIFICAT_CREATE but it keeps giving this error: EIS499E499 Non-specifiable notification in function module. When I try to use BAPI_SERVICENOTIFICAT_GETLIST
to get an example data for existing service notification, I can’t use the function module since all the example data doesn’t contain any customer number while the function module set customer number as an obligatory parameter.

Create PM Notification
Create PM Notification screenshot

Then it leaves me to the second choice, BAPI_SERVNOT_CREATE. When I tried to create service notification using this function, it keeps giving this error: ‘Notification Type M1 is not defined’. Now I need to know how to populate the data in the function module. Maybe I populated them wrong, so I run this function BAPI_SERVNOT_GET_DETAIL filling service notification number that has been created manually. It still giving the same error ‘Notification Type M1 is not defined’. Then I almost gave up.

Read more…

vera ABAP , ,

Problem with BAPI

January 23rd, 2009

Today is the xxxth day I’m looking for this BAPI_SERVNOT_CREATE documentation all over the net. I’m not familiar with PM transaction and we don’t have any functional here so I’ve got no one to ask. I’ve been searching the internet for the documentation but found none.

All the articles I found are only explaining how the function module works, but there’s no example on how to populate the data.

If I got any luck and succeed, I’ll write down a complete example code to get the function module work. Wish me luck!

vera ABAP ,

Making ALV Grid Editable

November 18th, 2008

Actually this subject is included in BCALV_EDIT* in SAP/R3. I just want to make several conclusions, and make some notes on how to implement an ALV Editable Grid with the minimum method required to make it work. In this example I use a dynamic ALV Grid, so here are the steps:

1. You must create a screen (e.g. 9000) and create a CUSTOM_CTRL on that screen.
2. Add these variables to your program:

DATA: GRID TYPE REF TO CL_GUI_ALV_GRID,

CUST_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

G_LAYOUT TYPE LVC_S_LAYO,

G_FIELDCAT TYPE LVC_S_FCAT OCCURS 0,

GS_FIELDCAT TYPE LVC_S_FCAT.

3. You must define a class derived from CL_GUI_ALV_GRID to make custom methods that you can edit according to your needs.
To see the methods (and parameters needed) available for CL_GUI_ALV_GRID, you can double click on the class.
The code will look like this:

CLASS LCL_9000_GRIDEVENT DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_DATACHANGE FOR EVENT DATA_CHANGED OF
CL_GUI_ALV_GRID IMPORTING
ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,

HANDLE_USERCOMMAND FOR EVENT USER_COMMAND OF
CL_GUI_ALV_GRID IMPORTING E_UCOMM.

ENDCLASS.

CLASS LCL_9000_GRIDEVENT IMPLEMENTATION.

METHOD HANDLE_DATACHANGE.
perform f_datachange using er_data_changed.
ENDMETHOD.

METHOD HANDLE_USERCOMMAND.
perform f_usercommand using e_ucomm.
ENDMETHOD.

ENDCLASS.

4. Create a variable that refers to the class created.

DATA: LCL_9000_GRIDEVENT TYPE REF TO LCL_9000_GRIDEVENT.

5. Create PBO for your screen. For example your PBO method name is PBO_9000. The code will look like this:

MODULE PBO_9000 OUTPUT.

IF CUST_CONTAINER IS INITIAL.

CREATE OBJECT CUST_CONTAINER
EXPORTING
CONTAINER_NAME = ‘CS_CTRL’.

CREATE OBJECT GRID
EXPORTING
I_PARENT = CUST_CONTAINER.

GS_REPID = SY-REPID.

*—This part will costumize the display of your grid
G_LAYOUT-GRID_TITLE = ‘Put your title here’.
G_LAYOUT-CWIDTH_OPT = ‘X’.
G_LAYOUT-no_rowins = ‘X’.
*—————————————————-

*—Build your field catalog for your internal table displayed
PERFORM F_9000_BUILD.
*—————————————————-

CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = G_LAYOUT
CHANGING
IT_OUTTAB = T_DATA
IT_FIELDCATALOG = G_FIELDCAT.

*—–These are the key methods called for editable ALV Grid to *—–work properly
CALL METHOD GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.

call method grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
*———————————————————————–

*——————attach your grid to the EVENT HANDLER
CREATE OBJECT LCL_9000_GRIDEVENT.
set handler LCL_9000_GRIDEVENT->handle_datachange for grid.
set handler LCL_9000_GRIDEVENT->handle_usercommand for grid.
*———————————————————

ENDIF.

CALL METHOD GRID->SET_FRONTEND_FIELDCATALOG
EXPORTING
IT_FIELDCATALOG = G_FIELDCAT.
CALL METHOD GRID->REFRESH_TABLE_DISPLAY.

CALL METHOD CL_GUI_CONTROL=>SET_FOCUS EXPORTING CONTROL = GRID.

ENDMODULE. ” PBO_9000 OUTPUT

6. You need to fill in G_FIELDCAT variable. For example, you want to make an internal table contains material id and text. Material ID will be editable but not the text because material text will be obtained from MAKT table. This is the implementation looks like:

FORM F_9000_BUILD.
clear GS_FIELDCAT.
GS_FIELDCAT-fieldname = ‘MATNR’.
GS_FIELDCAT-ref_table = ‘MARA’.
GS_FIELDCAT-ref_field = ‘MATNR’.
GS_FIELDCAT-EDIT = ‘X’.
append GS_FIELDCAT TO G_FIELDCAT.

CLEAR GS_FIELDCAT.
GS_FIELDCAT-fieldname = ‘MAKTX’.
GS_FIELDCAT-ref_table = ‘MAKT’.
GS_FIELDCAT-ref_field = ‘MAKTX’.
append GS_FIELDCAT TO G_FIELDCAT.
ENDFORM

Done! You’re Editable ALV Grid is ready to be used. Enjoy!

vera ABAP ,