AT NEW in ALV list
Hi all,
I am displaying an ALV list. I want my output to display the department in a new line for every new department.
Example:
no name dept
department D1
1 abc d1
2 xyz d1
3 xyz1 d1
department D2
1 abr d2
2 xyg d2
3 xfz d2
How can we do it in ALV list? Please help me.
Dev.
You cannot add that line("Department D1") in ALV,
You can do this work around,
declare wa_final and it_final just like your itab.
1) sort itab by dept.
2) Loop at itab into wa.
3) at new dept.
wa_final-name = 'Department'.
wa_final-dept = wa-dept
append wa_final to it_final.
endat.
wa_final = wa.
append wa_final to it_final.
endloop.
Please refine the code. I have not tested it.
Regards,
Sumit
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 -
ALV List Layout add new button and modify Append Row Button Text and Logi
Hi All,
I am working on Employee custom development Application in Webdynpro ABAP>
In my ALV list Layout I have to add new two Buttons Top or Bottom of the ALV List.
If I am adding I have to add logic for those Buttons. How to add and add logic for those buttons.
as well as I have to Change the Text for Existing Button ''Append Row'' to "ADD NEW ROWS"
and I have to add logic in this button while Append New Row I have to generate ID no for New Rows .
Kindly help/advice me to proceed further.
Thanks in advance.
DavHi Dav,
To Add buttons please refer this thred,
ALV with user-defined buttons on toolbar in wd abap
To change or rename text in ALV standard buttons, please refer this ...
How can i change the text of an standard button in ALV?
and also see this article on self defined functions...
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110?quicklink=index&overridelayout=true
Thanks,
Kris.
Edited by: kissnas on Feb 22, 2011 5:59 AM -
How to set the focus on the new added line in ALV list (OO)
Dear Friends,
I have an ALV list based on OO(using alv_grid->set_table_for_first_display), when I click the 'new' button to add a new line, the mouse arrow is always pointing to the first line - not the new created line for user to input!!.
So how to set the focus (mouse arrow) on the new added line in ALV list for user to input it friendly?
Thanks a lot!!Hello,
To get the selected line row first we have get all the rows in the internal table.
When u click on the button when it is creating the new line we have to pass the row number to the call method
CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->get_selected_rows
IMPORTING
ET_INDEX_ROWS = <internal table of type LVC_T_ROW > (obsolete)
ET_ROW_NO = <internal table of type LVC_T_ROID > .
CALL METHOD<ref.var. to CL_GUI_ALV_GRID>->set_selected_rows
EXPORTING
IT_ROW_NO = <internal table of type LVC_T_ROID>
or alternatively
IT_INDEX_ROWS = <internal table of type LVC_T_ROW>
IS_KEEP_OTHER_SELECTIONS = <type CHAR01>.
http://help.sap.com/saphelp_erp2004/helpdata/EN/22/a3f5ecd2fe11d2b467006094192fe3/content.htm -
How to create Multiple ALV Lists, Each list on one new page
Hi All,
I have a requirement of displayiong data on multiple ALV Lists.
Ex:
I have data in internal table MATNR QTY VALUE
M1 2 3USD
M1 2 3USD
M2 2 3USD
M2 2 3USD
M3 2 3USD
M3 2 3USD
M4 2 3USD
M4 2 3USD
In The above internal table data , i have to displat M1 on one page and M2 on second,M3 on third and M4 on 4th page.....This may go to MN.
I have tried to do this with REUSE_ALV_BLOCK_LIST_APPEND, But if Lists are fixed like 3 or 4 , I can use this method.
Can any one help me on this?
Thanks,
Suresh.Hi Peter,
Yes I think that this is the way we will be probably go but not sure what the correct terms are for what I am looking for. Not sure if you are allowed to post examples of specific commercial plug ins here but if not, what should I search for. I know if sounds daft but it's a real case of not knowing what it is I am looking for. I am a complete InDesign newcomer who uses it at the moment for simple flyers etc so more than happy to find someone who can do the more complex stuff for me. The price lists will need to be done inhouse and on a regular basis.
thanks
Jen -
How to read modifed data in ALV List
Hi,
I have one input enabled field in my ALV list. User can modify the values of that field. How i can get what are all the records are modified by the user.
Thanks
stallinHi,
Try this code...
REPORT ZTEST_EDIT_ALV .
*Data Declaration
DATA: BEGIN OF T_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
* FLAG TYPE C,
* HANDLE_STYLE TYPE LVC_T_STYL,
END OF T_EKKO.
DATA: GD_REPID LIKE SY-REPID, "Exists
REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
DATA: BEGIN OF IT_EKKO OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS. "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Start-of-selection.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
IT_BACKUP[] = IT_EKKO[].
PERFORM DISPLAY_ALV_REPORT.
*& Form build_fieldcatalog
* text
FORM BUILD_FIELDCATALOG.
REFRESH FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELN'.
FIELDCATALOG-SELTEXT_M = 'Purchase Order'.
FIELDCATALOG-INPUT = 'X'.
FIELDCATALOG-EDIT = 'X'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SELTEXT_M = 'PO Item'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM BUILD_LAYOUT.
"Permet d'ajuster les colonnes au text
* gd_layout-colwidth_optimize = 'X'.
* GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-box_fieldname = 'SELECT'.
* gd_layout-box_tabname = 'IT_EKKO'.
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_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* i_grid_title = 'My Title'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE:/ SY-SUBRC.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP
UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
ENDFORM. " DATA_RETRIEVAL
* FORM SET_PF_STATUS *
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.
ENDFORM. "set_pf_status
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
*then insert the following code in your USER_COMMAND routine...
<b> 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.</b>*modify
CASE R_UCOMM.
WHEN '&IC1'.
CHECK RS_SELFIELD-TABINDEX > 0.
IF RS_SELFIELD-VALUE EQ '6000000001'.
CALL TRANSACTION 'ZTEST'.
ENDIF.
WHEN 'REFRESH'.
READ TABLE IT_EKKO INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
IF IT_EKKO <> IT_BACKUP.
* then do your check
ENDIF.
ENDIF.
ENDIF.
PERFORM DATA_RETRIEVAL.
RS_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM. "user_command
Regards
vijay -
Hi,
My program output is in ALV format either LIST or GRID based on Sy-batch.
In that program they are using table Z1021.
They are retreiving data from Z1021 table based on selection screen parameters like werks, bukrs, vkorg,
auart and date and passing that data to one internal table.
SELECT * FROM Z1021 INTO TABLE i_z1021
WHERE werks in s_werks
AND bukrs in s_bukrs
AND vkorg in s_vkorg
AND auart in s_auart
AND pgi_date in s_date.
SORT i_z1021 BY werks bukrs vkorg auart pgi_date.
For fieldcatlog they used function module REUSE_ALV_FIELDCATALOG_MERGE'.
passing only i_structure_name = c_struct_name in Exporting parameters
retreive to i_fieldcat from Changing parameters.
from above both they are passing i_z1021 table data and i_fieldcat to function module
'REUSE_ALV_GRID_DISPLAY' OR 'REUSE_ALV_LIST_DISPLAY' based on sy-batch.
That is my current program.
My new requirement is given below.
Additional and change to fields:
1) Add Intercompany purchase order number
From the document flow table VBFA.
The field name is VBFA-VBELN when Subs.doc.categ (VBFA-VBTYP_N) equal to "V" after sales order line item.
2) Change field name u2018Customeru2019 to u2018Ship-tou2019
From VBFA table need to retrieve VBELN value based on VBELN_VA and POSNR_VA from Z1021 table
where VBFA-VBELV = Z1021-VBELN_VA and VBFA-POSNV = Z1021-POSNR_VA.
This is the condition to fetch that data.
And I want to change the description of Field 'CUSTOMER'( Z1021-KUNNR) to' Ship-to'.
Is it possible to do without changing the original logic.
IF it is possible what is the solution ?
If it is not possible without changing the original code then what is the solution for that also.
Current Code:
Some code i am giving here.
TABLES: Z1021.
DATA: i_z1021 LIKE z1021 OCCURS 0.
CONSTANTS: c_struct_name LIKE dd02l-tabname VALUE 'Z1021'.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM list_display.
FORM get_data.
SELECT * FROM Z1021 INTO TABLE i_z1021
WHERE werks in s_werks
AND bukrs in s_bukrs
AND vkorg in s_vkorg
AND auart in s_auart
AND pgi_date in s_date.
SORT i_z1021 BY werks bukrs vkorg auart pgi_date.
ENDFORM.
FORM list_display.
PERFORM create_fieldcatalog.
< another performs>
PERFORM display_list.
ENDOFRM.
FORM create_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = c_struct_name
CHANGING
ct_fieldcat = i_fieldcat.
ENDFORM.
FORM display_list.
CASE sy-batch.
WHEN 'X'.
CALL FUNCTION ;REUSE_ALV_LIST_DISPLAY'
WHEN ' '.
CALL FUNCTION ;REUSE_ALV_GRID_DISPLAY'
ENDCASE
ENDFORM.
Could you please suggest on this.
Thanks & Regards.
VSRHi
After fill the field catalog table by function module MERGE, u can modify the value before moving it to ALV LIST/GRID display fm:
FORM create_fieldcatalog.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = c_struct_name
CHANGING
ct_fieldcat = i_fieldcat.
LOOP AT I_FIELDCAT INTO LS_FIELDCAT.
CASE LS_FIELDCAT-FIELDNAME.
WHEN 'KUNNR'.
LS_FIELDCAT-SELTEXT_L = <new descrip.>.
LS_FIELDCAT-SELTEXT_M = <new descrip.>.
LS_FIELDCAT-SELTEXT_S = <new descrip.>.
MODIFY I_FIELDCAT FROM LS_FIELDCAT.
ENDCASE.
ENDLOOP.
ENDFORM.
Max
Edited by: max bianchi on Jan 29, 2009 8:15 PM -
Convert ALV list to PDF and send mails to respective persons
Hi All,
I have a requirement ..we have written a program which will give o/p in alv list.Now I got a requirement to download that program to ALV format.Kindly help me how to approch for that we have some standard FM's for that like CONVERT_ABAPSPOOLJOB_2_PDF..what are the necessary inputs I have to give for that FM,
Second requirement is I have to send an E mail of that list to respective persons.help me on this also
Regards
KKHi,
Try with this program which will send the spool to email.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
*** Alternative way could be to submit another program and store spool
*** id into memory.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Regards,
Raghav -
How to create space between Header text of Hierarchical ALV List.
hi,
I am display data using Hierarchical ALV List.
In Perform of field catalog, I am writing this code:
PERFORM fill_catalogue USING :
'CHKBX' 'T_HEADER' 20 'Sess Decision Box'(t19) 'X',
'SESS_NO' 'T_HEADER' 11 'Session'(t20) ' ' ,
'SESS_STAT' 'T_HEADER' 4 'Status'(t39) ' ',
'HOLD_STAT' 'T_HEADER' 4 'HOLD'(t52) ' ',
'ICON' 'T_HEADER' 9 'Tracking'(t21) ' ' ,
'CREATE_DT' 'T_HEADER' 10 'Archiving Date'(t22) ' ' ,
'AGING' 'T_HEADER' 50 'Aging'(t23) ' ',
'OBJECT' 'T_HEADER' 12 'Archive Obj'(t24) ' ',
'HOLD_INFO' 'T_HEADER' 100 'Hold Reason' ' ' ,
'YFY_DATA' 'T_HEADER' 4 'Data Fiscal Year'(t48) ' ' ,
'COMMENTS' 'T_HEADER' 50 'Session Notes'(t26) ' ' ,
'DATATYPE' 'T_HEADER' 50 'Archive Object Description'(t25) ' ',
'APPR_STAT' 'T_ITEM' 16 'Approval Status'(t29) ' ',
'DESTR_DT_REV' 'T_ITEM' 10 'New Date'(t30) ' ',
'REJCT_REASON' 'T_ITEM' 60 'Rejection Reason'(t31) ' ' .
At output of this program , there are two rows in HEADER details.
I want text 'Session notes' of 2nd row under 'Archiving Date' of 1st row.
For this i have to create space between 'Data Fiscal Year' & 'Session notes' text.
How i can do this.
Regards,
MamtaHi,
You can use TOP-OF-PAGE event and pass this event to Hierarchical ALV FM.
Thanks,
Kartavya Kaushik. -
Problem with check Box in ALV list
Hi All,
In my alv list I am using Check box and if I enabled the check box after pressing that pushbutton its not reflecting in the internal table how can I resolve it.
Please find below the piece of codes
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
sy-ucomm = ucomm.
CASE ucomm.
When 'SAVE'.
I am checking my internal table value here.
my logic....
When others.
Endcase.
FORM FIELD_CATLOGUE USING VALUE(P_tname) "Int.table name
VALUE(P_fname) "Field name
VALUE(P_title) "Column name
VALUE(P_sum) "Sum
VALUE(P_edit) "Edit
VALUE(P_Check). " Check box
CLEAR wa_fcat.
wa_fcat-tabname = p_tname.
wa_fcat-fieldname = p_fname.
wa_fcat-seltext_l = p_title.
wa_fcat-do_sum = P_Sum.
Wa_Fcat-edit = P_Edit.
Wa_Fcat-checkbox = P_Check.
Append wa_fcat to i_fcat.
gs_user_command type slis_formname value 'USER_COMMAND'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = i_fcat
is_layout = ilay
I_DEFAULT = 'X'
I_SAVE = 'A'
I_CALLBACK_PF_STATUS_SET = gs_user_status
i_callback_user_command = gs_user_command
TABLES
t_outtab = it_data
EXCEPTIONS
program_error = 1
others = 2.Hi,
Refer this program:-
* internal table and alv declarations
* with one field in internal table as
* flag(1) type c (for checkbox in alv)
* START-OF-SELECTION
START-OF-SELECTION.
"your select query to populate data in internal table
* END-OF-SELECTION
END-OF-SELECTION.
* FIELD CATALOG FOR FIRST GRID DISPLAY
PERFORM field_catalog.
* SORT W.R.T. WORK ORDER NUMBER FOR FIRST GRID DISPLAY
PERFORM sort_field.
* FOR LAYOUT FOR FIRST GRID DISPLAY
PERFORM set_layout.
* DISPLAY RECORDS IN ALV GRID FOR FIRST GRID DISPLAY
PERFORM alv_display.
*& SUBROUTINE DEFINITIONS
*& Form FIELD_CATALOG
* SUB-ROUTINE FIELD_CATALOG USED TO SET THE COLUMNS FOR
* THE ALV GRID (OUTPUT FORMAT)
* SETS THE COLUMN NAME AND THE OUTPUT LENGTH FOR THE FIELDS
FORM field_catalog .
wa_field-fieldname = 'FLAG'. " name of field from internal table
wa_field-tabname = 'IT_FINAL'. " internal table name
wa_field-outputlen = 2. " output length on screen
wa_field-checkbox = c_check. " print as checkbox
wa_field-edit = c_check. " make field open for input
wa_field-seltext_l = ' '. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area
wa_field-fieldname = 'AUFNR'. " name of field from internal table
wa_field-tabname = 'IT_FINAL'. " internal table name
wa_field-outputlen = 20. " output length on screen
wa_field-seltext_l = text-003. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area
ENDFORM. " FIELD_CATALOG
*& Form SORT_FIELD
* SUB-ROUTINE SORT_FIELD IS USED TO SORT THE RECORDS IN THE
* INTERNAL TABLE BASED ON THE GIVEN FIELD AND NATURE OF
* SORTING TO BE DONE (ASCENDING OR DESCENDING)
FORM sort_field .
wa_sort-spos = 1. " sort priority
wa_sort-fieldname = 'AUFNR'. " field on which records sorted
wa_sort-tabname = 'IT_FINAL'. " internal table name
wa_sort-up = c_check. " sort ascending
APPEND wa_sort TO it_sort. " append sort info internal table
CLEAR wa_sort. " clear sort info work area
ENDFORM. " SORT_FIELD
*& Form SET_LAYOUT
* SUB-ROUTINE SET_LAYOUT IS USED TO SET THE DISPLAY OF THE
* ALV GRID LINES IN ALTERNATIVE COLOURS
FORM set_layout .
wa_layout-zebra = c_check. " so set colors of line alternatively
ENDFORM. " SET_LAYOUT
*& Form ALV_DISPLAY
* SUB-ROUTINE ALV_DISPLAY IS USED TO SET THE PARAMETERS
* FOR THE FUNCTION MODULE REUSE_ALV_GRID_DISPLAY
* AND PASS THE INTERNAL TABLE EXISTING THE RECORDS TO BE
* DISPLAYED IN THE GRID FORMAT
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
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. " ALV_DISPLAY
*& Form pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'.
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
* when the function code is EXECUTE then process the selected records
WHEN 'EXECUTE'.
* refresh it_process when user processes selected records
REFRESH it_process.
* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
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.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
WHEN 'SEL_ALL'.
* to select all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = 'X'.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
WHEN 'DESEL_ALL'.
* to deselect all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = ' '.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun. -
ALV List in the same Column for the row CELL i need button or value
Hi,
In my ALV list for the same column I need Button or Value for the different rows (CELL) depending upon my condition.
as well as I have to make read only of 3 rd column CELL based on my first column dropdown value CELL for this Row Only.
Depends upon the value in column 1 / row 2 I have to read only the CELL of column 5 / row 2 ie for the same row.
Depends upon the value in Column 1/ row 3 I have to EDITABLE or Button the CELL of column 5 / row 3 ie for the same row
How to do the logic for this.
I tried and got it for the entire column only.
But my requirement is for the sepecific cell in the column.
Kindly help to proceed further.
Thanks in advance.
DavHere is how you can make a particular cell in the row read-only based on certain conditions.
In my example I am displaying the flight details in an ALV. Here I am checking the airline id and if it is "AA' I am making the cell in the column airline id as readonly. In my example I am putting a check and readonly on the same column. However you can do this for different columns as well.
In order to achieve this you need to add a new context attribute 'READONLY' of type abap_bool to the context node which is bound to data node of ALV.
The method where I populate the node has the following code to populate the data.
data: lr_input_node type ref to if_wd_context_node,
lr_flight_node type ref to if_wd_context_node,
lv_cityfrom type s_from_cit,
lv_cityto type s_to_city,
ls_from type bapisfldst,
ls_to type bapisfldst,
lt_flights type table of bapisfldat,
ls_flights type bapisfldat.
data: lt_final type if_mainview=>elements_node_flighttab,
ls_final type if_mainview=>element_node_flighttab.
* Instantiate the variable lr_input_note to the node NODE_FLIGHT
lr_input_node = wd_context->get_child_node( name = 'NODE_FLIGHT' ).
* Instantiate the variable lr_flight_note to the node NODE_FLIGHTTAB
lr_flight_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' )
* Get the attributes CityFrom und CityTo
lr_input_node->get_attribute( exporting name = 'CITYFROM'
importing value = lv_cityfrom ).
lr_input_node->get_attribute( exporting name = 'CITYTO'
importing value = lv_cityto ).
* Fill the stuctures ls_from and ls_to
ls_from-city = lv_cityfrom.
ls_to-city = lv_cityto.
* Call the function BAPI_FLIGHT_GETLIST
call function 'BAPI_FLIGHT_GETLIST'
exporting
destination_from = ls_from
destination_to = ls_to
tables
flight_list = lt_flights.
Now I am going to check if the airline id is 'AA' and based on that I will fill the readonly context attribute.
loop at lt_flights into ls_flights.
MOVE-CORRESPONDING ls_flights to ls_final.
if ls_flights-airlineid = 'AA'.
ls_final-readonly = abap_true.
else.
ls_final-readonly = abap_false.
endif.
append ls_final to lt_final.
endloop.
Finally bind the data to the context node.
* Bind the data to the node NODE_FLIGHTTAB
lr_flight_node->bind_elements( lt_final ).
Now you need to do the ALV configuration settings.
* create an instance of ALV component
DATA:
lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
lr_salv_wd_table_usage->create_component( ).
ENDIF.
* get ALV component
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
CALL METHOD wd_this->alv_config_table->if_salv_wd_table_settings~set_read_only
EXPORTING
VALUE = ABAP_FALSE
* set visible row count
DATA:
lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= wd_this->alv_config_table.
lr_table_settings->set_visible_row_count( '10' ).
DATA:
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column.
lr_column_settings ?= wd_this->alv_config_table.
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column = lr_column_settings->get_column( 'AIRLINEID' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'AIRLINEID'.
lr_column->set_cell_editor( lr_input_field ).
lr_input_field->set_read_only_fieldname( value = 'READONLY' ).
CALL METHOD lr_column_settings->delete_column
EXPORTING
id = 'READONLY' -
Hello every one, got an issue with at new in ALV.
I need to get individial sum for each employee. So what ever the amount sub total is for emploee 8361 it should be displayed first b4 it proceeds for next employee 8375.
How to go about it.
Employe Amount
8361 50,000.00-
8375 47,250.00
8375 23,625.00-
8375 64,855.00-
8375 95,100.00-
8375 70,150.00-
256,480.00-Hi Kesi,
*& Report Z_REPORTFROMKNA1ANDT005T
report z_reportfromkna1andt005t
line-size 180
message-id zz.
tables:ekko.
type-pools : slis.
Internal table for ALV
data : it_fieldcat type slis_t_fieldcat_alv, "Field catalog
wa_fieldcat type slis_fieldcat_alv, "WA for Field catalog
it_event type slis_t_event, "events
wa_event type slis_alv_event, "WA for events
it_comment type slis_t_listheader, "Header details
wa_comment type slis_listheader, "WA for header details
wa_layout type slis_layout_alv, "Layout
it_sort type slis_t_sortinfo_alv, "Sort table
wa_sort type slis_sortinfo_alv, "WA for sort table
it_keyinfo type slis_keyinfo_alv. "Pass key value
data : v_repid like sy-repid.
v_repid = sy-repid.
data : v_date like sy-datum.
color management.
data : it_color type table of lvc_s_scol. "Color management.
Internal table declearation
data:begin of it_ekko occurs 0,
ebeln like ekko-ebeln,
bukrs like ekko-bukrs,
aedat like ekko-aedat,
end of it_ekko.
data : begin of it_ekpo occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
netwr like ekpo-menge,
end of it_ekpo.
data : begin of it_EKBE occurs 0,
ebeln like EKBE-ebeln,
ebelp like EKBE-ebelp,
BELNR like EKBE-BELNR,
MENGE like EKBE-MENGE,
MATNR like EKBE-MATNR,
end of it_EKBE.
data : begin of it_final occurs 0,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
netwr like ekpo-netwr,
line_color(4) type c, "Used to store row color attributes
end of it_final.
selection-screen begin of block blk with frame title text-001.
select-options:s_ebeln for ekko-ebeln.
parameters : rb1 radiobutton group g1,
rb2 radiobutton group g1,
rb3 radiobutton group g1.
selection-screen end of block blk.
start-of-selection.
perform get_details.
perform get_alv.
*& Form GET_DETAILS
Get the details
form get_details .
data: ld_color(1) type c.
select ebeln
bukrs
aedat
from ekko
into table it_ekko
where ebeln in s_ebeln.
if sy-subrc = 0.
sort it_ekko by ebeln.
else.
message e000 with 'DATA NOT FOUND'.
endif.
if not it_ekko[] is initial.
select ebeln
ebelp
matnr
menge
meins
netpr
netwr
from ekpo
into table it_ekpo
for all entries in it_ekko
where ebeln = it_ekko-ebeln.
if sy-subrc = 0.
sort it_ekpo by ebeln.
endif.
endif.
loop at it_ekpo.
it_final-ebeln = it_ekpo-ebeln.
it_final-ebelp = it_ekpo-ebelp.
it_final-matnr = it_ekpo-matnr.
it_final-menge = it_ekpo-menge.
it_final-meins = it_ekpo-meins.
it_final-netpr = it_ekpo-netpr.
it_final-netwr = it_ekpo-netwr.
on change of it_final-ebeln.
ld_color = 7.
concatenate 'C' ld_color '10' into it_final-line_color.
endon.
append it_final.
clear it_final.
endloop.
loop at it_final.
on change of it_final-ebeln.
ld_color = 7.
concatenate 'C' ld_color '10' into it_final-line_color.
modify it_final.
endon.
endloop.
endform. " GET_DETAILS
*& Form GET_ALV
text
form get_alv .
perform generate_fieldcat.
perform generate_layout.
perform generate_events.
perform generate_sort.
perform alv_grid_display.
endform. " GET_ALV
*& Form GENERATE_FIELDCAT
Field catalog
form generate_fieldcat .
if rb1 = 'X' or rb2 = 'X'.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'PO Number'.
wa_fieldcat-lowercase = 'X'.
<b> wa_fieldcat-do_sum = 'X'.</b>
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Item Number'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Material Number'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'PO Quantity'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Order unit'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Net price'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Net order value'.
wa_fieldcat-lowercase = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'CHK'.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-just = 'C'.
wa_fieldcat-seltext_l = 'Check Box'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'.
append wa_fieldcat to it_fieldcat.
else.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_EKKO'
I_STRUCTURE_NAME = I_STRUCTURE_NAME
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
changing
ct_fieldcat = it_fieldcat
exceptions
inconsistent_interface = 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.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_EKPO'
I_STRUCTURE_NAME = I_STRUCTURE_NAME
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
changing
ct_fieldcat = it_fieldcat
exceptions
inconsistent_interface = 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.
endif.
endform. " GENERATE_FIELDCAT
*& Form GENERATE_EVENTS
Generate Events
form generate_events .
call function 'REUSE_ALV_EVENTS_GET'
importing
et_events = it_event
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.
if not it_event[] is initial.
read table it_event into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc = 0.
wa_event-form = 'TOP_OF_PAGE'.
modify it_event from wa_event index sy-tabix.
endif.
endif.
endform. " GENERATE_EVENTS
*& Form TOP_OF_PAGE
TOP_OF_PAGE
form top_of_page.
wa_comment-typ = 'S'.
wa_comment-key = 'USER :'.
wa_comment-info = sy-uname.
append wa_comment to it_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'DATE:'.
wa_comment-info = sy-datum.
append wa_comment to it_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'TIME:'.
wa_comment-info = sy-timlo.
append wa_comment to it_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_comment.
clear it_comment.
endform. "TOP_OF_PAGE
*& Form ALV_GRID_DISPLAY
Grid display
form alv_grid_display .
if rb1 = 'X'.
perform grid_display.
elseif rb2 = 'X'.
perform list_display.
else.
perform hierseq_display.
endif.
endform. " ALV_GRID_DISPLAY
*& Form GENERATE_LAYOUT
LAYOUT
form generate_layout .
wa_layout-colwidth_optimize = 'X'. "OPTIMIZING FIELD WIDTH
wa_layout-zebra = 'X'. "PUTTING ZEBRA COLORS
<b> wa_layout-totals_text = 'Total'.</b>
<b> wa_layout-subtotals_text = 'SUB TOTAL'.</b>
wa_layout-info_fieldname = 'LINE_COLOR'.
endform. " GENERATE_LAYOUT
*& Form GENERATE_SORT
SORT
form generate_sort .
wa_sort-fieldname = 'EBELN'.
wa_sort-spos = '1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
append wa_sort to it_sort.
endform. " GENERATE_SORT
*& Form GRID_DISPLAY
GRID DISPLAY
form grid_display .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'IT_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = 'Purchase Order Details'
I_GRID_SETTINGS = I_GRID_SETTINGS
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
it_events = it_event
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
IT_HYPERLINK = IT_HYPERLINK
IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = it_final
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. " GRID_DISPLAY
*& Form LIST_DISPLAY
LIST DISPLAY
form list_display .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'IT_USER_COMMAND'
I_STRUCTURE_NAME = I_STRUCTURE_NAME
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
it_events = it_event
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = 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 = IR_SALV_LIST_ADAPTER
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = it_final
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. " LIST_DISPLAY
*& Form HIERSEQ_DISPLAY
HIERSEQ DISPLAY
form hierseq_display .
it_keyinfo-header01 = 'EBELN'.
it_keyinfo-item01 = 'EBELN'.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
it_sort = it_sort
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
it_events = it_event
IT_EVENT_EXIT = IT_EVENT_EXIT
i_tabname_header = 'IT_EKKO'
i_tabname_item = 'IT_EKPO'
I_STRUCTURE_NAME_HEADER = I_STRUCTURE_NAME_HEADER
I_STRUCTURE_NAME_ITEM = I_STRUCTURE_NAME_ITEM
is_keyinfo = it_keyinfo
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
IR_SALV_HIERSEQ_ADAPTER = IR_SALV_HIERSEQ_ADAPTER
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab_header = it_ekko
t_outtab_item = it_ekpo
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. " HIERSEQ_DISPLAY
*& Form IT_USER_COMMAND
text
form it_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
free it_fieldcat.
case r_ucomm.
when '&IC1'.
read table it_final index rs_selfield-tabindex.
perform get_EKBE.
PERFORM GET_FIELD_CATALOG.
perform get_list.
endcase.
endform. "IT_USER_COMMAND
*& Form GET_EKBE
text
form get_EKBE .
if not it_final[] is initial.
select ebeln
ebelp
BELNR
MENGE
MATNR
into table it_ekbe
from EKBE
for all entries in it_final
where ebeln = it_final-ebeln
and ebelp = it_final-ebelp.
endif.
endform. " GET_EKBE
*& Form GET_FIELD_CATALOG
text
form GET_FIELD_CATALOG .
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'PO Number'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'Item Number'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'Material Document'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'Quantity'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-just = 'R'.
wa_fieldcat-seltext_l = 'Material Number'.
wa_fieldcat-lowercase = 'X'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
endform. " GET_FIELD_CATALOG
*& Form get_list
text
form get_list .
IF RB1 = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME = I_STRUCTURE_NAME
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'SECONDARY LIST'
I_GRID_SETTINGS = I_GRID_SETTINGS
IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
IT_SORT = IT_SORT
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
IT_EVENTS = IT_EVENTS
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS = IT_ALV_GRAPHICS
IT_HYPERLINK = IT_HYPERLINK
IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = IT_EKBE
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.
ENDIF.
IF RB2 = 'X'.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = I_STRUCTURE_NAME
IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
IT_SORT = IT_SORT
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
IT_EVENTS = IT_EVENTS
IT_EVENT_EXIT = IT_EVENT_EXIT
IS_PRINT = IS_PRINT
IS_REPREP_ID = 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 = IR_SALV_LIST_ADAPTER
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
tables
t_outtab = it_ekbe
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.
ENDIF.
endform. " get_list
Thanks
Vikranth Khimavath
Message was edited by: Khimavath Vikranth -
Output of two ALV lists in background
HI ALV experts,
[Soory I just saw that I posted this yesterday with a wrong subject]
I'm currently working with an existing reports which is quite complex. The report creates an ALV grid and uses a couple of write statements to create some statistics.
Running the report, we get the ALV grid. Then using BACK/F3 we leave the grid and get the list showing statistics.
I would like to create an ALV for the statistics. This works fine online: After leaving the grid the statistics ALV is started. But in background, I got just one list.
I tried this sample:
FORM batchtest .
DATA:
lr_data TYPE REF TO data,
lo_salv TYPE REF TO cl_salv_table.
FIELD-SYMBOLS:
<table> TYPE table.
* dynamic table fpr T000
CREATE DATA lr_data TYPE TABLE OF t000.
ASSIGN lr_data->* TO <table>.
SELECT * INTO TABLE <table> FROM t000.
* show table in grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'T000'
TABLES
t_outtab = <table>
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.
* create another table
TRY.
CREATE DATA lr_data TYPE TABLE OF t100.
ASSIGN lr_data->* TO <table>.
SELECT * INTO TABLE <table> FROM t100 UP TO 100 ROWS.
cl_salv_table=>factory(
EXPORTING
list_display = if_salv_c_bool_sap=>true
IMPORTING
r_salv_table = lo_salv
CHANGING
t_table = <table> ).
* display list
lo_salv->display( ).
CATCH cx_salv_msg .
ASSERT 1 = 2.
ENDTRY.
ENDFORM. " BATCHTEST
Online, it works fine. In batch, I get only the second table as list. If I exit after calling FUNCTION 'REUSE_ALV_GRID_DISPLAY', I get the first list only. How to get both lists printed in sequence? I will not use ALV block list display, because this would mean major restructuring of the program and no grid online. SUBMIT ist no good idea as well.
Thanks in advance
Regards
ClemensHi
The option is in layout structure adn has to be set in the next ALV function called, so if the program works in background mode it can call REUSE_ALV_LIST_DISPLAY instaed of CL_SALV_TABLE.
The call can be place in the END_OF_LIST event of ALV:
TYPE-POOLS: SLIS.
PERFORM BATCHTEST.
FORM BATCHTEST .
DATA:
LR_DATA TYPE REF TO DATA,
LO_SALV TYPE REF TO CL_SALV_TABLE.
FIELD-SYMBOLS:
<TABLE> TYPE TABLE.
DATA: T_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE.
DATA: L_PRINT TYPE SLIS_PRINT_ALV.
DATA: L_REPORT TYPE SY-REPID.
* dynamic table fpr T000
CREATE DATA LR_DATA TYPE TABLE OF T000.
ASSIGN LR_DATA->* TO <TABLE>.
SELECT * INTO TABLE <TABLE> FROM T000.
IF SY-BATCH = 'X'.
* In background only
L_PRINT-PRINT = 'X'. "Print ALV
L_PRINT-NO_PRINT_LISTINFOS = 'X'.
T_EVENTS-NAME = 'END_OF_LIST'. "Call event
T_EVENTS-FORM = 'END_OF_LIST'.
APPEND T_EVENTS.
ENDIF.
L_REPORT = SY-REPID.
* show table in grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPORT
I_STRUCTURE_NAME = 'T000'
IT_EVENTS = T_EVENTS[]
IS_PRINT = L_PRINT
TABLES
T_OUTTAB = <TABLE>
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.
CHECK SY-BATCH IS INITIAL.
* The form for the nex ALV is called by event END_OF_LIST if the
* program works in background
PERFORM NEXT_LIST.
ENDFORM. " BATCHTEST
FORM NEXT_LIST .
DATA:
LR_DATA TYPE REF TO DATA,
LO_SALV TYPE REF TO CL_SALV_TABLE.
FIELD-SYMBOLS:
<TABLE> TYPE TABLE.
DATA: LT_LAYOUT TYPE SLIS_LAYOUT_ALV.
* create another table
TRY.
CREATE DATA LR_DATA TYPE TABLE OF T100.
ASSIGN LR_DATA->* TO <TABLE>.
SELECT * INTO TABLE <TABLE> FROM T100 UP TO 100 ROWS.
IF SY-BATCH IS INITIAL. "Online
CL_SALV_TABLE=>FACTORY(
EXPORTING
LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>TRUE
IMPORTING
R_SALV_TABLE = LO_SALV
CHANGING
T_TABLE = <TABLE> ).
* display list
LO_SALV->DISPLAY( ).
ELSE. "In background
LT_LAYOUT-LIST_APPEND = 'X'. "Append new ALV list
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'T100'
IS_LAYOUT = LT_LAYOUT
TABLES
T_OUTTAB = <TABLE>
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.
ENDIF.
CATCH CX_SALV_MSG .
ASSERT 1 = 2.
ENDTRY.
ENDFORM. " NEXT_LIST
FORM END_OF_LIST.
PERFORM NEXT_LIST.
ENDFORM. "END_OF_LIST
Max -
Whi is the winner? ALV LIst or ALV Grid OO?
Hi Guys,
Hope you are all well.
My company is still mostly using the ALV List Function Modules when creating reports. Yes, they are using the SLIS pools.
I have written a template program for them to start doing things the OO way. That is to say, using ALV Grid Objects.
We are now thinking of COMPLETELY going over into ALV Grid Objects, but some of us are still arguing which one is best?
The biggest argument is :
Is ALV too "expensive" with regards to using system recources?
Please give me your thoughts as Im all for going for OO, but I would understand if it would make things slower.
Points will be awarded for useful arguments.
tks
ChristiaanSLIS is OLD, OBSOLETE DINOSAUR technology.
With the new classes you can create new reports really quickly and easily and add all sorts of functionality to them.
There's a small learning curve -- but what ought to appeal to management is that once you get the hang of it you can produce a report in hours (or even minutes) which done in the old way could take a week or more.
These days Human development time is far far more expensive than machine time so there's NO CONTEST.
The advantages in general of OO are too numerous to list here but if you look at the sample code I've listed here you can see how easy and quicklly you can get an application up and running even if you haven't got my Z_class definition listed in the program (it's a global class now defined with SE24).
With either cl_gui_alv_grid or even easier (if you don't need edit capability) the salv_table type class it only takes a few lines to code your program and display the grid.
All you ever now need to do in an alv program is the following.
1) define your data structures
2) use RTTI to generate dynamic field catalog from your data structures
3) create dynamic table
4) populate it
5) display grid.
You should have all the events etc you need such as cell selection etc etc.
Your whole code could be quite small.
For example I've got a generalized Z_cLass for my alv grid.
Now here's a sample program to display program names in the system. When I double click a program SE38 is entered and on exit unlike the standard sap transaction my list is re-displayed where I can choose another program.
Note how small the code is.
You won't be able to copy and run this program directly as you'll need the Z_class definitions.
In this Z_class there's also functionality for ON data change, multiple cell selection , toolbar additions etc.
These methods are available to EVERY program calling the class.
If you need the extra functionality using SLIS you have to program it in every time for each individual program.
You can therefore concentrate in your application program on just getting the data and displaying it. All the complicated functionality is in the Z_class.
Incidently using ALV classes can also render the whole idea of classical dynpros with Table controls as also obsolete.
program zzjimboprogs.
tables : trdirt.
include my_zdata. "data references to my Z_Class etc.
* Front end to call SE38 Program list
* When you use the search Program facility in SE38
* the system loses the LIST after you choose a program and enter
* transaction SE38
* double click on the Program module you want SE38 to use.
* After exiting SE38 you will return to the list .
types: begin of s_elements,
name type trdirt-name,
text type trdirt-text,
end of s_elements.
data: progname type trdirt-name.
data: wa_elements type s_elements.
selection-screen begin of block one with frame title text-t01.
select-options: s_prog for trdirt-name obligatory.
selection-screen end of block one.
at selection-screen.
initialization.
invoker = sy-repid. "Name of calling program for alv class.
start-of-selection.
create data dref type s_elements.
assign dref->* to <fs>.
i_gridtitle = 'Program List'.
invoker = sy-repid.
i_zebra = ' '.
i_edit = 'X'.
create object z_object
exporting
z_object = z_object
cfname = 'CCONTAINER1'.
assign z_object to <fs1>.
i_object = <fs1>.
call method i_object->build_dynamic_structures
exporting
my_line = <fs>
calling_program = invoker
importing
dy_table = dy_table
changing
it_fldcat = it_fldcat.
perform populate_dynamic_itab
changing dy_table.
perform modify_fldcat.
i_screen = '100'.
i_text = 'Prog List'.
perform display_grid
using
i_screen
i_text
it_fldcat
<dyn_table>.
end-of-selection.
form populate_dynamic_itab changing dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
select *
from trdirt
into corresponding fields of table <dyn_table>
where name in s_prog
and sprsl eq sy-langu.
endform.
form display_grid
using i_screen
i_text
field_catalog
dynamic_table.
call method i_object->display_data
exporting
i_gridtitle = i_gridtitle
i_edit = ' '
i_zebra = ' '
i_opt = ' '
title_text = i_text
program = invoker
screen_number = i_screen
z_object = i_object
changing
it_fldcat = field_catalog
gt_outtab = dynamic_table
e_ucomm = e_ucomm.
if e_ucomm = 'BACK'.
leave to screen 0.
else.
leave program.
endif.
endform.
form verwerk.
endform.
form refresh.
call method i_object->refresh_grid.
endform.
form dubbelklik using
e_row type lvc_s_row
e_column type lvc_s_col
es_row_no type lvc_s_roid.
read table <dyn_table> index e_row into wa_elements.
progname = wa_elements-name.
set parameter id 'RID' field progname.
call transaction 'SE38'.
perform refresh.
row_number-row_id = e_row.
call method z_object->set_cell
exporting
e_column = e_column
es_row_no = row_number.
endform.
form modify_fldcat.
col_name it_fldcat 1 'Programe' 25.
col_name it_fldcat 2 'description' 50.
endform. -
Extract ALV list to a file in the background
I am currently working on an ALV report which the user requires that a file be generated automatically based on the ALV list output. Any ideas? Thanks in advance.
Hello Emmanuel,
I have had the same problem, and i found no solution on the forums... So i have implemented my own solution: I implemented a child class, in order to add a new method write_file. This coding creates a file on the application server, considering the field catalog from the choosen variant. It can be enhanced in order to get the sort and the filter criteria (but if the file is exported to excel, the sort and filter can be managed within excel). Such a program can be run in background, and it works perfectly!
Sample coding:
REPORT z_alv_download_file.
CLASS LCL_GUI_ALV_GRID INHERITING FRO
Local child-class in order to implement a new method for *
download in a file in background *
CLASS lcl_gui_alv_grid DEFINITION INHERITING FROM cl_gui_alv_grid.
PUBLIC SECTION.
METHODS: write_file IMPORTING i_structure_name TYPE dd02l-tabname
is_variant TYPE disvariant
i_default TYPE char01
i_save TYPE char01
i_file TYPE fileextern
CHANGING it_outtab TYPE STANDARD TABLE.
ENDCLASS.
CLASS lcl_gui_alv_grid IMPLEMENTATION
Implementation of the new method write_file *
CLASS lcl_gui_alv_grid IMPLEMENTATION.
METHOD write_file.
Local types
TYPES: BEGIN OF ty_fieldnames,
field(60),
field2 TYPE help_info-tabname,
field3 TYPE help_info-fieldname,
key(1),
END OF ty_fieldnames.
Local data
DATA: lt_catalog TYPE lvc_t_fcat,
ls_catalog TYPE lvc_s_fcat,
lt_datatab TYPE TABLE OF hrdatatab,
ls_datatab TYPE hrdatatab,
lt_fieldnames TYPE TABLE OF ty_fieldnames,
ls_fieldnames TYPE ty_fieldnames,
ls_record TYPE string,
l_field(60) TYPE c,
l_nbcol TYPE i,
l_colpos TYPE i,
l_colpos_c(2) TYPE c,
l_fieldname(21) TYPE c VALUE 'ls_datatab-langtext '.
FIELD-SYMBOLS <f> TYPE ANY.
Call the grid display
CALL METHOD me->set_table_for_first_display
EXPORTING i_structure_name = i_structure_name
is_variant = is_variant
i_default = i_default
i_save = i_save
CHANGING it_outtab = it_outtab.
Get the field catalog according to the display variant which is used
CALL METHOD me->get_frontend_fieldcatalog
IMPORTING et_fieldcatalog = lt_catalog.
Get an internal table with only the fields from the field catalog
CALL FUNCTION 'ALV_CONVERT_DATA'
EXPORTING
alv_fieldcat = lt_catalog
TABLES
alv_datatab = it_outtab
hr_datatab = lt_datatab
hr_fieldnametab = lt_fieldnames.
Keep only the displayed fields from the field catalog
DELETE lt_catalog WHERE no_out = 'X'.
SORT lt_catalog BY col_pos DESCENDING.
READ TABLE lt_catalog INTO ls_catalog INDEX 1.
IF sy-subrc = 0.
CLEAR ls_record.
l_nbcol = ls_catalog-col_pos.
Open the file
OPEN DATASET i_file FOR OUTPUT IN TEXT MODE.
Write the column names
LOOP AT lt_fieldnames INTO ls_fieldnames.
CONDENSE ls_fieldnames-field.
CONCATENATE ls_record ls_fieldnames-field
INTO ls_record SEPARATED BY ';'.
ENDLOOP.
SHIFT ls_record.
TRANSFER ls_record TO i_file.
Write the lines
LOOP AT lt_datatab INTO ls_datatab.
CLEAR: l_colpos,
ls_record.
Condense the fields in a single string, separated by ';' (csv)
DO l_nbcol TIMES.
ADD 1 TO l_colpos.
CLEAR l_colpos_c.
l_colpos_c = l_colpos.
CONDENSE l_colpos_c.
l_fieldname+19(2) = l_colpos_c.
ASSIGN (l_fieldname) TO <f>.
WRITE <f> TO l_field.
CONDENSE l_field.
CONCATENATE ls_record l_field INTO ls_record SEPARATED BY ';'.
ENDDO.
SHIFT ls_record.
TRANSFER ls_record TO i_file.
ENDLOOP.
Close the file
CLOSE DATASET i_file.
ENDIF.
ENDMETHOD.
ENDCLASS.
MAIN PROGRAM
DATA: wo_alv TYPE REF TO lcl_gui_alv_grid,
wt_sflight TYPE TABLE OF sflight,
ws_variant TYPE disvariant.
PARAMETERS: p_file TYPE fileextern OBLIGATORY
DEFAULT '/usr/sap/.../file.csv',
p_vari TYPE slis_vari
DEFAULT 'DEFAULT'.
START-OF-SELECTION.
ws_variant-report = sy-repid.
ws_variant-username = sy-uname.
ws_variant-variant = p_vari.
SELECT * FROM sflight INTO TABLE wt_sflight.
CREATE OBJECT wo_alv EXPORTING i_parent = cl_gui_container=>screen0.
CALL METHOD wo_alv->write_file
EXPORTING i_structure_name = 'SFLIGHT'
is_variant = ws_variant
i_default = 'X'
i_save = 'A'
i_file = p_file
CHANGING it_outtab = wt_sflight.
Maybe you are looking for
-
my iphone4 says searching in the top left corner and i can not make calls or get calls how do i fix it so i have my service back
-
Exception in thread "main" java.util.NoSuchElementException
Hello there, I need to store resultset values in arrays. Following is my code: (Note : The function uses the jdbc connection with mysql that is return from other function.) public static void getResultSetInArray(Connection con) throws Exception Map l
-
MacPro shut down instaed Sleep after Mountain Lion Update
Sleep Mode works not longer after updateted to Mouintain Lion. It shut down and needs quite longer on a next Computer start - longer as if started normal after normal shut down before.
-
Reverse/Cancel Outbound Delivery and Billing documents
Hi all, My question is...How do you reverse/ Cancel Outbound delivery and billing documents and what will be the reversals in Accounting document and how are they updated. Regards
-
Dreamweaver CC generates one of 3 error messages when using find and replace is used more than twice in succession. "While executing onLoad in bc_afterSave.htm, the following JavaScript error(s) occurred: At line 188 of file C:\Program Files (x86)\Ad