Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

classical drill down report

Former Member
0 Likes
1,594

Hi Experts

if i want to double click classical report(drill down report) and one field, i need to open another transaction code.

How to do in classical reports, pls give me with example code.

thanks in advance.

regards

rajaram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,075

Hi Raja,

Check this simple program.

REPORT  ychandra_call_transcation_test.

TABLES:
  mara.

SELECT-OPTIONS:
  s_matnr FOR mara-matnr.

DATA:
  w_matnr LIKE mara-matnr.

START-OF-SELECTION.
  SELECT SINGLE matnr
    FROM mara
    INTO w_matnr
   WHERE matnr IN s_matnr.

END-OF-SELECTION.
  WRITE:/ w_matnr.

AT LINE-SELECTION.

  SET PARAMETER ID 'MAT' FIELD w_matnr.
  LEAVE TO TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

Here I am writing Material Number(MATNR) on the basic list and once the user clicks on the Material Number it goes to the transaction MM03 with that material number.

MAT is the paremeter id for MATNR.

Regards,

Chandra Sekhar

7 REPLIES 7
Read only

Former Member
0 Likes
1,075

Hi, for that you have to assign with specifying column size. With those column width, the user clicks and call the transaction in your code.

Read only

Former Member
Read only

Former Member
0 Likes
1,076

Hi Raja,

Check this simple program.

REPORT  ychandra_call_transcation_test.

TABLES:
  mara.

SELECT-OPTIONS:
  s_matnr FOR mara-matnr.

DATA:
  w_matnr LIKE mara-matnr.

START-OF-SELECTION.
  SELECT SINGLE matnr
    FROM mara
    INTO w_matnr
   WHERE matnr IN s_matnr.

END-OF-SELECTION.
  WRITE:/ w_matnr.

AT LINE-SELECTION.

  SET PARAMETER ID 'MAT' FIELD w_matnr.
  LEAVE TO TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

Here I am writing Material Number(MATNR) on the basic list and once the user clicks on the Material Number it goes to the transaction MM03 with that material number.

MAT is the paremeter id for MATNR.

Regards,

Chandra Sekhar

Read only

0 Likes
1,075

the was simple and working fine but what if i am having multiple number of material and for each material i would like to call the corresponding Tcode MM03

Read only

Former Member
0 Likes
1,075

Hi,

I hope the below links will help you.

http://www.sap-img.com/abap/example-code-for-drill-down-report.htm

Thanks,

Khushboo.

Read only

Former Member
0 Likes
1,075

Hi,

Check this sample code


REPORT z_sdn.

*" Data declarations...................................................
*"--------------------------------------------------------------------*
* Work variables                                                      *
*"--------------------------------------------------------------------*
DATA:
  BEGIN OF fs_vbak,
    vbeln LIKE vbak-vbeln,             " Sales Document
    erdat LIKE vbak-erdat,             " Creation Date
    ernam LIKE vbak-ernam,             " Person who created the Object
    vbtyp LIKE vbak-vbtyp,             " SD Document Category
    auart LIKE vbak-auart,             " Sales Document Type
    lifsk LIKE vbak-lifsk,             " Delivery Block
    faksk LIKE vbak-faksk,             " Billing Block in SD Document
    netwr LIKE vbak-netwr,             " Net Value of Sales Order
    vkorg LIKE vbak-vkorg,             " Sales Organisation
    kunnr LIKE vbak-kunnr,             " Sold to Party
  END OF fs_vbak,
   w_vbeln LIKE vbak-vbeln,            " Sales Document
  BEGIN OF fs_vbap,
    vbeln LIKE vbap-vbeln,             " Sales Document
    posnr LIKE vbap-posnr,             " Sales Document Item
    matnr LIKE vbap-matnr,             " Material Number
    meins LIKE vbap-meins,             " Base Unit of Measure
  END OF fs_vbap.
*"--------------------------------------------------------------------*
* Internal Table to hold Sales Document                               *
*"--------------------------------------------------------------------*
DATA:
  t_vbak LIKE
   TABLE OF
         fs_vbak.
*"--------------------------------------------------------------------*
* Internal Table to hold Sales Document                               *
*"--------------------------------------------------------------------*
DATA:
  t_vbap LIKE
   TABLE OF
         fs_vbap.

*"Selection screen elements............................................
SELECTION-SCREEN BEGIN OF BLOCK blck WITH FRAME TITLE text-001.
  SELECT-OPTIONS: s_vbeln FOR w_vbeln.
SELECTION-SCREEN END OF BLOCK blck.

*"--------------------------------------------------------------------*
*    AT SELECTION-SCREEN on s_vbeln                                   *
*"--------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_vbeln.
  PERFORM validate.

*"--------------------------------------------------------------------*
*    START-OF-SELECTION Event                                         *
*"--------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM get_frm_vbak.
*"--------------------------------------------------------------------*
*    TOP-OF-PAGE Event                                                *
*"--------------------------------------------------------------------*
TOP-OF-PAGE.
  ULINE.
  WRITE: /10 text-001 COLOR 5,
          25 text-002 COLOR 5,
          40 text-003 COLOR 5,
          60 text-004 COLOR 5,
          69 text-005 COLOR 5,
          83 text-006 COLOR 5,
          96 text-007 COLOR 5,
         110 text-008 COLOR 5,
         119 text-009 COLOR 5,
         132 text-010 COLOR 5.
  ULINE.

*"--------------------------------------------------------------------*
*    TOP-OF-PAGE DURING LINE-SELECTION                                *
*"--------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
   WRITE: /10 text-001 COLOR 4,
           25 text-011 COLOR 4,
           40 text-012 COLOR 4,
           60 text-013 COLOR 4.
*"--------------------------------------------------------------------*
*    END-OF-PAGE Event                                                *
*"--------------------------------------------------------------------*
END-OF-PAGE.
   WRITE: 'END-OF-PAGE'.
*"--------------------------------------------------------------------*
*    END-OF-SELECTION Event                                           *
*"--------------------------------------------------------------------*
END-OF-SELECTION.
  PERFORM display_t_vbak.
*"--------------------------------------------------------------------*
*    AT LINE-SELECTION EVENT                                          *
*"--------------------------------------------------------------------*
AT LINE-SELECTION.
  IF sy-lsind EQ 1 AND sy-lilli GE 4.
    PERFORM get_vbap_data.
    PERFORM display_vbap_data.
  ELSEIF sy-lilli LT 5.
   MESSAGE 'Invalid Selection' TYPE 'I'.
  ENDIF.                               " IF sy-lsind EQ 1..
*&---------------------------------------------------------------------*
*&      Form  validate
*&---------------------------------------------------------------------*
* This subroutine validates the Sales Document entered by user
*----------------------------------------------------------------------*
* This subroutine does not have interface parameters
*----------------------------------------------------------------------*
FORM validate .
  SELECT SINGLE
         vbeln                         " Sales Document
    FROM vbak
    INTO w_vbeln
   WHERE vbeln IN s_vbeln.
  IF w_vbeln IS INITIAL.
    MESSAGE s000(yh1146_msg) WITH s_vbeln.
  ENDIF.                               " IF w_vbeln IS INITIAL
ENDFORM.                               " VALIDATE
*&---------------------------------------------------------------------*
*&      Form  get_frm_vbak
*&---------------------------------------------------------------------*
*  This subroutine fetches the data from vbak and pass it to t_vbak
*----------------------------------------------------------------------*
*  This subroutine does not have interface parameters to pass
*----------------------------------------------------------------------*
FORM get_frm_vbak .
  SELECT vbeln                         " Sales Document
         erdat                         " Creation Date
         ernam                         " Person who created the Object
         vbtyp                         " SD Document Category
         auart                         " Sales Document Type
         lifsk                         " Delivery Block(document header)
         faksk                         " Billing Block in SD Document
         netwr                         " Net Value of Sales Order
         vkorg                         " Sales Organisation
         kunnr                         " Sold to Party
    FROM vbak
    INTO TABLE t_vbak
   WHERE vbeln IN s_vbeln.

ENDFORM.                               " GET_FRM_VBAK
*&---------------------------------------------------------------------*
*&      Form  display_t_vbak
*&---------------------------------------------------------------------*
* This subroutine displays the data from vbak table
*----------------------------------------------------------------------*
* This subroutine does not have interface parameters to pass
*----------------------------------------------------------------------*
FORM display_t_vbak .
  LOOP AT t_vbak INTO fs_vbak.
    WRITE: / fs_vbak-vbeln UNDER text-001,
             fs_vbak-erdat UNDER text-002,
             fs_vbak-ernam UNDER text-003,
             fs_vbak-vbtyp UNDER text-004,
             fs_vbak-auart UNDER text-005,
             fs_vbak-lifsk UNDER text-006,
             fs_vbak-faksk UNDER text-007,
         97  fs_vbak-netwr ,
             fs_vbak-vkorg UNDER text-009,
             fs_vbak-kunnr UNDER text-010.
   HIDE:
     fs_vbak-vbeln.
  ENDLOOP.                             " LOOP AT t_vbak..
   CLEAR fs_vbak.
ENDFORM.                               " DISPLAY_T_VBAK


*&---------------------------------------------------------------------*
*&      Form  GET_vbap_data
*&---------------------------------------------------------------------*
*  This subroutine fetches the data from vbap table
*----------------------------------------------------------------------*
* This subrotuine does not have interface parameters to pass
*----------------------------------------------------------------------*
FORM get_vbap_data .
  SELECT vbeln                         " Sales Document
         posnr                         " Sales Document Item
         matnr                         " Material Number
         meins                         " Base Unit of Measure
    FROM vbap
    INTO TABLE t_vbap
   WHERE vbeln EQ fs_vbak-vbeln.
ENDFORM.                               " GET_VBAP_DATA
*&---------------------------------------------------------------------*
*&      Form  display_vbap_data
*&---------------------------------------------------------------------*
*  This subroutine displays the data of vbap table
*----------------------------------------------------------------------*
* This subroutine does not have interface parameters to pass
*----------------------------------------------------------------------*
FORM display_vbap_data .
  LOOP AT t_vbap INTO fs_vbap.
    WRITE: / fs_vbap-vbeln UNDER text-001,
             fs_vbap-posnr UNDER text-011,
             fs_vbap-matnr UNDER text-012,
             fs_vbap-meins UNDER text-013.
  ENDLOOP.                             " LOOP AT t_vbap..
ENDFORM.                               " display_vbap_data

Regards

Abhijeet

Read only

Former Member
0 Likes
1,075

Hi Raja Ram,

We can get this functionality using CALL TRANSACTION syntax.

Pleasae check this code

DATA: w_cust TYPE kna1-kunnr.
SELECT-OPTIONS: s_cust FOR w_cust OBLIGATORY.



DATA:
 BEGIN OF fs_basiclist,
 kunnr LIKE kna1-kunnr,
 name1 LIKE kna1-name1,
 vbeln LIKE vbak-vbeln,
 END OF fs_basiclist.

DATA:
  BEGIN OF fs_order,
  vbeln LIKE vbak-vbeln,
  vbelnp LIKE vbap-vbeln,
  posnr LIKE vbap-posnr,
  matnr LIKE vbap-matnr,
  kwmeng LIKE vbap-kwmeng,
  netpr LIKE vbap-netpr,
  END OF fs_order.


DATA:
  t_basiclist LIKE TABLE OF fs_basiclist,
  t_order LIKE TABLE OF fs_order.



START-OF-SELECTION.
  SET PF-STATUS 'CUSTOMER'.
  PERFORM get_customer.


AT LINE-SELECTION.
  PERFORM get_orderdetails.


AT USER-COMMAND.
  PERFORM get_details.
*&---------------------------------------------------------------------*
*&      Form  get_customer
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_customer .
  SELECT kna1~kunnr
         kna1~name1
         vbak~vbeln
       INTO TABLE t_basiclist
       FROM kna1
       INNER JOIN vbak ON
       kna1~kunnr = vbak~kunnr
       WHERE kna1~kunnr IN s_cust.

  WRITE:/3  'Customer',
         15 'Customer Name',
         35 'Order Number'.
  IF sy-subrc = 0.
    LOOP AT t_basiclist INTO fs_basiclist.
      WRITE:/5 fs_basiclist-kunnr,
             15 fs_basiclist-name1,
             38 fs_basiclist-vbeln.
      HIDE fs_basiclist-kunnr.
    ENDLOOP.                           " Loop at t_basiclist
  ENDIF.                               " If sy-subrc
ENDFORM.                               " get_customer
*&---------------------------------------------------------------------*
*&      Form  get_details
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_details .
  DATA: w_var1(10) TYPE c,
        w_var2(10) TYPE c.
  CASE sy-ucomm.

    WHEN 'BUTTON1'.


      GET CURSOR FIELD  fs_basiclist-kunnr VALUE w_var1.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = w_var1
        IMPORTING
          output = w_var1.
      SELECT SINGLE kunnr
       FROM kna1
       INTO fs_basiclist
       WHERE kunnr = w_var1.

      IF sy-subrc NE 0.
        MESSAGE 'Invalid Cursor Position' TYPE 'E'.
      ENDIF.
      SET PARAMETER ID 'KUN' FIELD  w_var1.
      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.


    WHEN 'BUTTON2'.
      GET CURSOR FIELD  fs_order-vbeln VALUE w_var2.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = w_var2
        IMPORTING
          output = w_var2.
      SELECT SINGLE vbeln
         FROM vbak
         INTO fs_basiclist
         WHERE vbeln = w_var2.

      IF sy-subrc NE 0.
        MESSAGE 'Invalid Cursor Position' TYPE 'E'.
      ENDIF.
      SET PARAMETER ID 'AUN' FIELD  w_var2.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
  ENDCASE.                             " Case sy-ucomm
ENDFORM.                               " get_details
*&---------------------------------------------------------------------*
*&      Form  get_orderdetails
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_orderdetails .

  SELECT vbeln
         posnr
         matnr
         kwmeng
         netpr
     FROM vbap
     INTO CORRESPONDING FIELDS OF TABLE t_order
     WHERE vbeln = fs_basiclist-vbeln.

  WRITE:/5 'Item Number',
         18 'Material',
         28 'Order Quantity',
         45 'Price'.

  IF sy-subrc = 0.
*    write:/ fs_basiclist-kunnr.
    LOOP AT t_order INTO fs_order.
      WRITE:/7 fs_order-posnr,
             20 fs_order-matnr,
             28 fs_order-kwmeng,
             37 fs_order-netpr.
    ENDLOOP.                           " Loop t_order
  ENDIF.                               " If sy-subrc
ENDFORM.                               " get_orderdetails

Best regards,

raam