Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to give a space

Former Member
0 Kudos

hi,

i am working on report i have initialise

g_target type i,

g_delay type p decimals 2.

i am calculating g_target as difference between two date, but if there is no value for any one of the date, then the g_target has to empty, but it is showing 0, i don' want to have 0.

Promise to award points.

regards,

anitha

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos

i assume that you want this to happen while writing the results to ABAP list?

its showing zero because the initial value for type i field is 0.

while writing you can avoid zero by adding NO-ZERO addition.

IF g_target = 0.

WRITE g_target NO-ZERO .

else.

WRITE g_target .

ENDIF.

Hope this helps.

Regards

Raja

7 REPLIES 7

athavanraja
Active Contributor
0 Kudos

i assume that you want this to happen while writing the results to ABAP list?

its showing zero because the initial value for type i field is 0.

while writing you can avoid zero by adding NO-ZERO addition.

IF g_target = 0.

WRITE g_target NO-ZERO .

else.

WRITE g_target .

ENDIF.

Hope this helps.

Regards

Raja

0 Kudos

thanks for the reply,

i dont want it to write, i need to assign it to a variable and pass it print through alv_grid display

0 Kudos

if its for ALV display you can set NO_ZERO to 'X' in the field catalog for that field.

Regards

Raja

0 Kudos

Hi

IF g_target is just a variable and you have different field in the Final internal table which you are using for grid diplay. then use

Write g_target to itab-field no-zero.

make sure that this internal table field should be Char, only then a space is displayed else for numeric field you get a zero by default. so you have to modify the field catalog as said by Raja.

Regards

Santosh

0 Kudos

can u provide a sample coding for that, i am not able to get exactly what u are trying to tell, if u show me a small coding then i think it will be useful.

promise to reward points.

regards,

anitha

0 Kudos

clear it_fieldcat.

it_fieldcat-fieldname = 'MATNR'.

it_fieldcat-tabname = 'IT_MARA'.

it_fieldcat-seltext = 'Material No'.

<b>it_fieldcat-no_zero = 'X'.</b>

append it_fieldcat.

If ur problem is solves please reward points and close

Message was edited by: chandrasekhar jagarlamudi

0 Kudos

Hi

I am pasting the whole code of a program below. check that out for the output.

I have differented the actaual code required for you by making it bold...

Regards

Santosh

_________________________________________________________

*&----


*

*& Report ZSAMPLE_ALVV2

*&

*&----


*

*&

*&

*&----


*

REPORT ZSAMPLE_ALVV2.

  • ALV

type-pools: slis.

  • DB-Table

tables sflight.

  • Includes

include .

*

constants:

gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.

data: gt_fieldcat type slis_t_fieldcat_alv,

gs_layout type slis_layout_alv,

gs_print type slis_print_alv,

gt_sort type slis_t_sortinfo_alv,

gt_sp_group type slis_t_sp_group_alv,

gt_events type slis_t_event.

data: begin of gt_sflight occurs 0.

include structure sflight.

data: add1,

carrname like scarr-carrname,

box,

lights.

data: end of gt_sflight.

*

data: g_repid like sy-repid.

data: gt_list_top_of_page type slis_t_listheader.

*----


*

select-options:

carrid for sflight-carrid,

connid for sflight-connid,

fldate for sflight-fldate.

selection-screen skip 1.

  • Parameters

parameters:

p_maxrow type i default 30.

selection-screen skip 1.

*PARAMETERS:

  • P_ZEBRA AS CHECKBOX DEFAULT ' '.

*----


*

data: g_boxnam type slis_fieldname value 'BOX',

p_f2code like sy-ucomm value '&ETA',

p_lignam type slis_fieldname value 'LIGHTS',

g_save(1) type c,

g_default(1) type c,

g_exit(1) type c,

gx_variant like disvariant,

g_variant like disvariant.

*----


*

initialization.

g_repid = sy-repid.

perform e01_fieldcat_init using gt_fieldcat[].

perform e03_eventtab_build using gt_events[].

perform e04_comment_build using gt_list_top_of_page[].

perform e06_t_sort_build using gt_sort[].

perform e07_sp_group_build using gt_sp_group[].

g_save = 'A'.

perform variant_init.

*----


*

start-of-selection.

perform selection.

end-of-selection.

perform zebra_layout_build using gs_layout.

  • Call ABAP/4 List Viewer

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_background_id = 'ALV_BACKGROUND'

i_callback_program = g_repid

i_structure_name = 'SFLIGHT'

is_layout = gs_layout

it_fieldcat = gt_fieldcat[]

  • IT_EXCLUDING =

it_special_groups = gt_sp_group[]

it_sort = gt_sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = g_default

i_save = g_save

is_variant = g_variant

it_events = gt_events[]

  • IT_EVENT_EXIT =

is_print = gs_print

  • 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 =

tables

t_outtab = gt_sflight.

*----


*

  • FORM E01_FIELDCAT_INIT *

*----


*

  • ........ *

*----


*

  • --> E01_LT_FIELDCAT *

*----


*

form e01_fieldcat_init using e01_lt_fieldcat type slis_t_fieldcat_alv.

data: ls_fieldcat type slis_fieldcat_alv.

*

clear ls_fieldcat.

  • LS_FIELDCAT-COL_POS = 1.

ls_fieldcat-fieldname = 'ADD1'.

ls_fieldcat-reptext_ddic = '?'.

ls_fieldcat-outputlen = 1.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-input = 'X'.

ls_fieldcat-sp_group = 'A'.

append ls_fieldcat to e01_lt_fieldcat.

*

clear ls_fieldcat.

ls_fieldcat-fieldname = 'CARRNAME'.

ls_fieldcat-col_pos = 2.

ls_fieldcat-key = 'X'.

ls_fieldcat-key_sel = 'X'.

ls_fieldcat-ref_tabname = 'SCARR'.

append ls_fieldcat to e01_lt_fieldcat.

*

clear ls_fieldcat.

ls_fieldcat-fieldname = 'SEATSOCC'.

ls_fieldcat-do_sum = 'X'.

append ls_fieldcat to e01_lt_fieldcat.

*

+

clear ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSOCC_B'.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-no_zero = 'X'.
append ls_fieldcat to e01_lt_fieldcat.

+

clear ls_fieldcat.

ls_fieldcat-fieldname = 'PRICE'.

ls_fieldcat-do_sum = 'X'.

append ls_fieldcat to e01_lt_fieldcat.

*

clear ls_fieldcat.

ls_fieldcat-col_pos = 1.

ls_fieldcat-fieldname = 'CARRID'.

  • ls_fieldcat-ref_fieldname = 'SFLIGHT'.

ls_fieldcat-text_fieldname = 'CARRNAME'.

  • append ls_fieldcat to e01_lt_fieldcat.

*

  • clear ls_fieldcat.

ls_fieldcat-fieldname = 'CARRID'.

ls_fieldcat-key_sel = 'X'.

ls_fieldcat-no_out = 'X'.

ls_fieldcat-outputlen = 7.

append ls_fieldcat to e01_lt_fieldcat.

endform. "E01_FIELDCAT_INIT

*----


*

  • FORM E02_DATA_ADD *

*----


*

  • ........ *

*----


*

  • --> E02_LT_SFLIGHT *

*----


*

form e02_data_add tables e02_lt_sflight structure gt_sflight.

loop at e02_lt_sflight.

if sy-tabix > 10.

e02_lt_sflight-add1 = 'A'.

e02_lt_sflight-box = 'X'.

e02_lt_sflight-lights = '3'.

else.

if sy-tabix = 1.

e02_lt_sflight-lights = '2'.

else.

e02_lt_sflight-lights = '1'.

endif.

endif.

modify e02_lt_sflight.

endloop.

endform. "E02_DATA_ADD

*----


*

  • FORM E03_EVENTTAB_BUILD *

*----


*

  • ........ *

*----


*

  • --> E03_LT_EVENTS *

*----


*

form e03_eventtab_build using e03_lt_events type slis_t_event.

data: ls_event type slis_alv_event.

*

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = e03_lt_events.

read table e03_lt_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 e03_lt_events.

endif.

endform. "E03_EVENTTAB_BUILD

*----


*

  • FORM E04_COMMENT_BUILD *

*----


*

  • ........ *

*----


*

  • --> E04_LT_TOP_OF_PAGE *

*----


*

form e04_comment_build using e04_lt_top_of_page type slis_t_listheader.

data: ls_line type slis_listheader.

*

  • Listenüberschrift: Typ H

clear ls_line.

ls_line-typ = 'H'.

  • LS_LINE-KEY: not used for this type

ls_line-info = text-100.

append ls_line to e04_lt_top_of_page.

  • Kopfinfo: Typ S

clear ls_line.

ls_line-typ = 'S'.

ls_line-key = text-101.

ls_line-info = text-102.

append ls_line to e04_lt_top_of_page.

ls_line-key = text-103.

ls_line-info = text-104.

append ls_line to e04_lt_top_of_page.

  • Aktionsinfo: Typ A

clear ls_line.

ls_line-typ = 'A'.

  • LS_LINE-KEY: not used for this type

ls_line-info = text-105.

append ls_line to e04_lt_top_of_page.

endform. "E04_COMMENT_BUILD

*----


*

  • FORM E05_LAYOUT_BUILD *

*----


*

  • ........ *

*----


*

  • zebra_LS_LAYOUT *

*----


*

form zebra_layout_build using zebra_ls_layout type slis_layout_alv.

zebra_ls_layout-zebra = 'X'. " P_ZEBRA.

endform. "zebra_LAYOUT_BUILD

*----


*

  • FORM E06_T_SORT_BUILD *

*----


*

  • ........ *

*----


*

  • --> E06_LT_SORT *

*----


*

form e06_t_sort_build using e06_lt_sort type slis_t_sortinfo_alv.

data: ls_sort type slis_sortinfo_alv.

*

  • ls_sort-fieldname = 'CARRID'.

  • ls_sort-spos = 1.

  • ls_sort-up = 'X'.

  • ls_sort-subtot = 'X'.

  • append ls_sort to e06_lt_sort.

clear ls_sort.

ls_sort-fieldname = 'CARRNAME'.

ls_sort-spos = 1.

ls_sort-up = 'X'.

  • ls_sort-subtot = 'X'.

append ls_sort to e06_lt_sort.

clear ls_sort.

ls_sort-fieldname = 'CONNID'.

ls_sort-spos = 2.

ls_sort-up = 'X'.

  • ls_sort-subtot = 'X'.

append ls_sort to e06_lt_sort.

endform. "E06_T_SORT_BUILD

*----


*

  • FORM E07_SP_GROUP_BUILD *

*----


*

  • ........ *

*----


*

  • --> E07_LT_SP_GROUP *

*----


*

form e07_sp_group_build using e07_lt_sp_group type slis_t_sp_group_alv.

data: ls_sp_group type slis_sp_group_alv.

*

clear ls_sp_group.

ls_sp_group-sp_group = 'A'.

ls_sp_group-text = text-005.

append ls_sp_group to e07_lt_sp_group.

endform. "E07_SP_GROUP_BUILD

*----


*

  • FORM SELECTION *

*----


*

  • ........ *

*----


*

form selection.

select * into corresponding fields of table gt_sflight from

( sflight left join scarr

on sflight~carrid = scarr~carrid )

up to p_maxrow rows

where sflight~carrid in carrid

and sflight~connid in connid

and sflight~fldate in fldate.

*

perform e02_data_add tables gt_sflight.

endform. "SELECTION

*----


*

  • FORM TOP_OF_PAGE *

*----


*

  • ........ *

*----


*

form top_of_page.

*

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

  • i_logo = 'HTMLCNTL_TESTHTM2_SAPLOGO'

i_logo = 'ENJOYSAP_LOGO'

it_list_commentary = gt_list_top_of_page.

endform. "TOP_OF_PAGE

*&----


*

*& Form VARIANT_INIT

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form variant_init.

*

clear g_variant.

g_variant-report = g_repid.

endform. " VARIANT_INIT

_________________________________________________________