Application Development and Automation 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: 
Read only

Invoice Data Download

Former Member
0 Likes
1,955

Hi Friends,

I have an urgent requirement, pls help me to solve this out.

I needs to download invoice data to a text file hourly basis.

Tables are vbrk & vbrp.

Fields are bukrs,vbeln, posnr,fkdat,kunag,matnr,fkimg,charg,knumv

It should run as s schedule job in background.

How to do it?

If u all can give me a sample abap program..it going to be a great help

Early attention appreciated.

Best Regards

Thanura

Hi Friends,

I have an urgent requirement, pls help me to solve this out.

I needs to download invoice data to a text file hourly basis.

Tables are vbrk & vbrp.

Fields are bukrs,vbeln, posnr,fkdat,kunag,matnr,fkimg,charg,knumv

It should run as s schedule job in background.

How to do it?

If u all can give me a sample abap program..it going to be a great help

Early attention appreciated.

Best Regards

Thanura

8 REPLIES 8
Read only

Former Member
0 Likes
1,473

hi thanura,

->select the req data from VBRK & VBRP using inner join

based on the key fields of the tables and Selection screen

fields and move it into one internal table.

->use GUI_DOWNLOAD fm to transfer the data from internal table to flat file.

->Schedule this program in background mode on hourly basis using SM37 & SM36 tcodes .

<b><i>reward points if useful</i></b>

Chandra

Read only

0 Likes
1,473

HI,

To my knowledge GUI_DOWNLOAD is not working in background mode.

How do I schedule the download in background mode?

Regards

Thanura

Read only

Former Member
0 Likes
1,473

Hello Thanura,

As u know which are the tables involved and what data to extract from them, so write a program to extract all the data into an internal table and then use OPEN DATASET to writ the data on to the application server. This Job can be scheduled inbackground as per your requiments and executed. However housekeeping activities of the file needs to be decided based on whatever is your requirements.

Read only

0 Likes
1,473

Hi,

I have done the way u have mentioned, but my issue is when I schedule the program using SM36 hourly basis,

Sometimes it is downloading the data sometimes not. I can't find any patter or any thing when it is not downloading.

Is there any special areas which I have to look why it is not downloading continuously.

Appreciate u help on this.

Regards

Thanura

Read only

Former Member
0 Likes
1,473

Hi,

question is what are you doing with the file on the application server? Is it transferred somewhere else or pulled by an ftp procudere. Is the file overwritten with the next job run. Do you select always all data or new created only? Do you alway use the same filename and path?

I would consider to write a statistic of read and transferred records and filename to the job log with an I-message. So you can check with sm37 and al11.

Read only

0 Likes
1,473

Hi,

Sorry for the late reply.

1. Yes, I am transfering the text file using a ftp procedure.

2. Yes I am selecting only newly entered invoice data and it is overy written by the existing file.

3. Same file name and same file path.

Regards

Thanura

Read only

Former Member
0 Likes
1,473

Hi,

after selecting ( hope u know , how to select the data ) the data from respective tables u need to schedule b/g job.

so for this run the tcode : SM36, select JOB WIZARD and give job name : yjob, and press continue.select ABAP prog step.

Continue

Abap prog name : 'Yprogram" <---ur program name which shud run.

Variant : name of the variant which shud be used to run ur prog

and Schedule after 1 hour.

Check the box Periodic job.and continue.

Wizard will take care of all the necessary stepsto be carried.

Rvert back if nay issues,

Rewrd if helpful.

Regards,

Naveen

Read only

Former Member
0 Likes
1,473

Hi Freinds,

My main issue is the program which written is selecting the data when it is running interactively. But it's not selcting the data when I schedule it in the background.

Pls help. With here I am attaching the program

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