2013 May 01 6:51 AM
Hi All,
I am facing an issue in ALV list display. The ALV is having lots of coloumns.
For that problem, I am using layout-colwidth_optimize to optimize the ALV display.
But in that case, in one of the decimal field column, I am getting '>' along with the value.
(Pls see the 'VONBT' col).
Now in case if I dont use col optimization, the lines in a records doesnt come in a single line.
I now find myself in a deadlock. If I use col optimise, I get that '>' sign. If I dont, I am not getting one single line.
Please suggest a way out.
Regards,
Saurabh.
2013 May 01 7:52 AM
Hi Saurabh,
In the field VNOBT, how much is the decimal places and how much does the actual value have? I think you should increase the number of decimal places.
Regards
Purnand
2013 May 01 8:13 AM
Can you please share your code with us. how are you calling ALV Layout and display FMs.
2013 May 01 10:08 AM
Hi Purnand,
VONBT is a standard field present in table T042E from which I am fetching the data.
So I think it wont be possible to have more decimals.
Rama,
The requirement was such that I had created a Z- FM where I am passing a program name, the final table, the final table structure and the Tables being used in the particular program.
Now this code will get the fields from the structure using a FM and then fetch the details of the fields from DD03L and DD04T. Then have a field selector from where some of the fields are selected for ALV display out of all the fields in the program.
Then from these fields and the details we build the fieldcatalog. The code is given below :
FUNCTION ZFI_LHM_GET_ALV.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(PROGRAM) LIKE SY-REPID
*" VALUE(TABNAME) LIKE RSRD1-TBMA_VAL
*" TABLES
*" OUTPUT_TABLE
*" TABUSE STRUCTURE DD03L
*"----------------------------------------------------------------------
TYPE-POOLS:SLIS.
TABLES:DD03L, DD04T.
TYPES:BEGIN OF TY_FNAME, "To hold the field names
FLD LIKE DD03L-FIELDNAME,
DDTXT TYPE AS4TEXT,
END OF TY_FNAME.
TYPES:BEGIN OF TY_FLTXT, "To hold the field names
FIELDNAME LIKE DD03L-FIELDNAME,
ROLLNAME TYPE DD03L-ROLLNAME,
DDTEXT TYPE AS4TEXT,
SCRTEXT_L TYPE SCRTEXT_L,
SCRTEXT_M TYPE SCRTEXT_M,
LENG TYPE DDLENG,
END OF TY_FLTXT.
DATA:GT_FNAME TYPE TABLE OF TY_FNAME,
GT_SNAME TYPE TABLE OF TY_FNAME,
GT_FLTXT TYPE STANDARD TABLE OF TY_FLTXT,
GT_FIELDS TYPE STANDARD TABLE OF RSTRUCINFO,
GT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
GT_DD03L TYPE STANDARD TABLE OF DD03L,
GT_DD04V TYPE STANDARD TABLE OF DD04V,
GT_FLDLST TYPE STANDARD TABLE OF TY_FLTXT.
DATA:GWA_FLTXT TYPE TY_FLTXT,
GWA_FNAME LIKE LINE OF GT_FNAME,
GA_FNAME LIKE LINE OF GT_FNAME,
GWA_FCAT LIKE LINE OF GT_FCAT,
GWA_DD04V TYPE DD04V,
GWA_LAYOUT TYPE SLIS_LAYOUT_ALV,
GWA_FIELDS TYPE RSTRUCINFO.
DATA:LV_CNT TYPE I VALUE 1,
LV_FLOUT TYPE SY-SUBRC,
LV_CHAR TYPE C,
LV_TXTLEN TYPE I,
LV_TAB TYPE TABNAME,
WA_TABUSE TYPE DD03L.
GWA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GWA_LAYOUT-NO_MIN_LINESIZE = 'X'.
GWA_LAYOUT-ZEBRA = 'X'.
GWA_LAYOUT-MAX_LINESIZE = 3000.
LOOP AT TABUSE INTO WA_TABUSE.
LV_TAB = WA_TABUSE-TABNAME.
TRANSLATE WA_TABUSE-TABNAME TO UPPER CASE.
MODIFY TABUSE FROM WA_TABUSE
* WHERE tabname = lv_tab
TRANSPORTING TABNAME.
ENDLOOP.
SELECT
A~FIELDNAME
A~ROLLNAME
B~DDTEXT
B~SCRTEXT_L
B~SCRTEXT_M
A~LENG
INTO CORRESPONDING FIELDS OF TABLE GT_FLTXT
FROM DD03L AS A INNER JOIN
DD04T AS B
ON ( A~ROLLNAME = B~ROLLNAME AND
B~AS4LOCAL = 'A' AND
* b~as4vers = a~as4vers and
B~DDLANGUAGE = SY-LANGU )
FOR ALL ENTRIES IN TABUSE
WHERE A~TABNAME = TABUSE-TABNAME.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
PROGRAM = PROGRAM
FIELDNAME = TABNAME
TABLES
COMPONENTS = GT_FIELDS.
LOOP AT GT_FIELDS INTO GWA_FIELDS.
READ TABLE GT_FLTXT INTO GWA_FLTXT WITH KEY
FIELDNAME = GWA_FIELDS-COMPNAME.
IF SY-SUBRC = 0.
APPEND GWA_FLTXT TO GT_FLDLST.
ELSE.
GWA_FLTXT-FIELDNAME = GWA_FIELDS-COMPNAME.
GWA_FLTXT-DDTEXT = GWA_FIELDS-COMPNAME.
GWA_FLTXT-SCRTEXT_L = GWA_FIELDS-COMPNAME.
GWA_FLTXT-SCRTEXT_M = GWA_FIELDS-COMPNAME.
GWA_FLTXT-LENG = GWA_FIELDS-LENG.
APPEND GWA_FLTXT TO GT_FLDLST.
ENDIF.
CLEAR GWA_FLTXT.
ENDLOOP.
LOOP AT GT_FLDLST INTO GWA_FLTXT.
IF NOT GWA_FLTXT-DDTEXT IS INITIAL.
CONCATENATE GWA_FLTXT-FIELDNAME '(' GWA_FLTXT-DDTEXT ')'
INTO GWA_FNAME.
ELSE.
IF NOT GWA_FLTXT-SCRTEXT_L IS INITIAL.
CONCATENATE GWA_FLTXT-FIELDNAME '(' GWA_FLTXT-SCRTEXT_L ')'
INTO GWA_FNAME.
ELSE.
CONCATENATE GWA_FLTXT-FIELDNAME '(' GWA_FLTXT-SCRTEXT_M ')'
INTO GWA_FNAME.
ENDIF.
ENDIF.
APPEND GWA_FNAME TO GT_FNAME.
CLEAR GWA_FNAME.
ENDLOOP.
DATA : IT_ZZFIELDS TYPE STANDARD TABLE OF ZZFIELDS,
WA_ZZFIELDS TYPE ZZFIELDS.
SELECT * FROM ZZFIELDS
INTO TABLE IT_ZZFIELDS
WHERE UNAME = SY-UNAME
AND PROG_NAME = PROGRAM.
IF SY-SUBRC EQ 0.
SORT IT_ZZFIELDS BY FIELD_IDX.
CLEAR : WA_ZZFIELDS, GWA_FNAME, GA_FNAME.
REFRESH: GT_SNAME. "gt_sname.
LOOP AT IT_ZZFIELDS INTO WA_ZZFIELDS.
GWA_FNAME-FLD = WA_ZZFIELDS-FLD.
GWA_FNAME-DDTXT = WA_ZZFIELDS-FLD.
APPEND GWA_FNAME TO GT_SNAME.
READ TABLE GT_FNAME INTO GA_FNAME WITH KEY FLD = GWA_FNAME-FLD.
IF SY-SUBRC = 0.
DELETE GT_FNAME INDEX SY-TABIX.
ENDIF.
CLEAR : WA_ZZFIELDS, GWA_FNAME.
ENDLOOP.
DATA : RET TYPE SY-SUBRC.
CALL FUNCTION 'ZFIELD_CHOICE_NEW'
EXPORTING
MAXFIELDS = 100
TITEL1 = 'Total Fields'
TITEL2 = 'Selected Fields'
IMPORTING
RETURN_CODE = RET
FLOUT_CH = LV_FLOUT
TABLES
FIELDTABIN = GT_FNAME
SELFIELDS = GT_SNAME
EXCEPTIONS
NO_TAB_FIELD_INPUT = 1
TO_MANY_SELFIELDS_ENTRIES = 2
OTHERS = 3.
IF SY-SUBRC = 0.
IF RET = 4.
LEAVE LIST-PROCESSING.
ELSE.
IF GT_SNAME IS INITIAL.
MESSAGE S028(ZM).
IF RET = 1.
REFRESH: IT_ZZFIELDS.
DELETE FROM ZZFIELDS
WHERE PROG_NAME = PROGRAM
AND UNAME = SY-UNAME.
COMMIT WORK.
ENDIF.
ELSEIF RET = 1.
REFRESH: IT_ZZFIELDS.
DELETE FROM ZZFIELDS
WHERE PROG_NAME = PROGRAM
AND UNAME = SY-UNAME.
COMMIT WORK.
CLEAR GWA_FNAME.
LOOP AT GT_SNAME INTO GWA_FNAME.
WA_ZZFIELDS-FIELD_IDX = SY-TABIX.
WA_ZZFIELDS-UNAME = SY-UNAME.
WA_ZZFIELDS-PROG_NAME = PROGRAM.
WA_ZZFIELDS-FLD = GWA_FNAME-FLD.
APPEND WA_ZZFIELDS TO IT_ZZFIELDS.
CLEAR : WA_ZZFIELDS, GWA_FNAME.
ENDLOOP.
IF NOT IT_ZZFIELDS IS INITIAL.
* SORT it_zzfields BY field_idx.
MODIFY ZZFIELDS FROM TABLE IT_ZZFIELDS.
COMMIT WORK.
IF SY-SUBRC = 0.
MESSAGE I029(ZM).
* CALL FUNCTION 'POPUP_TO_INFORM'
* EXPORTING
* titel = 'Field Variant'
* txt1 = 'Your selected fields'
* txt2 = 'have been saved.'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
CALL FUNCTION 'ZFIELD_CHOICE_NEW'
EXPORTING
MAXFIELDS = 100
TITEL1 = 'Total Fields'
TITEL2 = 'Selected Fields'
INFO_TEXT = 'Use Save to remember your choice'
IMPORTING
RETURN_CODE = RET
FLOUT_CH = LV_FLOUT
TABLES
FIELDTABIN = GT_FNAME
SELFIELDS = GT_SNAME
EXCEPTIONS
NO_TAB_FIELD_INPUT = 1
TO_MANY_SELFIELDS_ENTRIES = 2
OTHERS = 3.
IF SY-SUBRC = 0.
IF GT_SNAME IS INITIAL.
MESSAGE S028(ZM).
ELSE.
CLEAR GWA_FNAME.
REFRESH IT_ZZFIELDS.
LOOP AT GT_SNAME INTO GWA_FNAME.
WA_ZZFIELDS-FIELD_IDX = SY-TABIX.
WA_ZZFIELDS-UNAME = SY-UNAME.
WA_ZZFIELDS-PROG_NAME = PROGRAM.
WA_ZZFIELDS-FLD = GWA_FNAME-FLD.
APPEND WA_ZZFIELDS TO IT_ZZFIELDS.
CLEAR : WA_ZZFIELDS, GWA_FNAME.
ENDLOOP.
IF NOT IT_ZZFIELDS IS INITIAL AND RET = 1.
* SORT it_zzfields ASCENDING BY field_idx.
MODIFY ZZFIELDS FROM TABLE IT_ZZFIELDS.
COMMIT WORK.
IF SY-SUBRC = 0.
MESSAGE I029(ZM).
* CALL FUNCTION 'POPUP_TO_INFORM'
* EXPORTING
* titel = 'Field Variant'
* txt1 = 'Your selected fields '
* txt2 = 'have been saved.'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
LOOP AT GT_SNAME INTO GWA_FNAME.
SPLIT GWA_FNAME AT '(' INTO GWA_FNAME-FLD GWA_FNAME-DDTXT.
SPLIT GWA_FNAME-DDTXT AT ')' INTO GWA_FNAME-DDTXT LV_CHAR.
GWA_FCAT-COL_POS = LV_CNT.
GWA_FCAT-FIELDNAME = GWA_FNAME-FLD.
READ TABLE GT_FLDLST INTO GWA_FLTXT WITH KEY
FIELDNAME = GWA_FNAME-FLD.
IF SY-SUBRC = 0.
IF LV_FLOUT = 0.
LV_TXTLEN = STRLEN( GWA_FNAME-FLD ).
IF LV_TXTLEN > GWA_FLTXT-LENG.
GWA_FCAT-OUTPUTLEN = LV_TXTLEN.
ELSE.
GWA_FCAT-OUTPUTLEN = GWA_FLTXT-LENG.
ENDIF.
ELSE.
IF GWA_FLTXT-DDTEXT <> ''.
LV_TXTLEN = STRLEN( GWA_FLTXT-DDTEXT ).
ELSEIF GWA_FLTXT-SCRTEXT_M <> ''.
LV_TXTLEN = STRLEN( GWA_FLTXT-SCRTEXT_M ).
ELSEIF GWA_FLTXT-SCRTEXT_L <> ''.
LV_TXTLEN = STRLEN( GWA_FLTXT-SCRTEXT_L ).
ENDIF.
IF LV_TXTLEN > GWA_FLTXT-LENG.
GWA_FCAT-OUTPUTLEN = LV_TXTLEN.
ELSE.
GWA_FCAT-OUTPUTLEN = GWA_FLTXT-LENG.
ENDIF.
ENDIF.
IF LV_FLOUT = 0.
GWA_FCAT-SELTEXT_L = GWA_FNAME-FLD.
ELSE.
IF GWA_FLTXT-DDTEXT <> ''.
GWA_FCAT-SELTEXT_L = GWA_FLTXT-DDTEXT.
ELSEIF GWA_FLTXT-SCRTEXT_M <> ''.
GWA_FCAT-SELTEXT_L = GWA_FLTXT-SCRTEXT_M.
ELSEIF GWA_FLTXT-SCRTEXT_L <> ''.
GWA_FCAT-SELTEXT_L = GWA_FLTXT-SCRTEXT_L.
ENDIF.
ENDIF.
ENDIF.
GWA_FCAT-OUTPUTLEN = GWA_FCAT-OUTPUTLEN + 5.
GWA_FCAT-JUST = 'L'.
* IF NOT gwa_fname-ddtxt IS INITIAL.
* gwa_fcat-seltext_m = gwa_fname-ddtxt.
* ELSE.
* gwa_fcat-seltext_m = gwa_fname-fld.
* ENDIF.
APPEND GWA_FCAT TO GT_FCAT.
LV_CNT = LV_CNT + 1.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IS_LAYOUT = GWA_LAYOUT
IT_FIELDCAT = GT_FCAT
TABLES
T_OUTTAB = OUTPUT_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.
ENDFUNCTION.
2013 May 02 4:40 AM
why don't you use CL_GUI_ALV_GRID class to do the job, appears more agility?
2013 May 02 7:27 AM
Hi
Please do one thing as you are using list display FM in the report statement of your program try to change the LINE-SIZE to 400 or something and see what happens.
I believe it will be work.
Thanks
2013 May 02 5:31 AM
Hi Saurabh,
Can you use ALV Grid display instead of ALV list display with Horizontal and Vertical scrolling. The symbol '>' might be a indicator that there is more data in those cells. Also check the values in the statement
GWA_FCAT-OUTPUTLEN = LV_TXTLEN.
For that column I think the value is set same as the column header. That is what is causing the problem. You can try to set the GWA_FCAT-OUTPUTLEN for that filed to some greater value like 20 or 15 whichever is suitable for that column content.
Check the following document. This will give you a fair idea how you can achieve the same.
http://sap-partner.hu/ABAP_HELP_INFO/An%20Easy%20Reference%20for%20ALV%20Grid%20Control.pdf
Cheers,
Arindam