USER_COMMAND in the 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
HAI Experts ,
Can anyone pls give me a sample code which displays some operation using USER_COMMAND in the 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' .
Any small sample program will be helpful.
Regards,
Devendran
hi
Check this code:
REPORT Z_RE_ALV_JERARQUIA .
*****TABLAS
TABLES : MARA, MAKT.
****TIPOS
TYPE-POOLS: SLIS.
****TABLAS INTERNAS
DATA: IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE,
WA_MARA LIKE LINE OF IT_MARA ,
BEGIN OF IT_HEADER OCCURS 0,
TIPO LIKE MARA-MTART,
END OF IT_HEADER,
BEGIN OF IT_ITEM OCCURS 0,
TIPO LIKE MARA-MTART,
MATERIAL LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MEINS LIKE MARA-MEINS,
MAKTX LIKE MAKT-MAKTX,
END OF IT_ITEM.
*****ALV
DATA: IT_KEYINFO type SLIS_KEYINFO_ALV OCCURS 0 WITH HEADER LINE,
G_REPID LIKE SY-REPID,
IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_FIELD TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
IT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
IT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
IT_LIST_END_OF_PAGE TYPE SLIS_T_LISTHEADER,
IT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
IT_FILTER TYPE SLIS_T_FILTER_ALV WITH HEADER LINE,
GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
ls_event type slis_alv_event,
LS_LINE TYPE slis_listheader.
*****VARIABLES
DATA: TEXT(60).
****CONSTANTES
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
****INITIALIZATION
INITIALIZATION.
G_REPID = SY-REPID.
IT_LAYOUT-ZEBRA = 'X'.
IT_LAYOUT-no_hotspot = ' '.
IT_layout-colwidth_optimize = 'X'.
****START OF SELECTION
START-OF-SELECTION.
SELECT-OPTIONS: TIPO FOR MARA-MTART OBLIGATORY.
SELECT *
FROM MARA
INTO TABLE IT_MARA
WHERE MTART IN TIPO.
IF NOT IT_MARA[] IS INITIAL.
PERFORM FO_PROCESAR.
PERFORM FO_KEY_INFO.
PERFORM FO_IMPRIMIR_CABECERA USING IT_LIST_TOP_OF_PAGE[].
PERFORM FO_SORT.
PERFORM FO_FIELDCAT.
PERFORM FO_FILTRAR.
PERFORM FO_EVENTOS USING IT_events[].
PERFORM FO_MOSTRAR_ALV_JER.
ELSE.
MESSAGE S000(SU) WITH TEXT-001.
ENDIF.
*& Form FO_PROCESAR
FORM FO_PROCESAR.
SORT IT_MARA BY MTART ASCENDING.
LOOP AT IT_MARA.
MOVE-CORRESPONDING IT_MARA TO WA_MARA.
MOVE WA_MARA-MTART TO IT_HEADER-TIPO.
APPEND IT_HEADER.
MOVE: IT_MARA-MTART TO IT_ITEM-TIPO,
IT_MARA-MATNR TO IT_ITEM-MATERIAL,
IT_MARA-MATKL TO IT_ITEM-MATKL,
IT_MARA-MEINS TO IT_ITEM-MEINS.
SELECT SINGLE MAKTX INTO IT_ITEM-MAKTX
FROM MAKT
WHERE MATNR EQ IT_MARA-MATNR
AND SPRAS EQ 'S'.
APPEND IT_ITEM.
CLEAR: IT_MARA, WA_MARA, IT_ITEM, IT_HEADER.
ENDLOOP.
SORT IT_HEADER BY TIPO ASCENDING.
DELETE ADJACENT DUPLICATES FROM IT_HEADER COMPARING TIPO.
ENDFORM. " FO_PROCESAR
*& Form FO_MOSTRAR_ALV_JER
FORM FO_MOSTRAR_ALV_JER.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = IT_LAYOUT
IT_FIELDCAT = IT_FIELD[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT[]
IT_FILTER = IT_FILTER[]
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 10
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 45
I_SCREEN_END_LINE = 30
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT =
IT_EVENTS = IT_EVENTS[]
IT_EVENT_EXIT =
I_TABNAME_HEADER = 'IT_HEADER'
I_TABNAME_ITEM = 'IT_ITEM'
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
IS_KEYINFO = IT_KEYINFO
IS_PRINT =
IS_REPREP_ID =
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB_HEADER = IT_HEADER
T_OUTTAB_ITEM = IT_ITEM
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.
ENDFORM. " FO_MOSTRAR_ALV_JER
*& Form FO_KEY_INFO
FORM FO_KEY_INFO.
REFRESH IT_KEYINFO. CLEAR IT_KEYINFO.
IT_KEYINFO-header01 = 'TIPO'.
IT_KEYINFO-item01 = 'TIPO'.
APPEND IT_KEYINFO.
ENDFORM. " FO_KEY_INFO
*& Form FO_IMPRIMIR_CABECERA
FORM FO_IMPRIMIR_CABECERA USING TEXTO_REPORT TYPE SLIS_T_LISTHEADER.
CLEAR: LS_line, text.
LS_line-typ = 'H'.
WRITE: sy-title TO text.
LS_line-info = text.
APPEND LS_line TO TEXTO_REPORT.
CLEAR: LS_line, text.
LS_line-typ = 'A'.
WRITE: 'Fecha de Ejecución:' to text,
sy-DATUM TO text+20(20).
LS_line-info = text.
APPEND LS_line TO TEXTO_REPORT.
CLEAR: LS_line, text.
LS_line-typ = 'A'.
WRITE: 'Usuario:' to text,
sy-uname TO text+20(20).
LS_line-info = text.
APPEND LS_line TO TEXTO_REPORT.
CLEAR LS_LINE.
APPEND LS_line TO TEXTO_REPORT.
ENDFORM. " FO_IMPRIMIR_CABECERA
*& Form FO_SORT
FORM FO_SORT.
IT_SORT-FIELDNAME = 'TIPO'.
IT_SORT-TABNAME = 'IT_HEADER'.
IT_SORT-GROUP = 'X'.
IT_SORT-UP = 'X'.
IT_SORT-DOWN = ' '.
IT_SORT-SUBTOT = ' '.
APPEND IT_SORT. CLEAR IT_SORT.
ENDFORM. " FO_SORT
*& Form FO_FIELDCAT
FORM FO_FIELDCAT.
CLEAR IT_FIELD.
IT_FIELD-TABNAME = 'IT_ITEM'.
IT_FIELD-FIELDNAME = 'TIPO'.
IT_FIELD-COL_POS = '1'.
IT_FIELD-JUST = 'L'.
IT_FIELD-SELTEXT_L = 'Tipo Material'.
IT_FIELD-KEY = 'X'.
APPEND IT_FIELD.
CLEAR IT_FIELD.
IT_FIELD-TABNAME = 'IT_ITEM'.
IT_FIELD-FIELDNAME = 'MATERIAL'.
IT_FIELD-COL_POS = '2'.
IT_FIELD-JUST = 'L'.
IT_FIELD-SELTEXT_L = 'Codigo Material'.
APPEND IT_FIELD.
CLEAR IT_FIELD.
IT_FIELD-TABNAME = 'IT_ITEM'.
IT_FIELD-FIELDNAME = 'MATKL'.
IT_FIELD-COL_POS = '3'.
IT_FIELD-JUST = 'L'.
IT_FIELD-SELTEXT_L = 'Grupo De Articulos'.
APPEND IT_FIELD.
CLEAR IT_FIELD.
IT_FIELD-TABNAME = 'IT_ITEM'.
IT_FIELD-FIELDNAME = 'MEINS'.
IT_FIELD-COL_POS = '4'.
IT_FIELD-JUST = 'L'.
IT_FIELD-SELTEXT_L = 'Uni. Med. Base'.
APPEND IT_FIELD.
CLEAR IT_FIELD.
IT_FIELD-TABNAME = 'IT_ITEM'.
IT_FIELD-FIELDNAME = 'MAKTX'.
IT_FIELD-COL_POS = '5'.
IT_FIELD-JUST = 'L'.
IT_FIELD-outputlen = '40'.
IT_FIELD-SELTEXT_L = 'Descriptivo'.
APPEND IT_FIELD.
ENDFORM. " FO_FIELDCAT
*& Form FO_EVENTOS
FORM FO_EVENTOS USING PIT_EVENTS type slis_t_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = PIT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
read table PIT_EVENTS with key name = SLIS_EV_TOP_OF_PAGE
into ls_event.
if sy-subrc = 0.
move gc_formname_top_of_page to ls_event-form.
append ls_event to pIT_EVENTS.
endif.
CLEAR LS_EVENT.
ENDFORM. " FO_EVENTOS
*& FORM top_of_page *
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ZLOGO_GRUPO_POLAR'
IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE.
ENDFORM. "TOP_OF_PAGE
*& Form FO_FILTRAR
FORM FO_FILTRAR.
*IT_FILTER-FIELDNAME = 'TIPO'.
*IT_FILTER-TABNAME = 'IT_HEADER'.
*APPEND IT_FILTER. CLEAR IT_FILTER.
ENDFORM. " FO_FILTRAR
*& Form USER_COMMAND
FORM USER_COMMAND USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
READ TABLE IT_ITEM INDEX SELFIELD-TABINDEX.
IF SY-SUBRC EQ 0.
ENDIF.
ENDFORM. " USER_COMMAND
Regards
Gregory
Similar Messages
-
I wnat to add new fieldtext in the alv list output plz tell me
hi,
i whant add new fieldtext in the list output, plz tell me where can i modify it.
CORRECTIONS
DATE CORRECTION NOTE AUTHOR DESCRIPTION
09.03.2001 L9CK045451 0388404 XSC Wrong list output for multiple Os
05.06.2001 AL0K023393 0410219 Lud Wrong keydate for search with
Pchbegda and pchendda.
22.04.2004 S6BK024775 730486 PS Too many selection parameters in
header
19.06.2006 S6BK035494 956731 JF No sorting by qualification
REPORT RHPK_FIND_PERS_WITH_EXPIRED_QU MESSAGE-ID PQ.
DATA AUFRUF(8).
TABLES : OBJEC, GDSET.
DATA LIST.
DATA MARKFIELD(1) TYPE C.
ALV_POOL
TYPE-POOLS SLIS.
INCLUDES
INCLUDE .
INCLUDE RHPEINI0.
TABLES
DATA: orgeh_BUFFER like hrobject OCCURS 1 WITH HEADER LINE.
DATA: OBJECTS LIKE HRSOBID OCCURS 1 WITH HEADER LINE.
DATA: h_OBJEC LIKE objec OCCURS 0 WITH HEADER LINE.
DATA: pers_objects LIKE HRSOBID OCCURS 1 WITH HEADER LINE.
DATA: QUALI_TAB LIKE QUALI_PROF OCCURS 1 WITH HEADER LINE.
DATA: PERSONS LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA: H_PERSONS LIKE HRPE_PROFL OCCURS 1 WITH HEADER LINE.
DATA: LIST_OUTPUT LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA: BOOK_EVENT_TAB LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA: PLAN_EVENT_TAB LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA H_SUITED LIKE DYNP_PCRIT-SUITED.
DATA: O_COLOR LIKE STREEATTR-COLOR.
DATA: O_INTENSIV LIKE STREEATTR-INTENSIV.
DATA SHOW_KEY.
DATA EVENT.
DATA: HTEXT LIKE P1000-STEXT.
DATA: EVENT_TAB LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA: COLLECTED_EVENTS LIKE PERSQ_PROF OCCURS 1 WITH HEADER LINE.
DATA: SUBTY_TAB LIKE HRPE_OTYPE_SUBTY OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF HIDE_STRU,
PERSTYPE LIKE HROTYPE-OTYPE,
PERSOBID LIKE HRSOBID-SOBID,
PERSTXT LIKE PERSQ_PROF-STEXT,
SCALE_ID LIKE HRPE_PROFQ-SCALE_ID,
TRAININGTYPE LIKE HRP1000-OTYPE,
TRAININGID LIKE HRP1000-OBJID,
TRAININGSTXT LIKE HRP1000-STEXT,
QUALID LIKE QUALI_PROF-QUALID,
QUALTEXT LIKE QUALI_PROF-QUALSTXT,
END OF HIDE_STRU.
DATA: BEGIN OF EXTAB OCCURS 10,
FCODE LIKE RSMPE-FUNC,
END OF EXTAB.
DATA: CURRENT_QUALID LIKE QUALI_PROF-QUALID.
DATA: CURRENT_TRAININGSID LIKE HRP1000-OBJID.
DATA: CURRENT_TRAININGTYPE LIKE HRP1000-OTYPE.
DATA: SUBRC LIKE SY-SUBRC.
VARIABLES
DATA: OBJID LIKE P1000-OBJID.
DATA: H_LINE_COUNT TYPE I.
DATA: H_TABIX1 LIKE SY-TABIX.
ALV-Variables
DATA: alv_events_line TYPE slis_alv_event. "header line
DATA ALV_EVENTS TYPE SLIS_T_EVENT.
DATA GT_ALV_LIST_TOP_OF_LIST TYPE SLIS_T_LISTHEADER.
DATA: gt_events TYPE SLIS_T_EVENT.
DATA G_REPID LIKE SY-REPID.
DATA G_VARIANT LIKE DISVARIANT.
DATA ALV_USERCOMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA G_USERCOMMAND_FOR_RANKINGLIST TYPE SLIS_FORMNAME VALUE
'USER_COMMAND_FOR_RANKINGLIST'.
DATA ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: ALV_OUTPUT LIKE HRPDV_EXPIRED_Q OCCURS 0 WITH HEADER LINE.
DATA: Help_OUTPUT LIKE HRPDV_EXPIRED_Q OCCURS 0 WITH HEADER LINE.
begin of Dynpro 5020 - POPUP: WEITER
DATA: OK_CODE_5020 LIKE SY-UCOMM.
DATA: NO_ORG. "if no org selected
DATA: H_TABIX LIKE SY-TABIX.
begin of Dynpro 20nn - Header
TABLES: DYNP_RHPP.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-005.
PARAMETERS:
H_EVENTS LIKE DYNP_RHPP-GEN_TRAIN, "with training sugg
H_QUAL LIKE DYNP_RHPP-EXPIRED_QUAL. "with Qual
SELECTION-SCREEN END OF BLOCK B3.
INITIALIZATION
INITIALIZATION.
PERFORM READ_T77S0_PARAMETERS_FOR_PE.
get user parameters/Planvariante und Beginndatum setzen:
PCHOTYPE = $ORGEH.
CALL FUNCTION 'RHP0_USER_PARAMETERS_GET'
EXPORTING
FILL_IF_INITIAL = 'X'
IMPORTING
PLVAR = PCHPLVAR
BEGDA = PCHBEGDA
endda = Pchendda "Correction 0410219
WITH_KEY = SHOW_KEY
SUBSTITUTE =
ESSENTIAL = only_essential
ORG_UNIT = PCHOBJID-LOW
EXCEPTIONS
OTHERS = 0.
PCHBEGDA = LOW_DATE. "Correction note: 0410219 / AL0K023393
get menu text for key on/off
PERFORM USER_MENU_TEXT_KEY(SAPLRHP0) USING G_MENU_TEXT_KEY.
start-of-selection
START-OF-SELECTION.
terminate the selection if objid isn't given
READ TABLE PCHOBJID INDEX 1 TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0
AND PCHOBJID IS INITIAL.
PCHOBJID-SIGN = 'I'.
PCHOBJID-OPTION = 'EQ'.
PCHOBJID-LOW = '00000001'.
APPEND PCHOBJID.
NO_ORG = TRUE.
ELSE.
NO_ORG = FALSE.
ENDIF.
GET OBJEC.
terminate the selection if objid isn't given
IF NO_ORG = TRUE.
EXIT.
ENDIF.
OBJECTS-PLVAR = PCHPLVAR.
OBJECTS-OTYPE = PCHOTYPE.
OBJECTS-SOBID = OBJEC-REALO.
APPEND OBJECTS.
Für das lesen der Organisationseinheit
h_OBJEC-PLVAR = OBJEC-PLVAR.
h_OBJEC-OTYPE = OBJEC-OTYPE.
h_OBJEC-OBJID = OBJEC-objid.
append h_objec.
Read table h_objec index 1 transporting no fields.
if sy-subrc = 0.
Fill Buffer
orgeh_BUFFER = h_OBJEC.
orgeh_BUFFER[] = h_OBJEC[].
CALL FUNCTION 'RH_TEXT_BUFFER_FILL'
TABLES
OBJECTS = orgeh_BUFFER.
Loop at h_OBJEC.
H_TABIX = SY-TABIX.
Read text of organisation
CALL FUNCTION 'RH_READ_OBJECT'
EXPORTING
PLVAR = h_OBJEC-plvar
OTYPE = h_OBJEC-otype
OBJID = h_OBJEC-OBJID
IMPORTING
OBEG = h_objec-begda
OEND = h_objec-endda
SHORT = short
STEXT = h_OBJEC-stext
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
modify h_OBJEC index H_TABIX.
ENDIF.
endloop.
endif.
end-of-selection
END-OF-SELECTION.
read objects of the organizational unit
OBJID = OBJECTS-SOBID.
CALL FUNCTION 'RHPH_PICK_UP_PERSONS'
EXPORTING
BEGDA = PCHBEGDA "Correction 0410219
ENDDA = PCHENDDA "Correction 0410219
STATUS = '1'
WITH_STEXT = 'X'
TABLES
OBJECTS = OBJECTS
PERSONS = H_PERSONS
EXCEPTIONS
UNDEFINED = 1
OTHERS = 2.
IF SY-SUBRC = 0.
prepare objects !
objects-otype = h_persons-ttype.
objects-sobid = h_persons-tobid.
append objects.
ELSE.
EXIT.
ENDIF.
CLEAR OBJECTS. REFRESH OBJECTS.
prepare sel_objects !
pers_objects-PLVAR = PCHPLVAR.
LOOP AT H_PERSONS.
pers_objects-OTYPE = H_PERSONS-TTYPE.
pers_objects-SOBID = H_PERSONS-TOBID.
APPEND pers_objects.
ENDLOOP.
sort objects and delete adjacent duplicates
SORT Pers_OBJECTS BY PLVAR OTYPE SOBID.
DELETE ADJACENT DUPLICATES FROM Pers_OBJECTS COMPARING PLVAR OTYPE
SOBID.
CALL FUNCTION 'RHPK_FIND_PERS_WITH_EXPIRED_Q'
EXPORTING
PLVAR = PCHPLVAR
CHECK_BEGDA = PCHBEGDA
CHECK_ENDDA = PCHENDDA
SUBTY = $ownsb "'B032'
only_essential =
target_otype =
target_ap_iea =
TABLES
IMP_PER_TAB = pers_objects
QUALI_TAB = QUALI_TAB
PERSONS = LIST_OUTPUT
altq_tab =
EXCEPTIONS
NO_QUALIFICATION = 1
NO_PERSON_FOUND = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
100% case
READ TABLE pers_objects INDEX 1 TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
sort pers_objects by otype sobid.
check the selected persons: if org.unit was selected !
Loop at pers_objects.
H_TABIX = SY-TABIX.
READ TABLE LIST_OUTPUT WITH KEY OTYPE = pers_objects-OTYPE
SOBID = pers_objects-SOBID
BINARY SEARCH.
IF SY-SUBRC <> 0.
person doesn't belong to the selected org.unit
DELETE LIST_OUTPUT INDEX H_TABIX.
ENDIF.
ENDLOOP.
ENDIF. "org.unit check needed ?
end-of-selection.
sort h_objec by otype objid.
sort list_output by otype sobid.
sort h_persons by ttype tobid.
ALV-Liste aufbauen
loop at h_objec.
loop at h_persons where otype = h_objec-otype "XSC
and sobid = h_objec-objid. "XSC
Read table list_output with key
otype = h_persons-ttype
sobid = h_persons-tobid
binary search.
if sy-subrc = 0.
h_tabix1 = sy-tabix.
while sy-subrc = 0.
clear alv_output. "XSC
ALV_OUTPUT-otype = h_objec-otype.
ALV_OUTPUT-sobid = h_objec-objid.
ALV_OUTPUT-stext = h_objec-stext.
ALV_OUTPUT-Ptype = LIST_OUTPUT-otype.
ALV_OUTPUT-pobid = LIST_OUTPUT-sobid.
ALV_OUTPUT-pshort = LIST_OUTPUT-short.
ALV_OUTPUT-ptext = LIST_OUTPUT-stext.
ALV_OUTPUT-qualid = LIST_OUTPUT-qualid.
ALV_OUTPUT-qualstxt = LIST_OUTPUT-qualstxt.
ALV_OUTPUT-expbegda = LIST_OUTPUT-vbegda.
ALV_OUTPUT-expendda = LIST_OUTPUT-vendda.
PERFORM FIND_TRAINING TABLES QUALI_TAB EVENT_TAB COLLECTED_EVENTS
USING $PLVAR $GDATE H_EVENTS H_QUAL.
IF NOT EVENT_TAB[] IS INITIAL.
READ TABLE COLLECTED_EVENTS WITH KEY
QUALID = LIST_OUTPUT-QUALID.
IF SY-SUBRC = 0.
ALV_OUTPUT-ICON_S_EVENTS = ICON_BOOKEVENT.
endif.
ENDIF.
Append ALV_OUTPUT.
h_tabix1 = h_tabix1 + 1.
READ TABLE list_output INDEX h_tabix1
COMPARING otype sobid.
endwhile.
endif.
endloop.
endloop.
check if indicator for qualification view is set
IF h_qual = 'X'. "note 956731
SORT alv_output by qualid OTYPE SOBID ptype pobid "note 956731
expbegda expendda. "note 956731
ELSE. "note 956731
SORT alv_output by OTYPE SOBID ptype pobid qualid expbegda expendda.
ENDIF. "note 956731
DELETE ADJACENT DUPLICATES FROM ALV_OUTPUT COMPARING OTYPE SOBID ptype
pobid qualid expbegda expendda.
stext_AQ und icon-Feld noch nicht gefüllt
perform PREPARE_TOP_OF_LIST.
perform Build_FIELDCAT using GT_FIELDCAT[] H_EVENTS.
perform ALV_LAYOUT USING alv_layout.
G_REPID = SY-REPID.
G_VARIANT-REPORT = G_REPID.
PERFORM EVENTTAB_BUILD USING GT_EVENTS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = 'X'
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = ALV_USERCOMMAND
I_STRUCTURE_NAME = 'HRPDV_EXPIRED_Q'
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = G_VARIANT
IT_EVENTS = GT_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ALV_OUTPUT
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.
*& Form FIND_TRAINING
text
-->P_QUALI_TAB text
-->P_EVENT_TAB text
-->P_$PLVAR text
-->P_GDATE text
-->P_H_EVENT text
-->P_H_QUAL text
FORM FIND_TRAINING TABLES P_QUALI_TAB STRUCTURE QUALI_TAB
P_EVENT_TAB STRUCTURE EVENT_TAB
P_COLLECTED_EVENTS STRUCTURE COLLECTED_EVENTS
USING VALUE(P_$PLVAR) LIKE P1000-PLVAR
VALUE(P_GDATE) LIKE P1000-GDATE
VALUE(P_H_EVENT) TYPE ANY
VALUE(P_H_QUAL) TYPE ANY.
IF NOT P_H_EVENT IS INITIAL.
READ TABLE EVENT_TAB INDEX 1 TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
CLEAR P_EVENT_TAB. REFRESH EVENT_TAB.
CLEAR P_COLLECTED_EVENTS. REFRESH P_COLLECTED_EVENTS.
IF EVENT = FALSE.
EVENT = TRUE.
ELSE.
EVENT = FALSE.
ENDIF.
CALL FUNCTION 'RHPH_FIND_TRAINING_FOR_QUAL'
EXPORTING
PLVAR = PCHPLVAR
GDATE = SY-DATUM
GET_NAME = 'X'
TABLES
QUALI_TAB = QUALI_TAB
TO_Q_TAB = EVENT_TAB
EXCEPTIONS
NO_QUALIFICATION = 1
NO_OBJECT_FOUND = 2
TECHNICAL_ERROR = 3
OTHERS = 4.
IF SY-SUBRC = 0.
the found qualifications are picked up into table event_tab
ENDIF.
IF SY-SUBRC = 1.
MESSAGE S015. "Zu den Eingaben wurden keine Daten gefunden
ENDIF.
IF SY-SUBRC > 2.
EXIT.
ENDIF.
collect events when there are double.
Veranstaltungen kollektieren, Können mehrfach auftauchen, da
verschiedenen Qualifikationen von gleichen Veranstaltungen vermittelt
LOOP AT P_EVENT_TAB INTO P_COLLECTED_EVENTS.
APPEND P_COLLECTED_EVENTS.
ENDLOOP.
SORT P_COLLECTED_EVENTS BY QUALID STEXT.
ENDIF.
ENDIF.
ENDFORM. " FIND_TRAINING
*& Form PREPARE_TOP_OF_LIST
text
--> p1 text
<-- p2 text
FORM PREPARE_TOP_OF_LIST.
DATA ALV_TOP_OF_LIST TYPE SLIS_LISTHEADER. "typ, key, info
DATA STEXT LIKE HRPDV_SUCCESSOR_VIEW-TTEXT.
DATA P_SUBRC LIKE SY-SUBRC.
DATA P_STEXT LIKE T777O-OTEXT.
DATA l_tabix like sy-tabix value 0.
DATA: h_counter TYPE i. "note 730486
ALV_TOP_OF_LIST-TYP = 'H'.
ALV_TOP_OF_LIST-INFO = TEXT-REQ.
APPEND ALV_TOP_OF_LIST TO GT_ALV_LIST_TOP_OF_LIST.
Organisationseinheit
ALV_TOP_OF_LIST-typ = 'S'.
Read text for organisationunit
PERFORM READ_TEXT_OTYPE_T777O(SAPLRHP0) USING SY-LANGU $ORGEH
P_STEXT P_SUBRC.
ALV_TOP_OF_LIST-key = P_STEXT.
fill buffer for read organisation-text
CALL FUNCTION 'RH_TEXT_BUFFER_FILL'
EXPORTING
CHECK_STRU_AUTH = 'X'
WITH_EXTINT = ' '
TABLES
OBJECTS = OBJECTS.
loop at objects for multipleselection
clear h_counter. "note 730486
LOOP AT OBJECTS.
$OBJID = OBJECTS-SOBID.
CALL FUNCTION 'RH_READ_OBJECT'
EXPORTING
PLVAR = OBJECTS-PLVAR
OTYPE = OBJECTS-OTYPE
OBJID = $OBJID
IMPORTING
SHORT = short
STEXT = STEXT
EXCEPTIONS
NOT_FOUND = 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.
IF h_counter >= 15. "note 730486
MOVE '( ... )' TO ALV_TOP_OF_LIST-INFO. "note 730486
APPEND ALV_TOP_OF_LIST TO gt_alv_list_top_of_list.
"note 730486
EXIT. "note 730486
ENDIF. "note 730486
CONCATENATE $ORGEH OBJECTS-SOBID STEXT INTO
ALV_TOP_OF_LIST-INFO SEPARATED BY SPACE.
APPEND ALV_TOP_OF_LIST TO GT_ALV_LIST_TOP_OF_LIST.
CLEAR ALV_TOP_OF_LIST.
ALV_TOP_OF_LIST-typ = 'S'.
l_tabix = l_tabix + 1.
ADD 1 TO h_counter. "note 730486
ENDLOOP.
CLEAR ALV_TOP_OF_LIST.
ALV_TOP_OF_LIST-TYP = 'S'.
ALV_TOP_OF_LIST-key = TEXT-003.
WRITE PCHBEGDA TO ALV_TOP_OF_LIST-INFO.
APPEND ALV_TOP_OF_LIST TO GT_ALV_LIST_TOP_OF_LIST.
clear ALV_TOP_OF_LIST-INFO.
ALV_TOP_OF_LIST-key = TEXT-004.
WRITE PCHENDDA TO ALV_TOP_OF_LIST-INFO.
Append ALV_TOP_OF_LIST TO GT_ALV_LIST_TOP_OF_LIST.
ENDFORM. " PREPARE_TOP_OF_LIST
*& Form BUILD_FIELDCAT
text
-->P_GT_FIELDCAT[] text
FORM BUILD_FIELDCAT USING P_GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV
P_H_EVENTS.
DATA: WA_FIELDCAT LIKE LINE OF P_GT_FIELDCAT.
DATA: P_REPNAME LIKE SY-REPID,
L_TABIX LIKE SY-TABIX. "local variable for sy-tabix.
P_REPNAME = SY-REPID.
Erstellen des Feldkataloges
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = P_REPNAME
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'HRPDV_EXPIRED_Q'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = PRONAME
CHANGING
CT_FIELDCAT = P_GT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 0
PROGRAM_ERROR = 0
OTHERS = 0.
LOOP AT P_GT_FIELDCAT INTO WA_FIELDCAT.
l_tabix = sy-tabix.
CASE WA_FIELDCAT-FIELDNAME.
when 'OTYPE'.
WA_FIELDCAT-DDICTXT = 'L'.
when 'SOBID'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'STEXT'.
WA_FIELDCAT-DDICTXT = 'L'.
when 'PTYPE'.
WA_FIELDCAT-DDICTXT = 'L'.
when 'POBID'.
WA_FIELDCAT-DDICTXT = 'L'.
when 'PSHORT'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'PTEXT'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'QUALID'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'QUALSTXT'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'EXPBEGDA'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'EXPENDDA'.
WA_FIELDCAT-DDICTXT = 'L'.
WHEN 'ICON_S_EVENTS'.
IF P_H_EVENTS IS INITIAL.
WA_FIELDCAT-NO_OUT = 'X'.
else.
WA_FIELDCAT-DDICTXT = 'X'.
endif.
ENDCASE.
MODIFY P_GT_FIELDCAT FROM WA_FIELDCAT INDEX l_tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCAT
*& Form ALV_LAYOUT
text
-->P_L_ALV_LAYOUT text
FORM ALV_LAYOUT USING P_ALV_LAYOUT TYPE slis_layout_alv.
build layout
P_LAYOUT-BOX_FIELDNAME = 'MARK_X'. "fieldname for checkbox
P_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
P_ALV_LAYOUT-BOX_TABNAME = ALV_OUTPUT. "tabname for checkbox
p_ALV_layout-info_fieldname = 'ALV_COLOR'.
ENDFORM. " ALV_LAYOUT
FORM eventtab_build USING
FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
MOVE 'TOP_OF_PAGE' TO LS_EVENT-NAME.
MOVE 'TOP_OF_PAGE' TO LS_EVENT-FORM.
APPEND LS_EVENT TO RT_EVENTS.
ENDFORM. "EVENTTAB_BUILD
*FORM TOP_OF_PAGE
FORM TOP_OF_PAGE. "#EC CALLED
NEW-PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_ALV_LIST_TOP_OF_LIST[].
ENDFORM. "TOP_OF_PAGE
FORM USER_COMMAND *
USER_COMMAND for the list of successor view *
--> r_ucomm *
--> rs_selfield *
FORM USER_COMMAND USING ALV_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED
DATA: SELECTED_LINE LIKE HRPDV_expired_q.
DATA: SOBID_QUA LIKE P1000-OBJID.
DATA: LT_PERS_TAB LIKE HRSOBID OCCURS 0 WITH HEADER LINE.
CASE ALV_UCOMM.
WHEN '&IC1'. "per Doppelklick auswählen
READ TABLE ALV_OUTPUT INDEX
RS_SELFIELD-TABINDEX INTO SELECTED_LINE.
CASE RS_SELFIELD-FIELDNAME.
WHEN 'POTYPE' or 'POBID' or 'PTEXT' or 'OTYPE' or 'SOBID' or
'STEXT' or 'QUALID' or 'QUALSTXT' or 'EXPBEGDA' or 'EXPENDDA'.
READ TABLE ALV_OUTPUT INDEX RS_SELFIELD-TABINDEX INTO
Help_output.
IF SY-SUBRC <> 0.
MESSAGE S027. "Bitte gültige Zeile auswählen
EXIT.
Endif.
IF ALV_OUTPUT-SOBID IS INITIAL.
MESSAGE S015. "Zu den Eingaben wurden keine Daten gefunden
ELSE.
converte the variable because of the different types
SOBID_QUA = SELECTED_LINE-SOBID_QUA.
CALL FUNCTION 'RHPP_SHOW_PROFILE'
EXPORTING
PLVAR = pchplvar
OTYPE = SELECTED_LINE-PTYPE "XSC
OBJID = SELECTED_LINE-POBID "XSC
BEGDA = PCHBEGDA
ENDDA = PCHENDDA
MAINTAIN = ' '
EXCEPTIONS
NO_AUTHORITY = 1
NOT_FOUND = 2
OTHERS = 3.
CASE SY-SUBRC.
WHEN 0.
All right.
WHEN 1.
MESSAGE S015.
Zu Ihren Eingaben konnten keine Daten gefunden werden!
WHEN 2.
MESSAGE E000.
Dazu haben sie keine berechtigung!
WHEN OTHERS.
MESSAGE E008.
Es ist ein unvorhergesehener Fehler aufgetreten.
ENDCASE. "sy-subrc.
CLEAR ALV_OUTPUT.
ENDIF. "IF ALV_OUTPUT-SOBID IS INITIAL.
CLEAR ALV_OUTPUT-SOBID.
when 'ICON_S_EVENTS'.
IF SELECTED_LINE-ICON_S_EVENTS IS INITIAL.
MESSAGE S027. "Bitte gültige Zeile auswählen
EXIT.
ENDIF.
CLEAR LT_PERS_TAB.
REFRESH LT_PERS_TAB.
LT_PERS_TAB-PLVAR = pchPLVAR.
LT_PERS_TAB-OTYPE = SELECTED_LINE-PTYPE. "XSC
LT_PERS_TAB-SOBID = SELECTED_LINE-POBID. "XSC
APPEND LT_PERS_TAB.
SOBID_QUA = SELECTED_LINE-QUALID.
CALL FUNCTION 'RHPP_SHOW_SUGGEST_EVENTS'
EXPORTING
P_PLVAR = pchPLVAR
P_SOBID_QUA = SOBID_QUA
P_PROFCY_REQ = SELECTED_LINE-RATING_REQ
P_GDATE = sy-datum
TABLES
EVENT_TAB =
PERS_TAB = LT_PERS_TAB.
endcase.
CLEAR SELECTED_LINE.
ENDCASE. "case sy-ucomm
CLEAR SY-UCOMM.
ENDFORM. "USER_COMMANDPls be more specific in your question. If you want to include an extra field in your alv output, then read the field catalog table you created through "Reuse_alv_fieldcatalog_merge" and then add an extra entry in it giving the details of the field you want to add.. and then call the "resuse_alv_grid_display",
Hope this helps. To be able to help you in a better way, kindly revert with any specific issue.
Reward if helpful,
Karan -
Create a Procedural ALV Report with editable fields and save the changes
Hi,
I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EDITABLE
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
But all these are using OO Concepts.
Please help.
Regards,
SmruthiTABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-edit = 'X'
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
LOOP AT it_ekko INTO wa_ekko.
ld_color = ld_color + 1.
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
FORM top-of-page *
FORM top-of-page.
WRITE:/ 'This is First Line of the Page'.
ENDFORM.
FORM status *
FORM status USING rt_extab TYPE slis_t_extab. .
SET PF-STATUS 'ALV'.
ENDFORM.
FORM USER_COMMAND *
--> RF_UCOMM *
--> RS *
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
CASE rf_ucomm.
when 'SAVE'.
get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
endcase.
endform.
ENDFORM.
here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
create a custom PF status and create push buttons and assign your ok codes in your PF status.
if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
Hope this will help you.
Regards,
phani. -
Change of count on the header on filtering the ALV
Hi Gurus!
I have this ALV report which gives the sales order report, in the output right on the top the report shows the count of all the distinct sales order displayed when the report is run based ona selection criteria. Is it possible to show the total count of teh sales order in the report to change and show teh number of distinct sales doc when we use filter on teh report. Suppose if we run the report based on a particular selection criteria and it gives a count of 30 . In the output if we put filter on a particular column and the report shows fewer lines , which will reduce the number of sales doc, is it possible to show this number which for eg will be say 20 , is it possible to show the number 20 after filetr on ALV instead of that 30 remainiung constant. I am wanting the report to show the change in count of distinct sales doc when I put filter on any columnh.
report zsales_orders message-id zsd no standard page heading.
* For ALV usage
type-pools: slis.
data: gs_layout type slis_layout_alv,
ta_events type slis_t_event_exit,
tp_event type slis_event_exit,
tp_print type slis_print_alv,
gt_sort type slis_t_sortinfo_alv,
gt_events type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv with header line,
repid type syrepid, " ABAP Program.
gt_list_top_of_page type slis_t_listheader, " Top of page text.
gs_list_top_of_page type slis_listheader,
alv_variant type disvariant. " Customize Disp. Variant
data: w_field type slis_fieldcat_alv.
data: count type i.
data: count1 type i.
tables: vbak, vbap, vbpa, knvv.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
selection-screen begin of block one with frame title text-001.
parameters: p_vkorg type vkorg obligatory memory id vko,"DEVK906677
p_vtweg type vtweg obligatory default '01',
p_spart type spart obligatory default '01'.
select-options: s_vkbur for vbak-vkbur, " Sales Office "DEVK906677
s_kunnr for vbak-kunnr. " Sold-to customer number.
select-options: s_shipto for vbap-oid_ship, " Ship-to customer number.
s_billto for vbpa-kunnr, " bill-to from S.O. header.
s_load for vbpa-kunnr, " Load confirmation contact.
s_truck for vbap-oid_extbol. " Trucking ticket number.
select-options: s_werks for vbap-werks obligatory no intervals. " Plant.
select-options: s_lgort for vbap-lgort. " Storage location.
select-options: s_matnr for vbap-matnr. " Material number.
select-options: s_konda for knvv-konda. " price group
selection-screen skip 1.
select-options: s_vdatu for vbak-vdatu default sy-datum.
selection-screen end of block one.
* ALV display layout
selection-screen begin of block layout with frame title text-003.
parameters: pa_vari type slis_vari default ' '. " Display variant.
selection-screen end of block layout.
selection-screen begin of block two with frame title text-028.
selection-screen comment: /1(79) text-029.
selection-screen comment: /1(79) text-030.
selection-screen comment: /1(79) text-031.
selection-screen comment: /1(79) text-032.
selection-screen comment: /1(79) text-033.
selection-screen comment: /1(79) text-034.
selection-screen comment: /1(79) text-035.
selection-screen comment: /1(79) text-036.
selection-screen end of block two.
* Data Definitions *
* Storing Extracted Info.
types: begin of t_extract,
vbeln type vbeln_va, " Sales order number.
augru type augru, " order reason
vdatu type edatu_vbak, " Requested delivery date.
kunnr type kunag, " Sold-to customer number.
soldto_name type name1_gp, " Sold-to name.
posnr type posnr_va, " Item number.
matnr type matnr, " Material number.
vrkme type vrkme, " Sales UoM.
mseh3 type mseh3, " UoM text.
netwr type netwr_ap, " Net value of the order item.
kwmeng type p length 13 decimals 1, " Quantity.
werks type werks_d, " Plant.
lgort type lgort_d, " Storage location.
oid_extbol type oid_extbol, " External BOL or truck ticker header.
maktx type maktx, " Material description.
oid_ship type kunwe, " Ship-to customer number.
shipto_name type name1_gp, " Ship-to name.
billto type kunre, " Bill-to customer number.
billto_name type name1_gp, " Bill-to name.
load_contact type kunnr, " Load confirmation contact.
load_name type name1_gp, " Load confirmation contact name.
truck type kunnr, " Truck company number.
truck_name type name1_gp, " Truck company name.
bstkd type bstkd, " PO number.
ihrez type ihrez, " AFE number per the contract/sales order.
delivery type vbeln_vl, " Delivery number.
posnr_vl type posnr_vl, " Delivery item number.
bill_vbeln type vbeln_vf, " Invoice number.
bill_posnr type posnr_vf, " Invoice item number.
bill_netwr type netwr_fp, " Invoice net value.
statu type stats, " Document status.
auart type auart, " order type
vkorg type vkorg, " sales org.
vtweg type vtweg, " distrbtn channel
spart type spart, " division
vkbur like vbak-vkbur, " Sales Office DEVK906677
konda type konda, " price group
tdline type tdline, " text for customer account reference
count type i,
end of t_extract.
data : it_extract type table of t_extract with header line,
it_extract2 type table of t_extract with header line.
data: it_text type table of tline with header line.
data: w_index type sy-index,
w_tdname type tdobname.
constants: c_minus1 type netwr_ap value '1.00-'.
*RANGES: r_auart FOR vbak-auart.
data: r_auart type range of t_extract-auart,
r_auart_line like line of r_auart.
* initialization
initialization.
tp_event-ucomm = '&ILT'. " Filter event.
tp_event-after = 'X'.
append tp_event to ta_events.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
perform set_fieldcat.
perform alv_eventtab_build using:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* changed to exclude following order types
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZEQ'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* credit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* debit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRD'.
clear r_auart_line-high.
append r_auart_line to r_auart.
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZDR'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Industry sales order correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZSOC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield FF correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCF'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield WP correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCW'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Dropdown list for all created ALV layouts, global or user-specific
at selection-screen on value-request for pa_vari.
perform alv_variant_f4 changing pa_vari.
* Main BODY of processing logic
start-of-selection.
perform extract_data.
end-of-selection.
if not it_extract[] is initial.
* Build headings for report.
perform build_top_of_page using gt_list_top_of_page[].
perform call_alv.
endif.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
form extract_data.
clear: it_extract. refresh: it_extract.
* orders
select vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
into corresponding fields of table it_extract
from vbak inner join vbap
on vbak~mandt = vbap~mandt
and vbak~vbeln = vbap~vbeln where
vbak~auart not in r_auart and
vbak~vkorg eq p_vkorg and
vbak~vtweg eq p_vtweg and
vbak~spart eq p_spart and
vbak~vkbur in s_vkbur and "DEVK906677
vbak~vdatu in s_vdatu and
vbak~kunnr in s_kunnr and
vbap~matnr in s_matnr and
vbap~werks in s_werks and
vbap~lgort in s_lgort and
vbap~oid_extbol in s_truck and
vbap~oid_ship in s_shipto.
if sy-subrc <> 0.
message i000 with text-002 ' ' ' ' ' '.
endif.
sort it_extract by vbeln.
check sy-subrc = 0.
loop at it_extract.
* Retrieve and select by load confirmation contacts from header
select single kunnr from vbpa into it_extract-load_contact
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'ZB'.
if it_extract-load_contact in s_load.
it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
else.
delete it_extract.
continue.
endif.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
select single kunnr from vbpa into it_extract-billto
where vbeln = it_extract-vbeln
and posnr = '000000'
and parvw = 'RE'.
if sy-subrc = 0.
if s_billto is initial.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
if it_extract-billto in s_billto.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
delete it_extract.
continue.
endif.
endif.
else.
* Newalta - always has bill-to, following will not occur but included
* as good programming practice.
it_extract-billto_name = it_extract-billto.
endif.
* Retrieve and select by price group of sold-to
select single konda from knvv into it_extract-konda
where kunnr = it_extract-kunnr
and vkorg = it_extract-vkorg
and vtweg = it_extract-vtweg
and spart = it_extract-spart.
if sy-subrc = 0.
if not ( it_extract-konda in s_konda ).
delete it_extract.
continue.
endif.
endif.
* Retrieve trucking company customer
select single kunnr from vbpa into it_extract-truck where
vbeln = it_extract-vbeln and
posnr = '000000' and
parvw = 'ZT'.
if sy-subrc = 0.
it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
endif.
* Retrieve sold-to name
it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
* Retrieve ship-to name
it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
* lookup P.O.
select single bstkd ihrez from vbkd into (it_extract-bstkd, it_extract-ihrez)
where vbeln = it_extract-vbeln
and posnr = '000000'.
* Retreive the material description.
it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
* cosmetic change of material number, donot display leading zeros.
shift it_extract-matnr left deleting leading '0'.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
w_tdname = it_extract-vbeln.
* read customer account reference which is under 'text'
call function 'READ_TEXT'
exporting
client = sy-mandt
id = 'Z010'
language = sy-langu
name = w_tdname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = it_text
exceptions
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
others = 8.
if sy-subrc = 0.
read table it_text index 1.
if sy-subrc = 0.
it_extract-tdline = it_text-tdline.
else.
clear it_extract-tdline.
endif.
else.
clear it_extract-tdline.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
* Get the delivery item.
call method zcl_vbap=>get_delivery
exporting
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
importing
etp_vbeln = it_extract-delivery
etp_posnr = it_extract-posnr_vl.
if it_extract-delivery is not initial.
perform process_deliveries.
else.
perform invoice_process.
endif.
it_extract-count = 1 .
move-corresponding it_extract to it_extract2.
append it_extract2.
at new vbeln.
count1 = count1 + 1.
endat.
endloop.
endform. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
form set_fieldcat .
clear w_field.
clear t_fieldcat. refresh t_fieldcat.
w_field-col_pos = 1 .
w_field-fieldname = 'VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Document.Nbr'.
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 2 .
w_field-fieldname = 'POSNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Item'(023).
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 3 .
w_field-fieldname = 'VDATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Req. Del. Date'(005).
append w_field to t_fieldcat.
w_field-col_pos = 4. "DEVK909658
w_field-fieldname = 'KUNNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to.'(038).
append w_field to t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'SOLDTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to'(006).
append w_field to t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'MATNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Material'(007).
append w_field to t_fieldcat.
w_field-col_pos = 7 .
w_field-fieldname = 'KWMENG'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Quantity'(008).
append w_field to t_fieldcat.
w_field-col_pos = 8.
w_field-fieldname = 'MSEH3'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'UOM'(009).
append w_field to t_fieldcat.
w_field-col_pos = 9 .
w_field-fieldname = 'BILL_VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Invoice #'(010).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
append w_field to t_fieldcat.
clear w_field.
w_field-col_pos = 10 .
w_field-fieldname = 'BILL_NETWR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Values'(011).
append w_field to t_fieldcat.
w_field-col_pos = 11.
w_field-fieldname = 'WERKS'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Plant'(012).
append w_field to t_fieldcat.
w_field-col_pos = 12.
w_field-fieldname = 'LGORT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Storage Loc'(013).
append w_field to t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'MAKTX'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Description'(014).
append w_field to t_fieldcat.
w_field-col_pos = 14. "DEVK909658
w_field-fieldname = 'OID_SHIP'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to.'(039).
append w_field to t_fieldcat.
w_field-col_pos = 15 .
w_field-fieldname = 'SHIPTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to'(015).
append w_field to t_fieldcat.
w_field-col_pos = 16. "DEVK909658
w_field-fieldname = 'BILLTO'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to .'(040).
append w_field to t_fieldcat.
w_field-col_pos = 17 .
w_field-fieldname = 'BILLTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to'(016).
append w_field to t_fieldcat.
w_field-col_pos = 18 .
w_field-fieldname = 'LOAD_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Load Contact'(017).
append w_field to t_fieldcat.
w_field-col_pos = 19 .
w_field-fieldname = 'TRUCK_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Comp.'(018).
append w_field to t_fieldcat.
w_field-col_pos = 20 .
w_field-fieldname = 'BSTKD'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'P.O.'(019).
append w_field to t_fieldcat.
w_field-col_pos = 21 .
w_field-fieldname = 'IHREZ'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'AFE Nbr'(020).
append w_field to t_fieldcat.
w_field-col_pos = 22 .
w_field-fieldname = 'OID_EXTBOL'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Ticket'(021).
append w_field to t_fieldcat.
w_field-col_pos = 23.
w_field-fieldname = 'STATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Status'(022).
append w_field to t_fieldcat.
w_field-col_pos = 24.
w_field-fieldname = 'AUGRU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ord.Reason'(024).
append w_field to t_fieldcat.
w_field-col_pos = 25.
w_field-fieldname = 'TDLINE'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'cstmr.acct.ref.'(027).
append w_field to t_fieldcat.
w_field-col_pos = 26 . "DEVK906678
w_field-fieldname = 'VKBUR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sales Office'(037).
append w_field to t_fieldcat.
w_field-col_pos = 27. "DEVK909658
w_field-fieldname = 'COUNT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Count'(041).
w_field-do_sum = 'X'.
append w_field to t_fieldcat.
endform. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
form call_alv .
sort it_extract by lgort vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
it_event_exit = ta_events[]
is_print = tp_print
tables
t_outtab = it_extract2
exceptions
program_error = 1
others = 2.
if sy-subrc ne 0.
message w000 with text-004 ' ' ' ' ' '.
endif.
endform. " CALL_ALV
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
form build_top_of_page using e04_lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
data: w_selections(40) type c,
w_date_from(10) type c,
w_date_to(10) type c.
write: s_vdatu-low to w_date_from dd/mm/yyyy.
if s_vdatu-high is not initial.
write: s_vdatu-high to w_date_to dd/mm/yyyy.
clear w_selections.
concatenate 'Del.Req.Date: ' w_date_from 'To' w_date_to
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total Number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
else.
clear w_date_to.
concatenate 'Del.Req.Date: ' w_date_from
into w_selections separated by space.
clear ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
append ls_line to e04_lt_top_of_page.
endif.
endform. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
form alv_eventtab_build using u_name type slis_alv_event-name
u_form type slis_alv_event-form
alv_lt_events type slis_t_event.
data: ls_event type slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
append ls_event to alv_lt_events.
endform. " alv_eventtab_build
* FORM TOP_OF_PAGE *
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
endform. " TOP_OF_PAGE
*& Form process_deliveries
* Process the delivery related records.
form process_deliveries .
data:
ltp_date type wadat_ist, " Goods movement date.
ltp_vbtyp type vbtyp_n,
ltp_mtart type mtart, " Material type.
w_lfimg type lfimg, " Actual quantity delivered (in sales units).
w_vrkme type vrkme. " Sales unit of measure.
* Read delivery quantity and uom.
select single lfimg vrkme into (w_lfimg, w_vrkme)
from lips where
vbeln = it_extract-delivery and
posnr = it_extract-posnr_vl.
* these fields have values from vbap. override with lips values
if sy-subrc = 0.
it_extract-kwmeng = w_lfimg.
it_extract-vrkme = w_vrkme.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
endif.
* Determine STATUS by reading 'service confirmation', R (goods movemt)
* it is possible to have multiple 'service confirmation' records for
* one item. ie. delivery 80010390 in PRD.
* As long as there is at least one 'service confirmation' record,
* status is considered 'complete'.
* Validate the created on date of the goods movement or service confirmation.
ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
* ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
* itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
call method zcl_lips=>get_goods_mvt_info
exporting
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
itp_mtart = ltp_mtart
importing
rtp_date = ltp_date
rtp_vbtyp = ltp_vbtyp.
* 'h' is cancel goods issue
if ltp_vbtyp = 'h'.
it_extract-statu = 'Incomplete'(025).
else.
if ltp_date is not initial.
it_extract-statu = 'COMPLETE'(026).
endif.
endif.
* Retrieve the invoice/billing document item.
call method zcl_lips=>get_invoice
exporting
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
importing
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
endif.
endform. " process_deliveries
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ltp_vbeln type vbeln. " Sales document number.
case r_ucomm.
when '&IC1'.
if ( rs_selfield-fieldname = 'VBELN'
or rs_selfield-fieldname = 'BILL_VBELN' )
and rs_selfield-value is not initial. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
endif.
when '&ILT'.
data:
lta_filt type slis_t_filtered_entries.
break rdrury.
call function 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
importing
* es_layout = gs_layout
* et_fieldcat = t_fieldcat[]
* et_sort = gt_sort[]
* ES_LAYOUT =
* ET_FIELDCAT =
* ET_SORT =
* ET_FILTER =
* ES_LIST_SCROLL =
* ES_VARIANT =
* E_WIDTH =
* ET_MARKED_COLUMNS =
et_filtered_entries = lta_filt
* ET_FILTERED_ENTRIES_HEADER =
* ET_FILTERED_ENTRIES_ITEM = lta_filt
* TABLES
* et_outtab =
* ET_OUTTAB_HEADER =
* et_outtab_item =
* ET_COLLECT00 =
* ET_COLLECT01 =
* ET_COLLECT02 =
* ET_COLLECT03 =
* ET_COLLECT04 =
* ET_COLLECT05 =
* ET_COLLECT06 =
* ET_COLLECT07 =
* ET_COLLECT08 =
* ET_COLLECT09 =
exceptions
no_infos = 1
program_error = 2
endcase.
endform. "user_command
*& Form invoice_process
* Process for orders without deliveries. *
form invoice_process .
* Translate unit of measure.
select single mseh3 from t006a into it_extract-mseh3
where spras = sy-langu
and msehi = it_extract-vrkme.
* Retrieve the invoice/billing document item.
call method zcl_vbap=>get_invoice
exporting
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
importing
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
if it_extract-bill_vbeln is not initial.
* retrieve net value from the invoice.
clear it_extract-bill_netwr.
select single netwr into it_extract-bill_netwr from vbrp
where vbeln = it_extract-bill_vbeln
and posnr = it_extract-bill_posnr.
else. " If no Invoice, then status becomes 'incomplete'.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
it_extract-statu = 'Incomplete'(025).
endif.
endform. " invoice_process
*& Form alv_variant_f4
* Get the display variant.
* <--CTP_VARI Variant name
form alv_variant_f4 changing ctp_vari type slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = alv_variant
i_save = 'A'
importing
es_variant = alv_variant
exceptions
others = 1.
if sy-subrc = 0.
ctp_vari = alv_variant-variant.
endif.
endform. " alv_variant_f4I have used all the FM modules mentioned but I am not able to get the total of the sales doc on the top of the page to chnage when filtering of data is done . I just want to see this count of sales document (distict ) and to see it change as filtering is done , be it at any place in teh ALV , its not necessary that it has to be on the top of the ALV output. Could I get some inputs please. As you can see I used the below mentioned FM but on debugging I find the gt_stack is empty still.
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
FORM build_top_of_page USING e04_lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
DATA: w_selections(40) TYPE c,
w_date_from(10) TYPE c,
w_date_to(10) TYPE c.
WRITE: s_vdatu-low TO w_date_from DD/MM/YYYY.
IF s_vdatu-high IS NOT INITIAL.
WRITE: s_vdatu-high TO w_date_to DD/MM/YYYY.
CLEAR w_selections.
CONCATENATE 'Del.Req.Date: ' w_date_from 'To' w_date_to
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total Number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
ELSE.
CLEAR w_date_to.
CONCATENATE 'Del.Req.Date: ' w_date_from
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
ENDIF.
ENDFORM. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
FORM alv_eventtab_build USING u_name TYPE slis_alv_event-name
u_form TYPE slis_alv_event-form
alv_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
APPEND ls_event TO alv_lt_events.
ENDFORM. " alv_eventtab_build
* FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
Data:lt_FILTERED_ENTRIES type SLIS_T_FILTERED_ENTRIES,
wa_filter like line of lt_FILTERED_ENTRIES.
data: count2 type i.
data: it_fieldcat type slis_t_fieldcat_alv with header line.
CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
IMPORTING
ET_FILTERED_ENTRIES = lt_FILTERED_ENTRIES
EXCEPTIONS
NO_INFOS = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
MESSAGE i000 WITH count1 .
ENDIF.
loop at lt_FILTERED_ENTRIES into wa_filter.
* if sy-tabix <> 0.
if sy-subrc = 0 .
count2 = count2 + 1.
*count3 = count1 - count2 .
* write:/ 'Total number of Sales Documents =', count3 .
endif.
endloop.
ENDFORM. " TOP_OF_PAGE
I tried using it at user-command level too but it dosent help.
Thanks -
Chnaging the count of doucments on filtering
Hi I have this report which I have created which also gives the count of distinct documnets at the top-of page, on filtering that number dosent and wont change as that comes from the internal table , I need to show the count of actual number of documents in teh output after the filetring is done alos which will change as per the filtering is done . Is it possible to show a column or somewhere in teh out like the actual document number on top somewhere which will refrlet the actual number of documents in teh output after filter is done based on any of teh selection.
REPORT zztest MESSAGE-ID zsd NO STANDARD PAGE HEADING.
* For ALV usage
TYPE-POOLS: slis.
DATA: gs_layout TYPE slis_layout_alv,
tp_print TYPE slis_print_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_events TYPE slis_t_event,
t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
repid TYPE syrepid, " ABAP Program.
gt_list_top_of_page TYPE slis_t_listheader, " Top of page text.
gs_list_top_of_page type slis_listheader,
alv_variant TYPE disvariant. " Customize Disp. Variant
DATA: w_field TYPE slis_fieldcat_alv.
DATA: count type i.
DATA: count1 type i.
TABLES: vbak, vbap, vbpa, knvv.
* Definition of selection screen *
* By plant, storage location, sold-to customers, material and *
* posting date of the sales orders *
SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY MEMORY ID VKO,"DEVK906677
p_vtweg TYPE vtweg OBLIGATORY DEFAULT '01',
p_spart TYPE spart OBLIGATORY DEFAULT '01'.
SELECT-OPTIONS: s_vkbur for vbak-vkbur, " Sales Office "DEVK906677
s_kunnr FOR vbak-kunnr. " Sold-to customer number.
SELECT-OPTIONS: s_shipto FOR vbap-oid_ship, " Ship-to customer number.
s_billto FOR vbpa-kunnr, " bill-to from S.O. header.
s_load FOR vbpa-kunnr, " Load confirmation contact.
s_truck FOR vbap-oid_extbol. " Trucking ticket number.
SELECT-OPTIONS: s_werks FOR vbap-werks OBLIGATORY NO INTERVALS. " Plant.
SELECT-OPTIONS: s_lgort FOR vbap-lgort. " Storage location.
SELECT-OPTIONS: s_matnr FOR vbap-matnr. " Material number.
SELECT-OPTIONS: s_konda FOR knvv-konda. " price group
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_vdatu FOR vbak-vdatu DEFAULT sy-datum.
SELECTION-SCREEN END OF BLOCK one.
* ALV display layout
SELECTION-SCREEN BEGIN OF BLOCK layout WITH FRAME TITLE text-003.
PARAMETERS: pa_vari TYPE slis_vari DEFAULT ' '. " Display variant.
SELECTION-SCREEN END OF BLOCK layout.
SELECTION-SCREEN BEGIN OF BLOCK two WITH FRAME TITLE text-028.
selection-screen comment: /1(79) text-029.
selection-screen comment: /1(79) text-030.
selection-screen comment: /1(79) text-031.
selection-screen comment: /1(79) text-032.
selection-screen comment: /1(79) text-033.
selection-screen comment: /1(79) text-034.
selection-screen comment: /1(79) text-035.
selection-screen comment: /1(79) text-036.
SELECTION-SCREEN END OF BLOCK two.
* Data Definitions *
* Storing Extracted Info.
TYPES: BEGIN OF t_extract,
vbeln TYPE vbeln_va, " Sales order number.
augru TYPE augru, " order reason
vdatu TYPE edatu_vbak, " Requested delivery date.
kunnr TYPE kunag, " Sold-to customer number.
soldto_name TYPE name1_gp, " Sold-to name.
posnr TYPE posnr_va, " Item number.
matnr TYPE matnr, " Material number.
vrkme TYPE vrkme, " Sales UoM.
mseh3 TYPE mseh3, " UoM text.
netwr TYPE netwr_ap, " Net value of the order item.
kwmeng TYPE p LENGTH 13 DECIMALS 1, " Quantity.
werks TYPE werks_d, " Plant.
lgort TYPE lgort_d, " Storage location.
oid_extbol TYPE oid_extbol, " External BOL or truck ticker header.
maktx TYPE maktx, " Material description.
oid_ship TYPE kunwe, " Ship-to customer number.
shipto_name TYPE name1_gp, " Ship-to name.
billto TYPE kunre, " Bill-to customer number.
billto_name TYPE name1_gp, " Bill-to name.
load_contact TYPE kunnr, " Load confirmation contact.
load_name TYPE name1_gp, " Load confirmation contact name.
truck TYPE kunnr, " Truck company number.
truck_name TYPE name1_gp, " Truck company name.
bstkd TYPE bstkd, " PO number.
ihrez TYPE ihrez, " AFE number per the contract/sales order.
delivery TYPE vbeln_vl, " Delivery number.
posnr_vl TYPE posnr_vl, " Delivery item number.
bill_vbeln TYPE vbeln_vf, " Invoice number.
bill_posnr TYPE posnr_vf, " Invoice item number.
bill_netwr TYPE netwr_fp, " Invoice net value.
statu TYPE stats, " Document status.
auart TYPE auart, " order type
vkorg TYPE vkorg, " sales org.
vtweg TYPE vtweg, " distrbtn channel
spart TYPE spart, " division
vkbur like vbak-vkbur, " Sales Office DEVK906677
konda TYPE konda, " price group
tdline TYPE tdline, " text for customer account reference
count TYPE I,
END OF t_extract.
DATA : it_extract TYPE TABLE OF t_extract WITH HEADER LINE,
it_extract2 TYPE TABLE OF t_extract WITH HEADER LINE.
DATA: it_text TYPE TABLE OF tline WITH HEADER LINE.
DATA: w_index type sy-index,
w_tdname type TDOBNAME.
CONSTANTS: c_minus1 type netwr_ap value '1.00-'.
*RANGES: r_auart FOR vbak-auart.
Data: r_auart TYPE range of t_extract-auart,
r_auart_line like line of r_auart.
* initialization
INITIALIZATION.
gs_layout-colwidth_optimize = 'X'.
tp_print-no_print_listinfos = 'X'.
tp_print-no_coverpage = 'X'.
PERFORM set_fieldcat.
PERFORM alv_eventtab_build USING:
** Event name Form to execute Event internal table
'TOP_OF_PAGE' 'TOP_OF_PAGE' gt_events[].
* changed to exclude following order types
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZEQ'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* credit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* debit memo
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZPRD'.
clear r_auart_line-high.
append r_auart_line to r_auart.
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZDR'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Industry sales order correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZSOC'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield FF correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCF'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* oilfield WP correction
r_auart_line-sign = 'I'.
r_auart_line-option = 'EQ'.
r_auart_line-low = 'ZOCW'.
clear r_auart_line-high.
append r_auart_line to r_auart.
* Dropdown list for all created ALV layouts, global or user-specific
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
PERFORM alv_variant_f4 CHANGING pa_vari.
* Main BODY of processing logic
START-OF-SELECTION.
PERFORM extract_data.
END-OF-SELECTION.
IF NOT it_extract[] IS INITIAL.
* Build headings for report.
PERFORM build_top_of_page USING gt_list_top_of_page[].
PERFORM call_alv.
ENDIF.
*& Form EXTRACT_KEY_DATA
* Retreive the data for the report.
FORM extract_data.
CLEAR: it_extract. REFRESH: it_extract.
* orders
SELECT vbak~vbeln vbak~auart vbak~augru vbak~vkorg vbak~vtweg
vbak~spart vbak~vdatu vbak~kunnr vbak~vkbur
vbap~posnr vbap~matnr vbap~vrkme vbap~netwr vbap~kwmeng
vbap~werks vbap~lgort vbap~oid_extbol vbap~oid_ship
INTO CORRESPONDING FIELDS OF TABLE it_extract
FROM vbak INNER JOIN vbap
ON vbak~mandt = vbap~mandt
AND vbak~vbeln = vbap~vbeln WHERE
vbak~auart NOT IN r_auart AND
vbak~vkorg EQ p_vkorg AND
vbak~vtweg EQ p_vtweg AND
vbak~spart EQ p_spart AND
vbak~vkbur in s_vkbur and "DEVK906677
vbak~vdatu IN s_vdatu AND
vbak~kunnr IN s_kunnr AND
vbap~matnr IN s_matnr AND
vbap~werks IN s_werks AND
vbap~lgort IN s_lgort AND
vbap~oid_extbol IN s_truck AND
vbap~oid_ship IN s_shipto.
IF sy-subrc <> 0.
MESSAGE i000 WITH text-002 ' ' ' ' ' '.
ENDIF.
SORT it_extract BY vbeln.
CHECK sy-subrc = 0.
LOOP AT it_extract.
* Retrieve and select by load confirmation contacts from header
SELECT SINGLE kunnr FROM vbpa INTO it_extract-load_contact
WHERE vbeln = it_extract-vbeln
AND posnr = '000000'
AND parvw = 'ZB'.
IF it_extract-load_contact IN s_load.
it_extract-load_name = zcl_kna1=>get_name1( it_extract-load_contact ).
ELSE.
DELETE it_extract.
CONTINUE.
ENDIF.
* Retrieve and select by sales order bill-to on header level
* as well as lookup bill-to customer name/description
SELECT SINGLE kunnr FROM vbpa INTO it_extract-billto
WHERE vbeln = it_extract-vbeln
AND posnr = '000000'
AND parvw = 'RE'.
IF sy-subrc = 0.
if s_billto is initial.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
if it_extract-billto in s_billto.
it_extract-billto_name = zcl_kna1=>get_name1( it_extract-billto ).
else.
DELETE it_extract.
CONTINUE.
endif.
endif.
ELSE.
* Newalta - always has bill-to, following will not occur but included
* as good programming practice.
it_extract-billto_name = it_extract-billto.
ENDIF.
* Retrieve and select by price group of sold-to
SELECT SINGLE konda FROM knvv INTO it_extract-konda
WHERE kunnr = it_extract-kunnr
AND vkorg = it_extract-vkorg
AND vtweg = it_extract-vtweg
AND spart = it_extract-spart.
IF sy-subrc = 0.
IF NOT ( it_extract-konda IN s_konda ).
DELETE it_extract.
CONTINUE.
ENDIF.
ENDIF.
* Retrieve trucking company customer
SELECT SINGLE kunnr FROM vbpa INTO it_extract-truck WHERE
vbeln = it_extract-vbeln AND
posnr = '000000' AND
parvw = 'ZT'.
IF sy-subrc = 0.
it_extract-truck_name = zcl_kna1=>get_name1( it_extract-truck ).
ENDIF.
* Retrieve sold-to name
it_extract-soldto_name = zcl_kna1=>get_name1( it_extract-kunnr ).
* Retrieve ship-to name
it_extract-shipto_name = zcl_kna1=>get_name1( it_extract-oid_ship ).
* lookup P.O.
SELECT SINGLE bstkd ihrez FROM vbkd INTO (it_extract-bstkd, it_extract-ihrez)
WHERE vbeln = it_extract-vbeln
AND posnr = '000000'.
* Retreive the material description.
it_extract-maktx = zcl_material=>get_maktx( it_extract-matnr ).
* cosmetic change of material number, donot display leading zeros.
SHIFT it_extract-matnr LEFT DELETING LEADING '0'.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
SELECT SINGLE mseh3 FROM t006a INTO it_extract-mseh3
WHERE spras = sy-langu
AND msehi = it_extract-vrkme.
w_tdname = it_extract-vbeln.
* read customer account reference which is under 'text'
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'Z010'
LANGUAGE = sy-langu
NAME = w_tdname
OBJECT = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
LINES = it_text
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF SY-SUBRC = 0.
read table it_text index 1.
if sy-subrc = 0.
it_extract-tdline = it_text-tdline.
else.
clear it_extract-tdline.
endif.
ELSE.
clear it_extract-tdline.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get the delivery item.
CALL METHOD zcl_vbap=>get_delivery
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
etp_vbeln = it_extract-delivery
etp_posnr = it_extract-posnr_vl.
IF it_extract-delivery IS NOT INITIAL.
PERFORM process_deliveries.
ELSE.
PERFORM invoice_process.
ENDIF.
it_extract-count = 1 .
MOVE-CORRESPONDING it_extract TO it_extract2.
APPEND it_extract2.
AT NEW vbeln.
count1 = count1 + 1.
ENDAT.
CALL FUNCTION 'REUSE_ALV_EVENT_NAMES_GET'
* EXPORTING
* I_LIST_TYPE = 0
TABLES
T_EVENT_NAMES = it_extract2
EXCEPTIONS
LIST_TYPE_WRONG = 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.
ENDLOOP.
ENDFORM. " EXTRACT_DATA
*& Form SET_FIELDCAT
* Create the field catalogue.
FORM set_fieldcat .
CLEAR w_field.
CLEAR t_fieldcat. REFRESH t_fieldcat.
w_field-col_pos = 1 .
w_field-fieldname = 'VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Document.Nbr'.
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
APPEND w_field TO t_fieldcat.
CLEAR w_field.
w_field-col_pos = 2 .
w_field-fieldname = 'POSNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Item'(023).
APPEND w_field TO t_fieldcat.
CLEAR w_field.
w_field-col_pos = 3 .
w_field-fieldname = 'VDATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Req. Del. Date'(005).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 4. "DEVK909658
w_field-fieldname = 'KUNNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to.'(038).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 5 .
w_field-fieldname = 'SOLDTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sold-to'(006).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 6 .
w_field-fieldname = 'MATNR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Material'(007).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 7 .
w_field-fieldname = 'KWMENG'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Quantity'(008).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 8.
w_field-fieldname = 'MSEH3'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'UOM'(009).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 9 .
w_field-fieldname = 'BILL_VBELN'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Invoice #'(010).
w_field-emphasize = 'X'.
w_field-hotspot = 'X'.
APPEND w_field TO t_fieldcat.
CLEAR w_field.
w_field-col_pos = 10 .
w_field-fieldname = 'BILL_NETWR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Values'(011).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 11.
w_field-fieldname = 'WERKS'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Plant'(012).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 12.
w_field-fieldname = 'LGORT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Storage Loc'(013).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 13 .
w_field-fieldname = 'MAKTX'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Description'(014).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 14. "DEVK909658
w_field-fieldname = 'OID_SHIP'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to.'(039).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 15 .
w_field-fieldname = 'SHIPTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ship-to'(015).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 16. "DEVK909658
w_field-fieldname = 'BILLTO'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to .'(040).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 17 .
w_field-fieldname = 'BILLTO_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Bill-to'(016).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 18 .
w_field-fieldname = 'LOAD_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Load Contact'(017).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 19 .
w_field-fieldname = 'TRUCK_NAME'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Comp.'(018).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 20 .
w_field-fieldname = 'BSTKD'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'P.O.'(019).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 21 .
w_field-fieldname = 'IHREZ'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'AFE Nbr'(020).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 22 .
w_field-fieldname = 'OID_EXTBOL'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Truck Ticket'(021).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 23.
w_field-fieldname = 'STATU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Status'(022).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 24.
w_field-fieldname = 'AUGRU'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Ord.Reason'(024).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 25.
w_field-fieldname = 'TDLINE'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'cstmr.acct.ref.'(027).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 26 . "DEVK906678
w_field-fieldname = 'VKBUR'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Sales Office'(037).
APPEND w_field TO t_fieldcat.
w_field-col_pos = 27. "DEVK909658
w_field-fieldname = 'COUNT'.
w_field-tabname = 'IT_EXTRACT2'.
w_field-seltext_l = 'Count'(041).
w_field-do_sum = 'X'.
APPEND w_field TO t_fieldcat.
ENDFORM. " SET_FIELDCAT
*& Form CALL_ALV
* Call the ALV Grid function.
FORM call_alv .
SORT it_extract BY lgort vbeln.
* repid is necessary since the ALV F.M. does not work properly with
* sy-repid.
repid = sy-repid.
alv_variant-variant = pa_vari.
alv_variant-report = sy-repid.
alv_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
it_sort = gt_sort[]
i_default = 'X'
i_save = 'A'
is_variant = alv_variant
it_events = gt_events[]
is_print = tp_print
TABLES
t_outtab = it_extract2
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE w000 WITH text-004 ' ' ' ' ' '.
ENDIF.
ENDFORM. " CALL_ALV
*& Form build_top_of_page
* Build heading for report. *
* -->P_GT_LIST_TOP_OF_PAGE[] Header stuff for report
FORM build_top_of_page USING e04_lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader. "Header table for top of page
* construct 'top of page' info. to display. In this case, one line.
DATA: w_selections(40) TYPE c,
w_date_from(10) TYPE c,
w_date_to(10) TYPE c.
WRITE: s_vdatu-low TO w_date_from DD/MM/YYYY.
IF s_vdatu-high IS NOT INITIAL.
WRITE: s_vdatu-high TO w_date_to DD/MM/YYYY.
CLEAR w_selections.
CONCATENATE 'Del.Req.Date: ' w_date_from 'To' w_date_to
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = ' Total Number of Sales Documents'.
append gs_list_top_of_page to gt_list_top_of_page.
gs_list_top_of_page-typ = 'S'.
gs_list_top_of_page-info = count1.
append gs_list_top_of_page to gt_list_top_of_page.
ELSE.
CLEAR w_date_to.
CONCATENATE 'Del.Req.Date: ' w_date_from
INTO w_selections SEPARATED BY space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = w_selections.
APPEND ls_line TO e04_lt_top_of_page.
ENDIF.
ENDFORM. " build_top_of_page
*& Form alv_eventtab_build
* Pass list of events to be triggered by the ALV function module
FORM alv_eventtab_build USING u_name TYPE slis_alv_event-name
u_form TYPE slis_alv_event-form
alv_lt_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event. " structure for event handling
ls_event-name = u_name.
ls_event-form = u_form.
APPEND ls_event TO alv_lt_events.
ENDFORM. " alv_eventtab_build
* FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'NEWALTA_LOGO'
it_list_commentary = gt_list_top_of_page.
ENDFORM. " TOP_OF_PAGE
*& Form process_deliveries
* Process the delivery related records.
FORM process_deliveries .
DATA:
ltp_date TYPE wadat_ist, " Goods movement date.
ltp_vbtyp TYPE vbtyp_n,
ltp_mtart TYPE mtart, " Material type.
w_lfimg TYPE lfimg, " Actual quantity delivered (in sales units).
w_vrkme TYPE vrkme. " Sales unit of measure.
* Read delivery quantity and uom.
SELECT SINGLE lfimg vrkme INTO (w_lfimg, w_vrkme)
FROM lips WHERE
vbeln = it_extract-delivery AND
posnr = it_extract-posnr_vl.
* these fields have values from vbap. override with lips values
IF sy-subrc = 0.
it_extract-kwmeng = w_lfimg.
it_extract-vrkme = w_vrkme.
* translate unit of measure
it_extract-mseh3 = it_extract-vrkme.
SELECT SINGLE mseh3 FROM t006a INTO it_extract-mseh3
WHERE spras = sy-langu
AND msehi = it_extract-vrkme.
ENDIF.
* Determine STATUS by reading 'service confirmation', R (goods movemt)
* it is possible to have multiple 'service confirmation' records for
* one item. ie. delivery 80010390 in PRD.
* As long as there is at least one 'service confirmation' record,
* status is considered 'complete'.
* Validate the created on date of the goods movement or service confirmation.
ltp_mtart = zcl_material=>get_mtart( it_extract-matnr ).
* ltp_date = zcl_lips=>get_goods_movement_date( itp_vbeln = it_extract-delivery
* itp_posnr = it_extract-posnr_vl itp_mtart = ltp_mtart ).
CALL METHOD zcl_lips=>get_goods_mvt_info
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
itp_mtart = ltp_mtart
IMPORTING
rtp_date = ltp_date
rtp_vbtyp = ltp_vbtyp.
* 'h' is cancel goods issue
IF ltp_vbtyp = 'h'.
it_extract-statu = 'Incomplete'(025).
ELSE.
IF ltp_date IS NOT INITIAL.
it_extract-statu = 'COMPLETE'(026).
ENDIF.
ENDIF.
* Retrieve the invoice/billing document item.
CALL METHOD zcl_lips=>get_invoice
EXPORTING
itp_vbeln = it_extract-delivery
itp_posnr = it_extract-posnr_vl
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
IF it_extract-bill_vbeln IS NOT INITIAL.
* retrieve net value from the invoice.
CLEAR it_extract-bill_netwr.
SELECT SINGLE netwr INTO it_extract-bill_netwr FROM vbrp
WHERE vbeln = it_extract-bill_vbeln
AND posnr = it_extract-bill_posnr.
ELSE.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
ENDIF.
ENDFORM. " process_deliveries
*& Form user_command
* Process the user command.
* -->R_UCOMM User command
* -->RS_SELFIELD Field selected
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: ltp_vbeln TYPE vbeln. " Sales document number.
CASE r_ucomm.
WHEN '&IC1'.
IF ( rs_selfield-fieldname = 'VBELN'
OR rs_selfield-fieldname = 'BILL_VBELN' )
AND rs_selfield-value IS NOT INITIAL. " Display sales document.
ltp_vbeln = rs_selfield-value.
zcl_sales_doc=>display( ltp_vbeln ).
ENDIF.
ENDCASE.
ENDFORM. "user_command
*& Form invoice_process
* Process for orders without deliveries. *
FORM invoice_process .
* Translate unit of measure.
SELECT SINGLE mseh3 FROM t006a INTO it_extract-mseh3
WHERE spras = sy-langu
AND msehi = it_extract-vrkme.
* Retrieve the invoice/billing document item.
CALL METHOD zcl_vbap=>get_invoice
EXPORTING
itp_vbeln = it_extract-vbeln
itp_posnr = it_extract-posnr
IMPORTING
rtp_vbeln = it_extract-bill_vbeln
rtp_posnr = it_extract-bill_posnr.
IF it_extract-bill_vbeln IS NOT INITIAL.
* retrieve net value from the invoice.
CLEAR it_extract-bill_netwr.
SELECT SINGLE netwr INTO it_extract-bill_netwr FROM vbrp
WHERE vbeln = it_extract-bill_vbeln
AND posnr = it_extract-bill_posnr.
ELSE. " If no Invoice, then status becomes 'incomplete'.
it_extract-bill_netwr = it_extract-netwr. " Use order net value.
it_extract-statu = 'Incomplete'(025).
ENDIF.
ENDFORM. " invoice_process
*& Form alv_variant_f4
* Get the display variant.
* <--CTP_VARI Variant name
FORM alv_variant_f4 CHANGING ctp_vari TYPE slis_vari.
alv_variant-report = sy-repid. " Report ID
alv_variant-username = sy-uname. " User ID
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = alv_variant
i_save = 'A'
IMPORTING
es_variant = alv_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
ctp_vari = alv_variant-variant.
ENDIF.
ENDFORM. " alv_variant_f4
Kind help will be greatly appreciated.
Thanks
AaravAarav,
when you call the ALV you need to set the event exit details for filter:
*Set callback after filter
REFRESH T_EVENT_EXIT.
CLEAR WA_EVENT_EXIT.
WA_EVENT_EXIT-UCOMM = '&ILT'.
WA_EVENT_EXIT-AFTER = 'X'.
APPEND WA_EVENT_EXIT TO T_EVENT_EXIT.
Then call the ALV as per usual with the event exit details:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Z_OWDR_MONTH_END_01'
I_CALLBACK_PF_STATUS_SET = Z_PF_STATUS_SET
I_CALLBACK_USER_COMMAND = 'CALLBACK_USER_COMMAND'
I_BACKGROUND_ID = 'ALV_BACKGROUND'
IS_LAYOUT = Z_IS_LAYOUT
IT_FIELDCAT = T_FIELDCAT2
IT_FILTER = T_FILTER
I_SAVE = 'A'
IS_VARIANT = Z_VARIANT
IT_EVENT_EXIT = T_EVENT_EXIT
TABLES
T_OUTTAB = T_OUT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Then in the 'callback_user_command' insert some code to read the filter settings when the filter function is selected using function 'REUSE_ALV_GRID_LAYOUT_INFO_GET':
FORM CALLBACK_USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
CASE UCOMM.
WHEN '&ILT'.
PERFORM 99_STORE_FILTERS.
ENDCASE.
FORM 99_STORE_FILTERS.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
ET_FILTER = T_FILTER
ET_FILTERED_ENTRIES = T_FILTERED
EXCEPTIONS
NO_INFOS = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " 99_STORE_FILTERS
Hope that makes it clear - worked for me.
Claire -
Regarding page down in the table control veritcally
Hi all,
I have an issue regarding page down in the Table control in module pool , i.e when i m click the vertical scroll bar and going for page down then , the control is flowing to the next sceen which is not needed , and it shuld just scroll down and up vetically.
Can anyone help me how to handle the page down event ?
Thanks & regards,
satyaTable Controls: Examples with Scrolling
The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar, the user can also carry out program-controlled scrolling with function codes.
REPORT demo_dynpro_tabcont_loop.
CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA: itab TYPE TABLE OF demo_conn,
fill TYPE i.
TABLES demo_conn.
DATA: lines TYPE i,
limit TYPE i.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
DESCRIBE TABLE itab LINES fill.
flights-lines = fill.
ENDMODULE.
MODULE fill_table_control OUTPUT.
READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE read_table_control INPUT.
lines = sy-loopc.
MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'NEXT_LINE'.
flights-top_line = flights-top_line + 1.
limit = fill - lines + 1.
IF flights-top_line > limit.
flights-top_line = limit.
ENDIF.
WHEN 'PREV_LINE'.
flights-top_line = flights-top_line - 1.
IF flights-top_line < 0.
flights-top_line = 0.
ENDIF.
WHEN 'NEXT_PAGE'.
flights-top_line = flights-top_line + lines.
limit = fill - lines + 1.
IF flights-top_line > limit.
flights-top_line = limit.
ENDIF.
WHEN 'PREV_PAGE'.
flights-top_line = flights-top_line - lines.
IF flights-top_line < 0.
flights-top_line = 0.
ENDIF.
WHEN 'LAST_PAGE'.
flights-top_line = fill - lines + 1.
WHEN 'FIRST_PAGE'.
flights-top_line = 0.
ENDCASE.
ENDMODULE.
The layout of screen 100 is:
A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, column headers, and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to the selection column. You can select one column and several lines.
It has the following flow logic:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP WITH CONTROL flights.
MODULE fill_table_control.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP WITH CONTROL flights.
MODULE read_table_control.
ENDLOOP.
MODULE user_command_0100.
The system executes a loop at PBO and PAI using the table control FLIGHTS. During the PBO loop, a module is called to fill the table control from table ITAB of the ABAP program. During the PAI loop, a module is called to modify table ITAB.
Before the PBO loop, in the module STATUS_0100 the current number of lines of the internal table ITAB is placed in component LINES of control structure FLIGHTS. This helps the system to correctly install the scroll bar of the table control.
During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table, where the row index corresponds to the current row of the table control.
During the PAI loop, in the module READ_TABLE_CONTROL the current number of the loop SY-LOOPC in the table control is placed an auxiliary variable. The number is dependent on the size of the screen. The rows of the internal table, whose row index corresponds to the current row of the table control, are overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control is selected or not.
After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate function codes. You can scroll line by line or page by page, or Goto the first or last page. You can implement scrolling by setting the component TOP_LINE of control structure FLIGHTS. For page-by-page scrolling the auxiliary variable that is filled in the PAI loop by SY-LOOPC is used as the step size. -
Alv grid - call transaction 'ME22N' and reflect the change made in alv grid
Hi,
<u>Scenario</u>
I have an alv list which has fields Purchase document no. (EBELN) and Item delivery date (EINDT). EBELN field is hot spot enabled. when i click on that transaction 'ME22' is called. I have done this using USER_COMMAND subroutine.the code is given.
FORM USER_COMMAND *
Call transaction ME22N on clicking Document number *
FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
I_SELFIELD TYPE SLIS_SELFIELD.
DATA: F_SUBRC LIKE SY-SUBRC,
s_arseg like G_T_PORD. "the internal table used is G_T_PORD
CASE F_UCOMM.
WHEN '&IC1'.
IF i_selfield-fieldname = 'EBELN'.
READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
endform.
<u>Requirement</u>
After calling the transaction, If the user changes the Item delivery date (EINDT) at the ME22 transaction screen, the new date needs to be reflected in the ALV grid.
Plz help it is very urgent.The first method (using selfield-refresh = 'X'.) didn't work as the internal table doesnt get modified when the user make changes in Item delivery date(EINDT) at ME22 transaction screen. The 2nd method is OO,which can't be used in my case.
I tried calling the subroutine for populating the itab (G_T_PORD) and the subroutine for displaying the alv grid immediately after calling ME22N transaction. Still it is not reflecting the new date in the output alv. The code is given below.
FORM USER_COMMAND *
Call transaction ME22N on clicking Document number *
FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
I_SELFIELD TYPE SLIS_SELFIELD.
DATA: F_SUBRC LIKE SY-SUBRC,
s_arseg like G_T_PORD.
CASE F_UCOMM.
WHEN '&IC1'.
IF i_selfield-fieldname = 'EBELN'.
READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
refresh G_T_PORD.
perform F1000_POPULATE_PO.
perform F2000_DISPLAY_PO .
endform. -
About the data of table control in tab strip control
hi experts:
I use screen 0001 include one tab strip control,and its include two subscreens,one of it is table control(subscreen is 0003).
I input data in the table control,when I click the button of tab strip control to change to another subscreen 0002.I found that the data I input into table control have not append to internal table.how can I solve this problem?
appreciate your reply.thanks a lot.Hi,
in the Main Screen
In PAI
call subscreen sub. ---> here it calls the subscreen where the tablecontrol is placed
then call module user_command
In the subscreen where you have your table control
in PAI
Loop at itab.
module modify_tab.
endloop.
module modify_tab,
descirbe table itab lines tc-lilnes.
if tc-lines <= tc-current_line.
modify itab index tc-current_lilne.
else.
append itab.
endmodule.
next you call the module user_command on the main screen
module user_command
case sy-ucomm
WHEN 'TAB1'
TS-ACTIVE_TAB = 'TAB1'
when tab2.
ts-active_tab = 'TAB2'.
endmodule
further you can take the help of CONTROL EXAMPLES in DWDM tcode
Regards
Ramchander Rao.K -
Refreshing the Output Table in ALV
Hi All,
Please let me know how to refresh the output table using refresh button in ALV.
Thanks & Regards,
Priya.
Edited by: SathyaPriya Neelagaru on Jun 26, 2008 7:00 AMHi,
We can refresh the output table for ALV by below code :
CLEAR : g_wa_outtab.
REFRESH: g_t_outtab.
When we append something to output table of ALV we need to clear the workarea for that table.
APPEND g_wa_outtab TO g_t_outtab.
CLEAR g_wa_outtab.
If you are using object oreinted concept we have
CALL METHOD g_alv_grid_9001->refresh_table_display.
In case you have to use your own PF Status - Always copy the standard GUI status
(Program : SAPLSLVC_FULLSCREEN,
Status : STANDARD_FULLSCREEN )
For REFRESH - Include parameter for "USER_COMMAND" in the Function module interface.
Inside the User command subroutine - set
"RS_SELFIELD-REFRESH" = "X".
It will automatically refresh the ALV and there is no requirement to call ALV again.
Or else if u have a Refresh button on screen.
we can have
WHEN 'REFRESH'.
CLEAR : g_wa_outtab.
REFRESH : g_t_outtab.
Hope this helps you.
Plz reward if useful.
Thanks,
Dhanashri
Edited by: Dhanashri Pawar on Jun 26, 2008 7:08 AM
Edited by: Dhanashri Pawar on Jun 26, 2008 7:14 AM
Edited by: Dhanashri Pawar on Jun 26, 2008 7:15 AM -
Edit the field in an alv report, also save the changes.
Hi Everyone,
I have made one interactive ALV report using function
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
also i had provided the code to edit a particular col.
fs_fieldcat-fieldname = 'AENAM'.
fs_fieldcat-tabname = 't_mara'.
fs_fieldcat-seltext_m = 'Changed by'.
fs_fieldcat-emphasize = 'X'.
fs_fieldcat-edit = 'X'.
APPEND fs_fieldcat TO t_fieldcat.
CLEAR fs_fieldcat.
now i want to make changes in the AENAM field and save the changes done back on the database table MARA.
pls, if anyone can provide me some assitance on how to save the changes on the alv.
Regards
Ravi Aswani.When SAVE Using the User_command handle the Changed records, and modify the Material using BAPI.
Just check this following code sample. For this you need to handle to events one PF-STATUS and other USER_COMMAND. see the below comments.
REPORT zalv_edit.
TYPE-POOLS: slis.
DATA: x_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv.
data: BEGIN OF itab OCCURS 0,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
END OF itab.
SELECT vbeln
posnr
kwmeng
FROM vbap
UP TO 20 ROWS
INTO TABLE itab.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-hotspot = 'X'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'KWMENG'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form STATUS
* PF-STATUS
FORM status USING p_extab TYPE slis_t_extab.
"Set the Button using the staus
"Copy the Standard status from the program SAPLKKBL status
" STANDARD using SE41, and use that here.
"Pf status
SET PF-STATUS 'STATUS' EXCLUDING p_extab.
ENDFORM. " STATUS
*& Form USER_COMMAND
* USER_COMMAND
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: gd_repid LIKE sy-repid,
ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data .
ENDIF.
CASE r_ucomm.
WHEN 'SAVE'.
"Here you will get the data(along with modified rows/data)
"Filter the modified rows and update to DB using BAPI/BDC
"Accordingly
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "USER_COMMAND -
Hi,
with ALV function call, is it possible to modify the field catalog when processing the event form 'USER_COMMAND'?
The reason:
Before calling the display, I generate the field catalog. Then I set all unpopulated columns (field is initial in all lines) to 'TECH'. So I see only 'active' columns.
Now, the user can do some interaction which will change the lines values. In event routine for 'USER_COMMAND, I set the selfield-refresh = 'X'.
But now, for some fields, I want to remove the 'TECH' attribute of the field catalog because they get populated.
How to achieve this?
Regards,
ClemensHa!
Don't remember who gave me this hint - thank you so uch!
Function group SLVC_FULLSCREEN
hast the FMs
REUSE_ALV_GRID_DISPLAY,
REUSE_ALV_GRID_DISPLAY_LVC
and also
GET_GLOBALS_FROM_SLVC_FULLSCR
Here you have the exporting parameter E_GRID as a reference of current instance of CL_GUI_ALV_GRID.
You may use this to access all the methods as i.e. GET_FRONTEND_FIELDCATALOG and SET_FRONTEND_FIELDCATALOG
and whatever more you want.
Makes use of OO technology almost obsolete
Regards,
Clemens -
Display of push button in the application tool bar in an ALV report
Hello everyone,
Query:
Is it possible to display a custom push button in the application tool bar while displaying an ALV report(1st one)?
On pressing this custom push button will I be able to display another ALV report(2nd one) based on the selection made on the current ALV report(1st one)?Hiii..
I have written a sample code for You
<b>"Call the below FunctionModule For Displaying The List
" And see the bolded line in the Below FunctionModule
" STANDARD_02 and USER_COMMAND are the subroutine Names</b>
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
<b>i_callback_pf_status_set = 'STANDARD_02'</b>
<b> i_callback_user_command = 'USER_COMMAND '</b>
i_structure_name = 'ZST_SCARR'
is_layout = is_layout
it_fieldcat = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
is_sel_hide = is_sel_hide
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = e03_lt_events[]
IT_EVENT_EXIT =
is_print = t
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_scarr
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.
FORM PF_STATUS_SET
<b>" Here Set A Button In Application Toolbar Using PF- Status</b>
FORM standard_02 USING extab TYPE slis_t_extab.
SET PF-STATUS 'STANDA02' EXCLUDING extab.
ENDFORM. "STANDARD_02
*& Form USER_COMMAND
text
-->R_UCOMM text
-->RS_SELFIELDtext
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
<b> "menubutton with functioncode GOTO's Action</b>
WHEN 'GOTO'.
READ TABLE it_scarr INDEX rs_selfield-tabindex. "cursorposit.
IF sy-subrc = 0.
WRITE:/ it_scarr-carrid,
/ it_scarr-carrname.
ENDCASE.
ENDFORM. "USER_COMMAND<b></b>
Hope it helps..
Regards,
Simy -
Dear All,
I want to write a code, where if I click on in ALV Report or Clasic Report then related Sales order should open in display mode.
I have found on the forum, but I could not get it.
Regards
H P SinghFORM SUB_SHOW_ALV .
FUNCTION MODULE FOR GRID DISPLAY
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = WA_FIELDLAYOUT
IT_FIELDCAT = I_FIELDCAT
IT_EVENTS = EVENTS
I_SAVE = 'A'
TABLES
T_OUTTAB = I_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " sub_show_alv
*& Form AT_user_command
form user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE rs_selfield-fieldname.
WHEN 'VBELN'.
SET PARAMETER ID 'AUN' FIELD rs_selfield-value.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
WHEN OTHERS.
MESSAGE 'Please select SO Doc# or DL doc# or BL Doc# for this facility'
TYPE 'I'.
ENDCASE.
endform. " user_command
Use the above code, it works
Regards,
Ajay -
Editable field in alv data format
i have a editable field on ALV which is of date format and i need when user enter a date the value will be updated in the database table .
note that i am using alv list and the field catalog is of date format dat 8
the update is not done pleaseee helppp urgentHi,
You need to use the USER_COMMAND in the ALV function module
{CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'GUI_STAT'
*i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
*it_special_groups = gd_tabgroup
*it_events = it_events
i_save = 'X'
*is_variant = z_template
TABLES
t_outtab = i_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
then you need to write the below FORM
* FORM USER_COMMAND *
* --> U_COMM *
* --> RS_SELFIELD *
FORM user_command USING u_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.}
Here in the Form, Write the UPDATE statment to update the database table
Regards
Sudheer -
Hi all,
I have to add a button to alv list display output to proceed further ( along with other standard buttons like select all/ filer/ sorting etc).
can anybody help me please.
thanks,
sudheerSE41 create
copy standard status from program saplsalv to you're own program and status standard
in you're programm refer to you're status created
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
i_bypassing_buffer = 'X'
* I_BUFFER_ACTIVE = ' '
i_callback_program = h_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
and the form
*& Form set_pf_status
* text
* -->RT_EXTAB text
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDAARD'.
ENDFORM. "set_pf_status
kind regards
arthur de smidt
Edited by: A. de Smidt on Jul 18, 2008 8:52 AM
Maybe you are looking for
-
Downloading personal video stored on computer to iPod
Is it possible to get video that I have stored on my computer (recording from a DVR in an mpg4 file) onto the iPod? I cannot transfer it to iTunes but is there a way to transfer it to the iPod directly? Do I need to purchase a special app to do this?
-
How to implement JAAS With Weblogic 10.3
I am working on a migration project. A project is to be migrated from JBOSS to Weblogic 10.3. JAAS has been used in JBOSS for security purpose. Required classess like LoginModule, CallBackHandler are customized and put into a jar file. Next a Login p
-
Problem with the picklist object in picklist.pll
I am using Developer 2.1 (Forms 5.0). In my application i am using Picklist object from picklist.pll (This library is supplied by oracle as a part of the software) which contains reusable code for creating picklist in your application. But while usin
-
Please let me know how to create a HR report category????? Thanks Rasika
-
hello, i want to use a query as infoprovider for a dso. but when i checked the properties of the query, this option is disabled. i wonder why. can anyone please give me some idea why's that ? please check the attachment