Sunday 26 June 2016

How to Know Material Info easily!

Many times we create material master by referring to another already created material. We need to know what is the industry sector and material type in Tx- MM01.
12
Go to Tx- MM03 and provide the already created material that you want to refer to create a new material.
3
Choose  Basic Data 1.
4
Select the marked [ i ] icon.
5
It displays the industry sector and the material type of the material. You can easily know this without going back to the DB tables and checking the details.
6
----------------------------------------------------------------------------------------------------------------------------------------

Dynamic call to FM with PARAMETER-TABLE

The below post shows how to call a FM dynamically and passing all the parameters by using PARAMETER-TABLE option.
We have the below FM with parameters in different sections such as import, export, tables.
12345
The source code returns a table of records from SFLIGHT table if the selection criteria meets else sends back only a text message.67

PRORGAM
TYPE-POOLSabap.
DATAfm_name   TYPE rs38l_fnam VALUE ‘FLIGHT_DETAILS’,
              lt_param  TYPE abap_func_parmbind_tab,
              ls_param  TYPE abap_func_parmbind,
              lv_msg    TYPE string,
              lt_flight TYPE TABLE OF sflight.
FIELD-SYMBOLS<fs_msg>     TYPE string,
                                    <fs_details> TYPE ANY TABLE.
PARAMETERSp_carr TYPE sflightcarrid,
                             p_conn TYPE sflightconnid,
                             p_date TYPE sflightfldate.
* Build parameters
ls_paramname ‘CARRID’.
ls_paramkind abap_func_exporting.
GET REFERENCE OF p_carr INTO ls_paramvalue.
APPEND ls_param TO lt_param.
CLEAR ls_param.
ls_paramname ‘CONNID’.
ls_paramkind abap_func_exporting.
GET REFERENCE OF p_conn INTO ls_paramvalue.
APPEND ls_param TO lt_param.
CLEAR ls_param.
ls_paramname ‘FLDATE’.
ls_paramkind abap_func_exporting.
GET REFERENCE OF p_date INTO ls_paramvalue.
APPEND ls_param TO lt_param.
CLEAR ls_param.
ls_paramname ‘MSG’.
ls_paramkind abap_func_importing.
GET REFERENCE OF lv_msg INTO ls_paramvalue.
APPEND ls_param TO lt_param.
CLEAR ls_param.
ls_paramname ‘DETAILS’.
ls_paramkind abap_func_tables.
GET REFERENCE OF lt_flight INTO ls_paramvalue.
APPEND ls_param TO lt_param.
CLEAR ls_param.
* Dynamic FM call with all import,export,table parameters
* passed in the Parameter-table
CALL FUNCTION fm_name
  PARAMETERTABLE lt_param.
READ TABLE lt_param INTO ls_param WITH KEY name ‘MSG’.
IF sysubrc IS INITIAL.
  ASSIGN ls_paramvalue->TO <fs_msg>.
  IF <fs_msg> IS ASSIGNED AND <fs_msg> IS NOT INITIAL.
    WRITE:/ <fs_msg>.
  ELSE.
    READ TABLE lt_param INTO ls_param WITH KEY name ‘DETAILS’.
    IF sysubrc IS INITIAL.
      ASSIGN ls_paramvalue->TO <fs_details>.
      IF <fs_details> IS ASSIGNED AND <fs_details> IS NOT INITIAL .
        lt_flight =   <fs_details>.
        CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
          EXPORTING
            i_callback_program syrepid
            i_structure_name   ‘SFLIGHT’
          TABLES
            t_outtab           lt_flight.
      ENDIF.
    ENDIF.
  ENDIF.
ENDIF.

13.jpg
RUN & OUTPUT- For the selection criteria no data is present in SFLIGHT table.
89
RUN & OUTPUT- For the selection criteria data is present in SFLIGHT table.
1011

Needed Info defined in TYPE GROUP- ABAP
12
-------------------------------------------------------------------------------------------------------------------------------------------

Thursday 23 June 2016

Dynamic FM call with extra parameter

Use Case 
Consider the scenario in your development, you are reusing a standard FM in your program which is having 2 mandatory import parameters . And you shipped the solution to the customer. Now same FM in the customer system is having one more additional mandatory importing parameter. Now when your program runs and that calls the FM the dump appears in customer system. How to resolve this issue. This can be done by calling the FM dynamically with extra parameter that is not in your system but it is there in customer system. The below post tries to show the same.

The  FM ‘FPM_DEMO_FLIGHT_GET_CARRIER’ having below details as one import and one export parameter.
123
Simple way of calling the FM.
4
Output of program.
5
In the simple call pass one more parameter like CONNID which is not declared as a import parameter in the FM definition.
6
No activation error of the program but once you execute below error appears.
7
Trying a dynamic call to the FM without any additional parameter.
8
Program output:
9
With dynamic FM call, added other parameter which is not there in the FM definition.
Imagine in your system CONNID parameter is not defined, but the FM call works fine without any error but if it is defined in the FM then surely there would not be any dump.
10
Here is the output without any dump.
11

Comments system

Disqus Shortname