Skip to Content

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

Data not getting selected in Background.

Hi Freinds

I have written a program which select the invoice data hourly basis and download it into a text file. Everything is file when I run the program in the foreground. (Interactvely). My issue is when I schedule this using SM36 to run in the background, it is not running properly. That means it is not picking up tha data and not giveing me spool report.

Whith here I am atttaching the program code for u'r reference. Pls help to solve this out. What do I have to do..? I am behind my schedile time pls help.

Regards

Thanura

REPORT ZTM_DOWNLOAD_INVDATA.

TYPES : BEGIN OF wa,

bukrs LIKE vbrk-bukrs, "Company Code

vbeln LIKE vbrk-vbeln, " Invoice No

posnr LIKE vbrp-posnr, " item no

fkdat LIKE vbrk-fkdat, " Date

kunag LIKE vbrk-kunag, " Sold to party Customer

matnr LIKE vbrp-matnr, " Material

fkimg LIKE vbrp-fkimg, " Billed qty

charg LIKE vbrp-charg, " expiry

knumv LIKE vbrk-knumv, "Number of the document condition

KWERT LIKE konv-KWERT, " invoice price

KWERT1 LIKE konv-KWERT, " invoice discount

END OF wa.

TABLES: vbrk.

DATA : it_sales TYPE STANDARD TABLE OF wa,

wa_sales TYPE wa.

RANGES : r_bwart FOR konv-kschl.

----


  • INITIALIZATION *

----


INITIALIZATION.

----


  • At selection screen *

----


PERFORM f001_getdata.

----


  • END-OF-SELECTION *

----


*&----


*

*& Form F001_GETDATA

*&----


*

FORM f001_getdata .

DATA: w_time(2) TYPE n,

w_timestr(6) TYPE c.

Data: p_bukrs LIKE vbrk-bukrs,

p_fkdat LIKE vbrk-fkdat.

w_time = sy-uzeit(2).

w_time = w_time - 1.

CONCATENATE '%' w_time '%' INTO w_timestr.

  • Discount condition list - 3100

r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'ZKMC'.

APPEND r_bwart TO r_bwart.

r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'ZKMG'.

APPEND r_bwart TO r_bwart.

r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'ZMGN'.

APPEND r_bwart TO r_bwart.

r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'ZCMG'.

APPEND r_bwart TO r_bwart.

r_bwart-sign = 'I'. r_bwart-option = 'EQ'. r_bwart-low = 'ZCDP'.

APPEND r_bwart TO r_bwart.

p_fkdat = sy-datum.

p_bukrs = '3100'.

SELECT abukrs avbeln bposnr afkdat akunag bmatnr bfkimg bcharg

a~knumv

FROM vbrk AS a

INNER JOIN vbrp AS b ON bvbeln = avbeln

INTO CORRESPONDING FIELDS OF TABLE it_sales

WHERE

a~bukrs = p_bukrs AND

fkdat = p_fkdat

AND a~erzet LIKE w_timestr.

DATA :w_KWERT LIKE konv-KWERT,

w_KWERT1 LIKE konv-KWERT.

LOOP AT it_sales INTO wa_sales.

  • Invoice price

SELECT SINGLE KWERT INTO w_KWERT

FROM konv

WHERE knumv = wa_sales-knumv

AND kschl = 'PR00'

AND kposn = wa_sales-posnr.

wa_sales-KWERT = w_KWERT.

MODIFY TABLE it_sales FROM wa_sales

TRANSPORTING KWERT.

  • invoice discount

SELECT SINGLE KWERT INTO w_KWERT1

FROM konv

WHERE knumv = wa_sales-knumv

AND kschl IN r_bwart

AND kposn = wa_sales-posnr.

wa_sales-KWERT1 = w_KWERT1.

MODIFY TABLE it_sales FROM wa_sales

TRANSPORTING KWERT1.

CLEAR wa_sales.

w_KWERT = 0.

w_KWERT1 = 0.

ENDLOOP.

DATA f_filename TYPE string.

DATA: rec(950) TYPE c,

v_line LIKE LINE OF it_sales,

w_fkimg TYPE string,

w1_kbetr TYPE string,

w2_kbetr TYPE string.

.

f_filename = '/usr/sap/DBI/INVD.txt'.

OPEN DATASET f_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

LOOP AT it_sales INTO wa_sales.

Clear rec.

rec(950) = v_line(56).

w_fkimg = wa_sales-fkimg.

w1_kbetr = wa_sales-KWERT.

w2_kbetr = wa_sales-KWERT1.

*

Concatenate wa_sales-bukrs ',' wa_sales-VBELN ',' wa_sales-kunag ','

wa_sales-fkdat ',' wa_sales-matnr ',' w_fkimg ',' w1_KBETR ','

wa_sales-charg ',' w2_kbetr

into rec.

Write rec.

TRANSFER rec TO f_filename.

ENDLOOP.

ENDIF.

CLOSE DATASET f_filename.

ENDFORM. " F001_GETDATA

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