Skip to Content
0
Former Member
Apr 04, 2009 at 03:54 AM

alv show in report but when see in spool (after run background job) there i

89 Views

my program have some error when i run result alv show in report but when see in spool (after run background job) there is no data, (other program can see result in spool)

Please help

here is some example of my program

********************************declare internal table*****************************

  • internal table output for BDC

data : begin of t_output occurs 0,

bukrs type anla-bukrs,

anln1 type anla-anln1,

anln2 type anla-anln2,

zugdt type anla-zugdt,

result(70) type c,

end of t_output.

*****get data from loop********************************

loop at t_anla.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_anla-anln1

IMPORTING

OUTPUT = t_anla-anln1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_anla-anln2

IMPORTING

OUTPUT = t_anla-anln2.

  • check record is correct or not

select single bukrs anln1 anln2 zugdt

into w_output

from anla

where bukrs = t_anla-bukrs and

anln1 = t_anla-anln1 and

anln2 = t_anla-anln2

  • zugdt = '00000000'

.

  • if record is correct

if sy-subrc = 0 and w_output-zugdt = '00000000'.

w_output-bukrs = t_anla-bukrs.

w_output-anln1 = t_anla-anln1.

w_output-anln2 = t_anla-anln2.

w_output-result = 'Yes : this asset can delete'.

append w_output to t_output.

  • if record is not correct

elseif sy-subrc = 0 and w_output-zugdt <> '00000000'.

  • there is error record this asset have value already

v_have_error = 'X'.

w_output-bukrs = t_anla-bukrs.

w_output-anln1 = t_anla-anln1.

w_output-anln2 = t_anla-anln2.

w_output-result = 'Error : this asset have value already'.

append w_output to t_output.

else.

  • there is error record this asset donot exist in table anla

v_have_error = 'X'.

w_output-bukrs = t_anla-bukrs.

w_output-anln1 = t_anla-anln1.

w_output-anln2 = t_anla-anln2.

w_output-result = 'Error : this asset doest not exist'.

append w_output to t_output.

endif.

*end of check record is correct or not

clear w_output.

endloop.

******************************show data in ALV***************************************************

  • show data from file in ALV

perform display_report_ALV.

&----


*& Form display_report_ALV

&----


form display_report_ALV.

DATA: LT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,

LT_EVENTS TYPE SLIS_T_EVENT,

LV_REPID LIKE SY-REPID.

PERFORM ALV_DEFINE_FIELD_CAT USING LT_FIELD_CAT.

PERFORM ALV_HEADER_BUILD USING T_LIST_TOP_OF_PAGE[].

PERFORM ALV_EVENTTAB_BUILD USING LT_EVENTS[].

LV_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = LV_REPID

IT_FIELDCAT = LT_FIELD_CAT

I_SAVE = 'A'

IT_EVENTS = LT_EVENTS[]

TABLES

T_OUTTAB = t_output

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC NE 0.

WRITE: / 'Return Code : ', SY-SUBRC,

'from FUNCTION REUSE_ALV_GRID_DISPLAY'.

ENDIF.

endform.

&----


*& Form alv_define_field_cat

&----


  • text

----


  • -->P_LT_FIELD_CAT text

----


FORM ALV_DEFINE_FIELD_CAT USING TB_FCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: WA_FIELDCAT LIKE LINE OF TB_FCAT,

LV_COL_POS TYPE I.

DEFINE FIELD_CAT.

CLEAR WA_FIELDCAT.

ADD 1 TO LV_COL_POS.

WA_FIELDCAT-FIELDNAME = &1.

WA_FIELDCAT-REF_TABNAME = &2.

WA_FIELDCAT-COL_POS = LV_COL_POS.

WA_FIELDCAT-KEY = &3.

WA_FIELDCAT-NO_OUT = &4.

WA_FIELDCAT-REF_FIELDNAME = &5.

WA_FIELDCAT-DDICTXT = 'M'.

IF NOT &6 IS INITIAL.

WA_FIELDCAT-SELTEXT_L = &6.

WA_FIELDCAT-SELTEXT_M = &6.

WA_FIELDCAT-SELTEXT_S = &6.

ENDIF.

WA_FIELDCAT-DO_SUM = &7.

WA_FIELDCAT-OUTPUTLEN = &8.

APPEND WA_FIELDCAT TO TB_FCAT.

END-OF-DEFINITION.

FIELD_CAT 'BUKRS' 'ANLA' 'X' '' 'BUKRS' 'Company Code' '' ''.

FIELD_CAT 'ANLN1' 'ANLA' 'X' '' 'ANLN1' 'Asset Number' '' ''.

FIELD_CAT 'ANLN2' 'ANLA' 'X' '' 'ANLN2' 'Asset Sub Number' '' ''.

  • FIELD_CAT 'ATEXT' 'T5EAE' 'X' '' 'ATEXT' 'Result' '' ''.

FIELD_CAT 'RESULT' '' 'X' '' 'RESULT' 'RESULT' '' ''.

ENDFORM. " alv_define_field_cat