Skip to Content
0
Former Member
Jul 05, 2012 at 06:44 AM

Problem in Interactive ALV

41 Views

hi,

i am new to abap.. i have a requirement input is PO number and based on input to display PO number, ASN number,GRN number and invoice details usin ALV report.i have done the code... but i am not getting the output... problem is when i double click on PO field it will not go to second page to display GRN number.. whats is the problem... plz help me...

TYPE-POOLS: SLIS.

TYPES : BEGIN OF EKES,

EBELN TYPE EKES-EBELN,

VBELN TYPE EKES-VBELN,

END OF EKES.


DATA : IT_EKES TYPE TABLE OF EKES,

WA_EKES TYPE EKES.


TYPES : BEGIN OF MSEG,

EBELN TYPE MSEG-EBELN,

EBELP TYPE MSEG-EBELP,

WEMPF TYPE MSEG-WEMPF,

END OF MSEG.


DATA : IT_MSEG TYPE TABLE OF MSEG,

WA_MSEG TYPE MSEG.


TYPES : BEGIN OF RSEG,

EBELN TYPE RSEG-EBELN,

BELNR TYPE RSEG-BELNR,

MENGE TYPE RSEG-MENGE,

END OF RSEG.


DATA : IT_RSEG TYPE TABLE OF RSEG,

WA_RSEG TYPE RSEG.


DATA: REPID TYPE SY-REPID,

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.


SELECT-OPTIONS EBELN FOR WA_EKES-EBELN.


START-OF-SELECTION.

SELECT EBELN VBELN FROM EKES INTO TABLE IT_EKES WHERE EBELN IN EBELN.


WA_FIELDCAT-TABNAME = 'IT_EKES'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.


WA_FIELDCAT-TABNAME = 'IT_EKES'.

WA_FIELDCAT-FIELDNAME = 'VBELN'.

WA_FIELDCAT-SELTEXT_M = 'ASN NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.


LOOP AT IT_EKES INTO WA_EKES.

WRITE : / WA_EKES-EBELN,

WA_EKES-VBELN.

HIDE WA_EKES-EBELN.

ENDLOOP.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = IT_EKES[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.



IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.


AT LINE-SELECTION .

IF SY-LSIND = 1.


SELECT EBELN EBELP WEMPF FROM MSEG INTO TABLE IT_MSEG WHERE EBELN = WA_EKES-EBELN.


WA_FIELDCAT-TABNAME = 'IT_MSEG'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.


WA_FIELDCAT-TABNAME = 'IT_EBELP'.

WA_FIELDCAT-FIELDNAME = 'EBELP'.

WA_FIELDCAT-SELTEXT_M = 'ITEM NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.



WA_FIELDCAT-TABNAME = 'IT_MSEG'.

WA_FIELDCAT-FIELDNAME = 'WEMPF'.

WA_FIELDCAT-SELTEXT_M = 'GRN NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.



IF SY-SUBRC EQ 0.

LOOP AT IT_MSEG INTO WA_MSEG.

WRITE:/ WA_MSEG-EBELN, WA_MSEG-EBELP, WA_MSEG-WEMPF.

HIDE WA_MSEG-EBELN.

ENDLOOP.

ENDIF.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = IT_MSEG[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.



IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.



ELSEIF SY-LSIND = 2.

SELECT EBELN BELNR MENGE FROM RSEG INTO TABLE IT_RSEG WHERE EBELN = WA_MSEG-EBELN.


WA_FIELDCAT-TABNAME = 'IT_RSEG'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.



WA_FIELDCAT-TABNAME = 'IT_RSEG'.

WA_FIELDCAT-FIELDNAME = 'BELNR'.

WA_FIELDCAT-SELTEXT_M = 'INVOICE DETAILS .'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.



WA_FIELDCAT-TABNAME = 'IT_RSEG'.

WA_FIELDCAT-FIELDNAME = 'MENGE'.

WA_FIELDCAT-SELTEXT_M = 'QUANTITY.'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.



IF SY-SUBRC = 0.


LOOP AT IT_RSEG INTO WA_RSEG.

WRITE:/ WA_RSEG-EBELN, WA_RSEG-BELNR, WA_RSEG-MENGE.

HIDE WA_RSEG-EBELN.

ENDLOOP.

ENDIF.



CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = IT_RSEG[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.



ENDIF.

Moderator Message: <<subject altered>> Use proper subject line while posting

Message was edited by: Kesavadas Thekkillath