i have list of sale order numbers in my table control wizard....when i double click on any sale order number or click push button "DETAIL" screen is open in VA03 but it is picking sale order number which is last in the list.....
kindly help me...m suing this code....
TABLES: VBAK,VBFA.
*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'TABD'
TYPES: BEGIN OF T_TABD,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
NETWR LIKE VBAK-NETWR,
BSTNK LIKE VBAK-BSTNK,
END OF T_TABD.
*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'TABD'
DATA: G_TABD_ITAB TYPE T_TABD OCCURS 0 WITH HEADER LINE,
G_TABD_WA TYPE T_TABD. "work area
DATA: G_TABD_COPIED. "copy flag
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TABD' ITSELF
CONTROLS: TABD TYPE TABLEVIEW USING SCREEN 0100.
*&SPWIZARD: LINES OF TABLECONTROL 'TABD'
DATA: G_TABD_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
DATA: ws_field(30),
ws_line TYPE i,
L_SO LIKE VBAK-VBELN..
SELECTION-SCREEN:BEGIN OF BLOCK BLK1 WITH FRAME TITLE T001.
SELECT-OPTIONS:KUNNR FOR VBAK-KUNNR,
VBELN FOR VBAK-VBELN,
ERDAT FOR VBAK-ERDAT.
SELECTION-SCREEN:END OF BLOCK BLK1.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MENU'.
* SET TITLEBAR 'xxx'.
CASE SY-UCOMM.
WHEN 'DETAIL'.
* GET CURSOR FIELD ws_field LINE ws_line.
* GET CURSOR FIELD vbak-VBELN VALUE G_TABD_WA-VBELN. READ TABLE sflight_tab INDEX sy-index INTO sflight_wa.
READ TABLE G_TABD_ITAB INTO G_TABD_WA INDEX SY-INDEX.
SET PARAMETER ID 'AUN' FIELD G_TABD_wa-VBELN.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
WHEN 'EXIT'.
*CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN..
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " STATUS_0100 OUTPUT
*&SPWIZARD: OUTPUT MODULE FOR TC 'TABD'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE TABD_INIT OUTPUT.
IF G_TABD_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'VBAK'
*&SPWIZARD: INTO INTERNAL TABLE 'g_TABD_itab'
SELECT * FROM VBAK
INTO CORRESPONDING FIELDS
OF TABLE G_TABD_ITAB
WHERE KUNNR IN KUNNR
AND VBELN IN VBELN
AND ERDAT IN ERDAT ..
G_TABD_COPIED = 'X'.
LOOP AT G_TABD_ITAB.
SELECT * FROM VBFA WHERE VBELV = G_TABD_ITAB-VBELN.ENDSELECT.
IF SY-SUBRC = 0.
DELETE G_TABD_ITAB.
ENDIF.
* COLLECT G_MATT_ITAB.
ENDLOOP.
REFRESH CONTROL 'TABD' FROM SCREEN '0100'.
ENDIF.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.