Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Doubt in function module...Urgent!!

hii all

I want to find the difference between sy-datum and BLDAT and have to get only the days value...

for eg...

sydatum(28.11.2007) - bldat(24.11.2007)= Days(4)

4 must the result... so i used the function module C14B_DIFF_BT_2_DATES..

but im unable to get the result...

my code is.....

&----


*& Report ZAGE1

*&

&----


*&

*&

&----


REPORT ZAGE1.

type-pools : slis,icon.

tables : bsid,kna1,knvv.

data : d_fieldcat type slis_t_fieldcat_alv,

d_fieldcat_wa type slis_fieldcat_alv.

data : begin of itab_bsid occurs 0,

kunnr like bsid-kunnr,

bukrs like bsid-bukrs,

bldat like bsid-bldat,

waers like bsid-waers,

belnr like bsid-belnr,

end of itab_bsid.

data : begin of itab_kna1 occurs 0,

kunnr like kna1-kunnr,

end of itab_kna1.

data : begin of itab_knvv occurs 0,

kunnr like knvv-kunnr,

zterm like knvv-zterm,

end of itab_knvv.

data : begin of itab_key occurs 0,

kunnr like bsid-kunnr,

bukrs like bsid-bukrs,

bldat like bsid-bldat,

waers like bsid-waers,

belnr like bsid-belnr,

zterm like knvv-zterm,

due type i,

end of itab_key.

selection-screen : begin of block blk1 with frame title text-001.

parameters : p_cc like bsid-bukrs.

selection-screen : end of block blk1.

select distinct kunnr bukrs bldat waers belnr from bsid into corresponding fields of table itab_bsid where bukrs = p_cc.

if not itab_bsid[] is initial.

select kunnr from kna1 into corresponding fields of table itab_kna1 for all entries in itab_bsid where kunnr = itab_bsid-kunnr.

if not itab_kna1[] is initial.

select kunnr zterm from knvv into corresponding fields of table itab_knvv for all entries in itab_kna1 where kunnr = itab_kna1-kunnr.

endif.

endif.

loop at itab_bsid.

itab_key-kunnr = itab_bsid-kunnr.

itab_key-bukrs = itab_bsid-bukrs.

itab_key-bldat = itab_bsid-bldat.

itab_key-waers = itab_bsid-waers.

itab_key-belnr = itab_bsid-belnr.

append itab_key.

clear itab_key.

endloop.

sort itab_key by kunnr.

loop at itab_key.

read table itab_knvv with key kunnr = itab_key-kunnr.

if sy-subrc = 0.

itab_key-zterm = itab_knvv-zterm.

modify itab_key transporting zterm.

endif.

endloop.

d_fieldcat_wa-fieldname = 'KUNNR'.

d_fieldcat_wa-seltext_l = 'CUSTOMER'.

d_fieldcat_wa-col_pos = 1.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'BUKRS'.

d_fieldcat_wa-seltext_l = 'COMPANY CODE'.

d_fieldcat_wa-col_pos = 2.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'WAERS'.

d_fieldcat_wa-seltext_l = 'CURRENCY'.

d_fieldcat_wa-col_pos = 3.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'BLDAT'.

d_fieldcat_wa-seltext_l = 'DOCUMENT DATE'.

d_fieldcat_wa-col_pos = 4.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'BELNR'.

d_fieldcat_wa-seltext_l = 'DOCUMENT NO'.

d_fieldcat_wa-col_pos = 5.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

d_fieldcat_wa-fieldname = 'ZTERM'.

d_fieldcat_wa-seltext_l = 'PAYMENT TERMS'.

d_fieldcat_wa-col_pos = 6.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

*data : due type i.

loop at itab_key.

CALL FUNCTION 'C14B_DIFF_BT_2_DATES'

EXPORTING

I_DATE_FROM = itab_key-bldat

I_DATE_TO = sy-datum

IMPORTING

E_DAYS = itab_key-due

  • E_MONTHS = months

  • E_YEARS = years

  • EXCEPTIONS

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

append itab_key.

endloop.

d_fieldcat_wa-fieldname = 'DUE'.

d_fieldcat_wa-seltext_l = 'DUE DATE'.

d_fieldcat_wa-col_pos = 7.

append d_fieldcat_wa to d_fieldcat.

clear d_fieldcat_wa.

data : gd_repid like sy-repid.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = gd_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_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = d_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = itab_key[]

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

Urgent plz help me....!!

Regards

Asha

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question