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

WRITE skips one line

Former Member
0 Likes
2,376

Hi,

I've got a strange problem, i got a z report that uses the command write to output the information.

All fine write the output with no problem but in a special case that a BAPI is called the next write is in the next line and not in the actual one that the information is being write.

Any idea way?

Thanks in advanced

Jaime

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,290

Check to make sure that the write statement is outside whatever IF (or other conditional) statement you are using to call the BAPI. For example:

IF condition1.

  • call the BAPI

ENDIF.

WRITE field1.

What does your code look like for the portion of the program where you're having a problem?

- April King

Hi,

I've got a strange problem, i got a z report that uses the command write to output the information.

All fine write the output with no problem but in a special case that a BAPI is called the next write is in the next line and not in the actual one that the information is being write.

Any idea way?

Thanks in advanced

Jaime

11 REPLIES 11
Read only

Former Member
0 Likes
2,291

Check to make sure that the write statement is outside whatever IF (or other conditional) statement you are using to call the BAPI. For example:

IF condition1.

  • call the BAPI

ENDIF.

WRITE field1.

What does your code look like for the portion of the program where you're having a problem?

- April King

Read only

0 Likes
2,290

Hi April,

I understand what your writing but how the bapi call affect's the output of my z report?

i've thought i'm doing that only in the end of the processing writing the line but it's more handy to write in several stages

Thanks for the help

Regards

Jaime

Read only

0 Likes
2,290

Jaime, the only thing that I can think of is that somewhere in the BAPI, there is something causing this like maybe an embedded SKIP statement somewhere or something. I was going to look thru the BAPI, but believe it or not, I can not find an internal ECC system which will allow me to look at the BAPI source. ;( I would try taking a look, and seeing if this is the case, although I'm not sure there is much you could do about it except for hacking the BAPI code.

I don't see anything jumping out at me in your coding that would think would cause this behavior.

REgards,

Rich Heilman

Read only

0 Likes
2,290

Hi,

i've thought the same but have no time to go look at the bapi code, one thing if the bapi return error it's doesn't skip the line.

The code it's simple one if statement and call to the BAPI nothing more.

Thanks for the Help

Regards

Jaime Cordeiro

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,290

Can you post the code so that we can take a quick look?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,290

Hi, heres the a sample of the code

write: at 40 in_zuper,

at 52 'Actualizado',

at 70 'ZUPER'.

clear is_sucess.

perform update_anla using

in_zuper

wa_anla-bukrs

wa_anla-anln1

wa_anla-anln2

changing is_sucess.

if is_sucess = 'X'.

    • Call to BAPI_FIXEDASSET_CHANGE

clear is_sucess.

perform bapi_update using

wa_anla-bukrs

wa_anla-anln1

wa_anla-anln2

asset

sub

changing

is_sucess.

if is_sucess = 'X'.

write at 52 'Actualizado'.

write at 70 'Por BAPI'.

commit work and wait.

else.

write at 52 'Não Actualizado'.

write at 70 'Erro na BAPI'..

endif.

and if the call is not done it writes on the correct lines

Thanks for the help

Jaime

Read only

0 Likes
2,290

Maybe try moving your commit statement. So right now you have:

if is_sucess = 'X'.

write at 52 'Actualizado'.

write at 70 'Por BAPI'.

commit work and wait.

else.

write at 52 'Não Actualizado'.

write at 70 'Erro na BAPI'..

endif.

Try changing to:

if is_sucess = 'X'.

commit work and wait.

write at 52 'Actualizado'.

write at 70 'Por BAPI'.

else.

write at 52 'Não Actualizado'.

write at 70 'Erro na BAPI'..

endif.

I'm not sure if the timing of your commit will affect writing the report.

- April

Read only

0 Likes
2,290

Hi April,

I've tried that already the effect was the same

Many thanks for the help

Regards

Jaime

Read only

0 Likes
2,290

hi. I am using the same bapi but i am always unsuccessful in changing the timedependent data...

can you post here your code?

regards

Read only

0 Likes
2,290

Hi, i dont know if it will help you but here goes

select * into corresponding fields of table it_bkpf from bkpf

where

"gjahr in p_gjahr and

bukrs = p_bukrs

and bstat = p_bstat

and budat in p_dt_la.

if sy-subrc = 0.

loop at it_bkpf into wa_bkpf.

if wa_bkpf-awtyp = 'RMRP' ."and dont is INITIAL.

                                          • MM Invoices *************************

  • -------------------------------------------- *

  • ---- Construção da Chave de pesquisa ---- *

  • -------------------------------------------- *

invoicedocnumber = wa_bkpf-awkey(10).

fiscalyear = wa_bkpf-awkey+10(4).

  • -------------------------------------------- *

  • ---- Ir buscar os dados para a criação ---- *

  • -------------------------------------------- *

call function 'BAPI_INCOMINGINVOICE_GETDETAIL'

exporting

invoicedocnumber = invoicedocnumber

fiscalyear = fiscalyear

importing

headerdata = headdata_detail

tables

itemdata = itemdata_detail

return = return.

move-corresponding headdata_detail to headdata_create.

      • Some Fields are not passed need to manual

headdata_create-gross_amount = headdata_detail-gross_amnt.

      • Need to change To New Parameters

headdata_create-pstng_date = p_budat.

headdata_create-comp_code = p_b_dst .

clear: headdata_create-inv_doc_no,

      • To Clean for the creation

headdata_create-dsct_days1,

headdata_create-dsct_days2,

headdata_create-dsct_pct1,

headdata_create-dsct_pct2

.

clear return.

  • -------------------------------------------- *

  • ---- Mudança dos itens ---- *

  • -------------------------------------------- *

      • The PO number may be different for each item

loop at itemdata_detail into wa_itemdetail.

      • Get the number of the next PO

clear: is_valid,ebeln_sel.

select single ebeln from ekko into ebeln_sel

where unsez = wa_itemdetail-po_number

and bukrs = 'CST'.

if sy-subrc = 0.

***Need To read the detail of the PO

call function 'BAPI_PO_GETDETAIL1'

exporting

purchaseorder = ebeln_sel

account_assignment = 'X'

version = 'X'

services = 'X'

tables

return = return

pohistory = pohistory

poitem = poitem.

read table return with key type = 'E' transporting no fields.

if sy-subrc <> 0.

  • ------------------------------------------------------------------- *

  • ---- Passa os dados dos itens para a nova estrutura de criação ---- *

  • ------------------------------------------------------------------- *

move-corresponding wa_itemdetail to wa_itemcreate.

  • ------------------------------------------------------------------------------------------- *

  • ---- Verificação se é um item com revisão de factura com base em entrada de mercadoria ---- *

  • ------------------------------------------------------------------------------------------- *

read table poitem into wa_item with key po_item = wa_itemdetail-po_item.

if sy-subrc = 0.

if wa_item-gr_ind = 'X' and wa_item-gr_basediv = 'X' and wa_item-ir_ind = 'X'."Case 1 - Tem revisão de facturas baseada em

" entrada de material

move-corresponding wa_itemdetail to wa_itemcreate.

read table pohistory into wa_hist with key po_item = wa_itemdetail-po_item.

if sy-subrc = 0.

wa_itemcreate-ref_doc = wa_hist-ref_doc.

wa_itemcreate-ref_doc_it = wa_hist-matdoc_itm.

wa_itemcreate-po_number = ebeln_sel.

wa_itemcreate-ref_doc_year = wa_hist-doc_year.

" Os restantes casos não precisam do documento de material

else.

if not w_hist is initial.

write at /1 wa_itemdetail-po_number.

write at ebeln_sel 20 .

endif.

endif.

endif.

else.

    • Msg de Erro

endif.

append wa_itemcreate to itemdata_create.

endif.

else.

  • is_valid = 'X'.

endif.

clear: wa_itemdetail, wa_hist, wa_itemcreate, wa_item.

endloop.

describe table itemdata_create lines lines.

if lines >= 1 and w_hist is initial.

clear return[].

***Theres no errors on the document, process the document

call function 'BAPI_INCOMINGINVOICE_PARK'

exporting

headerdata = headdata_create

importing

invoicedocnumber = invoicedocnumber_c

fiscalyear = fiscalyear_c

tables

itemdata = itemdata_create

return = return.

read table return with key type = 'E' transporting no fields.

if sy-subrc ne 0.

  • it_out-old = .

  • it_out-new = .

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

Read only

Former Member
0 Likes
2,290

By the way the first block of code is for testing if was possible to write or not

write : at 40 in_zuper ,

at 52 'Actualizado' ,

at 70 'ZUPER' .

clear is_sucess .

perform update_anla using

and now i've solved by using two entry's for the same line but thats not what hi wanted but well it works

Edited by: Jaime Cordeiro on Jan 25, 2008 12:54 PM