Skip to Content
author's profile photo Former Member
Former Member

BAPI billing

Hi Experts,

Problem with BAPI_BILLINGDOC_CREATEMULTIPLE.

when i run the bapi from SE37 it is working

but my program is not working

i am getting error 'sales org a001 is not defined'

types: begin of itab,

f1(4) type c,

f2(2) type c,

f3(2) type c,

f4(4) type c,

f5(2) type c,

f6 type d,

f7(10) type c,

f8 type d,

f9(2) type c,

f10(4) type c, " plant

f11(10) type c, " bill to party

f12(10) type c, " payer

f13(10) type c, " ship to party

f14(10) type c, " material

f15 type i, " req quan

f16(3) type c, " currency

  • i1(4) type c, " cond type

  • i2 type i, " cond value

  • i3(3) type c, " cond unit

end of itab.

data: it_itab type standard table of itab initial size 1 with header line.

data: it_itab1 type alsmex_tabline occurs 1 with header line.

data: billingdata like BAPIVBRK occurs 1 with header line,

bapiret like BAPIRET1 occurs 1 with header line,

succ like BAPIVBRKSUCCESS occurs 1 with header line,

conditiondata like BAPIKOMV occurs 1 with header line,

creaord like BAPICREATORDATA occurs 1 with header line.

data : w_str type string.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\pri\Desktop\bapi.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_itab

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

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

billingdata-salesorg = it_itab-f1.

billingdata-distr_chan = it_itab-f2.

billingdata-division = it_itab-f3.

billingdata-doc_type = it_itab-f4.

billingdata-ordbilltyp = it_itab-f5.

billingdata-bill_date = it_itab-f6.

billingdata-sold_to = it_itab-f7.

billingdata-price_date = it_itab-f8.

billingdata-country = it_itab-f9.

billingdata-plant = it_itab-f10.

billingdata-bill_to = it_itab-f11.

billingdata-payer = it_itab-f12.

billingdata-ship_to = it_itab-f13.

billingdata-material = it_itab-f14.

billingdata-req_qty = it_itab-f15.

billingdata-currency = it_itab-f16.

append billingdata.

*conditiondata-cond_type = it_itab-i1.

*conditiondata-cond_value = it_itab-i2.

*conditiondata-cond_p_unt = it_itab-i3.

*append conditiondata.

endloop.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'

EXPORTING

CREATORDATAIN = creaord

  • TESTRUN = 'X'

  • POSTING =

TABLES

BILLINGDATAIN = billingdata

  • CONDITIONDATAIN = conditiondata

  • CCARDDATAIN =

  • TEXTDATAIN =

  • ERRORS =

RETURN = bapiret

SUCCESS = succ

.

loop at bapiret.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = bapiret-ID

LANG = sy-langu

NO = bapiret-number

V1 = bapiret-Message_v1

V2 = bapiret-Message_v2

V3 = bapiret-Message_v3

V4 = bapiret-Message_v4

IMPORTING

MSG = w_str

  • EXCEPTIONS

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

write:/ w_str.

endloop.

pls rectify it.......

Regards.

Edited by: v@sap on Jun 17, 2008 12:15 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:30 AM

    hi,

    check whether the sales orginisation is present or not ie. field VKORG( Its check table is TVKO).

    And also put the Internal table structure prperly ,I mean to say the internal table structure in which you are uploading the data.

    i.e.

    begin of itab,

    f1 type tvko-vkorg,

    f2 type vtweg ,

    end of itab.

    If you do like this it will be very beneficial for you and also the conversion exit comes into play for many fields.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:37 AM

    Hi,

    The mentioned sales organisation in error message needs to be maintained in master table else change the value to the one which is present.You can put the check before running BAPI.Fetch the sales org from table TVKO.If it is not present in this table,exclude that record.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:05 AM

    it is the problem of small lettters inflat file

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.