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

bdc on cost centre(ks01)

In my program I am trying to create cost centres through a .txt file using bdc.I am using call transaction command and want to print the logged error messages in my report.

whn i debug my program in sy-msgid it shows me 'ks' and sy-msgno as '003' for an unsuccesful cost centre creation which is corect.Also for any other messages it is gvng me correct msgno and msgid.

But in case of successful cost centre creation my sy-msgid as well as my sy-msgno remains blank...whn it shud hv been 'ks' and '005' respectively.

why is this happening????

part of my program is as follows:

CALL TRANSACTION 'KS01' USING t_bdcdata MODE 'A' MESSAGES INTO itab.

SELECT text FROM t100

INTO t_msg

WHERE sprsl = 'EN' AND arbgb = sy-msgid AND msgnr = sy-msgno.

APPEND t_msg.

REPLACE FIRST OCCURRENCE OF '&' IN t_msg-text WITH sy-msgv1.

REPLACE FIRST OCCURRENCE OF '&' IN t_msg-text WITH sy-msgv2.

MOVE t_msg-text TO t_input-text.

ENDSELECT.

MODIFY t_input.

REFRESH t_bdcdata.

CLEAR t_bdcdata.

thank you in advance....!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2007 at 01:03 PM

    sy-msgid & sy-msgno gets filled when there is an error...if it is successful these fields do not get filled but one of the message gets filled up. check in MSGV1 or MSGV2 or MSGV3 or MSGV4 fields which success message is been filled.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 01, 2007 at 01:05 PM

    Hi Siddhesh,

    Why are you depending upon the system messages when you already having the messages in itab?

    You can just loop at itab and use the fm: format_message to get the meaningful messages .

    CALL TRANSACTION 'KS01' USING t_bdcdata MODE 'A' MESSAGES INTO itab.

    loop at itab.

    call function 'FORMAT_MESSAGE'

    exporting

    msgv1....

    .

    .

    .

    importing

    message = v_msg.

    write:/ v_msg.

    endloop.

    REgards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2007 at 01:05 PM

    Hi,

    If any Cost center is created from the Flat file then the Message Id should be 005, So loop at Messages tab and look at the Mesage ID. Message ID 005 is Cost 'center has been created', so the Internal table shoub contain the value.

    LOOP AT MESSTAB.

    SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

    AND ARBGB = MESSTAB-MSGID

    AND MSGNR = MESSTAB-MSGNR.

    IF SY-SUBRC = 0.

    L_MSTRING = T100-TEXT.

    IF L_MSTRING CS '&1'.

    REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

    REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

    REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

    REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

    ELSE.

    REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

    REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

    REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

    REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

    ENDIF.

    CONDENSE L_MSTRING.

    <b>

    if MESSTAB-MSGTYP = 'S'. </b> " Write Message No here

    WRITE: / L_MSTRING(100).

    ELSE.

    WRITE: / MESSTAB.

    ENDIF.

    endif.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2007 at 01:07 PM

    Hi

    U shouldn't use the system variables sy-msgno, sy-msgv1.... but get the message from ITAB table:

    TABLES MESSAGE.
    
    DATA:  ITAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    
    DATA: _MSGID LIKE  SY-MSGID,
          _MSGNO LIKE  SY-MSGNO,
          _MSGTY LIKE  SY-MSGTY.
    
    CALL TRANSACTION 'KS01' USING t_bdcdata MODE 'A' MESSAGES INTO ITAB.
    
    LOOP AT ITAB.
    
      _MSGID = ITAB-MSGID.
      _MSGNO = ITAB-MSGNR.
      _MSGTY = ITAB-MSGTYP.
    
    
      CALL FUNCTION 'WRITE_MESSAGE'
           EXPORTING
                MSGID = _MSGID
                MSGNO = _MSGNO
                MSGTY = _MSGTY
                MSGV1 = ITAB-MSGV1
                MSGV2 = ITAB-MSGV3
                MSGV3 = ITAB-MSGV3
                MSGV4 = ITAB-MSGV4
           IMPORTING
                MESSG = MESSAGE.
      WRITE: / MESSAGE-MSGTX.
    ENDLOOP.

    Max

    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.