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: 

BDC Session method - Header & Line item

Former Member
0 Kudos

Hi All..

I am doing an Interface to Journal upload. Transaction code is f-65. In this I have to upload Header data & Line Items data. I am using BDC Session method. For this I did Recording (Tr..shdb). By using this recording I am uploading the data from Excel file.

It is working for only for first one record, means header & line item. For second record there is no header I suppose to upload Line item only. I am trying to do this but it is not working. I am getting Error..

No batch input data for screen SAPLF040 0700.

There is data, after executing the pgm I am printing all internal table data in Grid. It is printing exactly line my Excel file.

For line item I am checking if first field is not HDR then I have to upload Line items, other wise it upload header & line item.

How I must do?

Every time I must upload the same header item for each & every line item or is there any other way?

Regards

Raj

7 REPLIES 7

Former Member
0 Kudos

u can make two internal table 1st for header data and second for line item data....

suppose u have 1st internal table itab1.

fill 2nd internal table based on 1st internal table for line item vlues...

now work like ...

1st fill header data and now make loop on scen on item lavel data and fill all the item level by itab2.

now again goes for 2nd header data by itab1 and for corresponding header data filled line item data again .....

0 Kudos

Hi..

I cont upload only header data bcz just look at f-65, in that Transaction first screen contain header data followed by Line item information Posting key & Account No.

Regards

Raj

0 Kudos

Hi,

Flat file should have the separater for Header record & item record, for ex. header can be denoted with the record type 'H' and the item line can be denoted with the record type 'I', to process the flat file contents after uploading into single internal table, the data needs tobe segregated based on H & I into two different internal tables, when recording you need to pass the header fields where ever header info is required and pass item details as header,

Hope this helps,

Rgds,

0 Kudos

just check there is option for fast data entry.....

where u can enter all the line item...

0 Kudos

Hi,

You need a flag indicating start of a new record.This will allow you to sagrgate.I'll give you an example.

Your test data (it is a hypotheticlal data..not for f-65)

Header pasrt Item Part

H 1000 100 12345 fhgdfjhj 1000 20

34569 dbmnb.bl 250 10

H 1000 200 47859 bshfvgbhb 400 30

Assuming this data is your upload file, you need pass data for header screen i.e. first screen only if the first field of your itab is 'H'.

You copy your iatb into itab1 and check whether in the next line flag contains 'H', if so code to call SAVE command.

Hope this hepls.Please give points if this is helpful.

Thanks & Regards

Abhijit Moholkar

0 Kudos

Hi,

You need a flag indicating start of a new record.This will allow you to sagrgate.I'll give you an example.

Your test data (it is a hypotheticlal data..not for f-65)

Header past    Item Part
H 1000 100   12345  fhgdfjhj  1000 20
             34569  dbmnb.bl  250  10
H 1000 200   47859  bshfvgbhb 400  30

Assuming this data is your upload file, you need pass data for header screen i.e. first screen only if the first field of your itab is 'H'.

You copy your iatb into itab1 and check whether in the next line flag contains 'H', if so code to call SAVE command.

Hope this hepls.Please give points if this is helpful.

Thanks & Regards

Abhijit Moholkar

Former Member
0 Kudos

Check this code this may be helpful.

REPORT YBADRI_ME21_PRG1.

DATA : BEGIN OF T_SOURCE OCCURS 1,

LIFNR TYPE ELIFN,

EKORG TYPE EKORG,

EKGRP TYPE EKGRP,

EMATN TYPE EMATN,

MENGE(5) TYPE N,

NETPR(4) TYPE N,

WERKS TYPE EWERK,

END OF T_SOURCE.

DATA : BEGIN OF T_HEADER OCCURS 1,

LIFNR TYPE ELIFN,

EKORG TYPE EKORG,

EKGRP TYPE EKGRP,

END OF T_HEADER.

DATA : BEGIN OF T_ITEM OCCURS 1,

EMATN TYPE EMATNR,

MENGE(5) TYPE N,

NETPR(4) TYPE N,

WERKS TYPE EWERK,

END OF T_ITEM.

DATA : BDCDATA TYPE BDCDATA OCCURS 1 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'D:\ME21A.TXT'

FILETYPE = 'DAT'

  • HEADLEN = ' '

  • LINE_EXIT = ' '

  • TRUNCLEN = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • DAT_D_FORMAT = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = T_SOURCE

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • FILE_OPEN_ERROR = 2

  • FILE_READ_ERROR = 3

  • INVALID_TYPE = 4

  • NO_BATCH = 5

  • UNKNOWN_ERROR = 6

  • INVALID_TABLE_WIDTH = 7

  • GUI_REFUSE_FILETRANSFER = 8

  • CUSTOMER_ERROR = 9

  • NO_AUTHORITY = 10

  • OTHERS = 11

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*LOOP AT T_SOURCE.

  • WRITE : T_SOURCE-LIFNR, T_SOURCE-EKORG, T_SOURCE-EKGRP,

*T_SOURCE-WERKS, T_SOURCE-EMATN, T_SOURCE-MENGE, T_SOURCE-NETPR.

*ENDLOOP.

LOOP AT T_SOURCE.

AT NEW LIFNR.

T_HEADER-LIFNR = T_SOURCE-LIFNR.

T_HEADER-EKORG = T_SOURCE-EKORG.

T_HEADER-EKGRP = T_SOURCE-EKGRP.

APPEND T_HEADER.

ENDAT.

T_ITEM-EMATN = T_SOURCE-EMATN.

T_ITEM-MENGE = T_SOURCE-MENGE.

T_ITEM-NETPR = T_SOURCE-NETPR.

T_ITEM-WERKS = T_SOURCE-WERKS.

APPEND T_ITEM.

ENDLOOP.

*LOOP AT T_HEADER.

*WRITE : / T_HEADER. "-LIFNR.", T_HEADER-EKORG, T_HEADER-EKGRP.

*ENDLOOP.

*

*

*LOOP AT T_ITEM.

*WRITE : / T_ITEM. "-LIFNR.", T_HEADER-EKORG, T_HEADER-EKGRP.

*ENDLOOP.

LOOP AT T_HEADER.

REFRESH BDCDATA.

perform bdc_dynpro using 'SAPMM06E' '0100'.

perform bdc_field using 'BDC_CURSOR' 'EKKO-LIFNR'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'EKKO-LIFNR' T_HEADER-LIFNR.

perform bdc_field using 'RM06E-BSART' 'NB'.

perform bdc_field using 'RM06E-BEDAT' '21.06.2006'.

perform bdc_field using 'EKKO-EKORG' T_HEADER-EKORG.

perform bdc_field using 'EKKO-EKGRP' T_HEADER-EKGRP.

perform bdc_field using 'RM06E-LPEIN' 'T'.

perform bdc_field using 'RM06E-WERKS' ''.

DATA : I TYPE C VALUE '1'.

DATA : FNAM(20) TYPE N.

LOOP AT T_ITEM.

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR' 'EKPO-WERKS(01)'.

perform bdc_field using 'BDC_OKCODE' '/00'.

CONCATENATE 'EKPO-EMATN( ' I ')' INTO FNAM.

perform bdc_field using FNAM T_ITEM-EMATN.

CONCATENATE 'EKPO-MENGE( ' I ')' INTO FNAM.

perform bdc_field using FNAM T_ITEM-MENGE.

CONCATENATE 'EKPO-NETPR( ' I ')' INTO FNAM.

perform bdc_field using FNAM T_ITEM-NETPR.

CONCATENATE 'EKPO-WERKS( ' I ')' INTO FNAM.

perform bdc_field using FNAM T_ITEM-WERKS.

I = I + 1.

ENDLOOP.

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR' 'EKPO-NETPR(01)'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'RM06E-EBELP' '10'.

perform bdc_field using 'EKPO-NETPR(01)' ' 50,00'.

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR' 'RM06E-EBELP'.

perform bdc_field using 'BDC_OKCODE' '=BU'.

perform bdc_field using 'RM06E-EBELP' '10'.

CALL TRANSACTION 'ME21' USING BDCDATA MODE 'A'.

ENDLOOP.

*----


*

  • Start new screen

*

*----


*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

*----


*

  • Insert field

*

*----


*

FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> SPACE.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.