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

Problem with creating BDC session

Former Member
0 Likes
821

Hi,

I have post incomming payments process(F-28) and can you please help me fix this problem.

The upload file has data from 2 customers A and B with same check num. The program is seperating the the records by customer and creating two transactions, but one session to process both. The problem is if there is any problem with one customer data(A), it processes other customer(B) and I have to manually delete that customer(A) data records from input file and process customer(B) later again.

Can you please help me to create 2 sessions for 2 customers so that I can process both seperately.

IHead has 2 records one for each customer with amt total.

ILines has all records from input file(A & B). Loop with cust num.

Thanks,

Veni.


FORM post_payments.

  DATA: m_amt(16) TYPE c,
        m_zuonr LIKE bseg-zuonr,
        m_newbs LIKE rf05a-newbs.

  IF gd_open <> gc_true.

    m_grpid = 'OPEN_ITEMS'.

    PERFORM open_bdc_session.

  ENDIF.

  LOOP AT ihead INTO wa_head.

    PERFORM create_header_input.

    m_count = 0.

    LOOP AT iline INTO wa_line WHERE chkno = wa_head-chkno
                               AND   kunnr = wa_head-kunnr
                               AND   rstgr = ' '.

      PERFORM create_items_input.

    ENDLOOP.

    LOOP AT iline INTO wa_line WHERE chkno = wa_head-chkno
                               AND   kunnr = wa_head-kunnr
                               AND   rstgr <> ' '.

      CLEAR: m_amt, m_zuonr, m_newbs.


      IF wa_line-wrbtr < 0.

        m_newbs = '04'.
        m_amt = wa_line-wrbtr * -1.

      ELSE.

        m_newbs = '15'.
        WRITE wa_line-wrbtr TO m_amt.

      ENDIF.

      CONCATENATE wa_line-rstgr wa_line-vbeln INTO m_zuonr
              SEPARATED BY '-'.

      PERFORM bdc_field  USING 'BDC_OKCODE' '=PA'.
      PERFORM bdc_dynpro USING 'SAPDF05X' '3100'.
      PERFORM bdc_field  USING 'BDC_OKCODE' '=KMD'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0700'.

      PERFORM bdc_field  USING 'RF05A-NEWBS' m_newbs.
      PERFORM bdc_field  USING 'RF05A-NEWKO' wa_line-kunnr.
      PERFORM bdc_field  USING 'BDC_OKCODE' '/00'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.

      PERFORM bdc_field  USING 'BSEG-WRBTR' m_amt.
      PERFORM bdc_field  USING 'BSEG-ZUONR' m_zuonr.
      PERFORM bdc_field  USING 'BSEG-SGTXT' '/'.
      PERFORM bdc_field  USING 'BDC_OKCODE' '=ZK'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0331'.
      PERFORM bdc_field  USING 'BSEG-RSTGR' wa_line-rstgr.

    ENDLOOP.

    PERFORM bdc_field  USING 'BDC_OKCODE' '=PA'.
    PERFORM bdc_dynpro USING 'SAPDF05X' '3100'.

    PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.

    PERFORM bdc_transaction USING gc_tcode.

  ENDLOOP.

  IF gd_open = gc_true.

    PERFORM close_bdc_session.

  ENDIF.

ENDFORM.                    " check_posting

8 REPLIES 8
Read only

naimesh_patel
Active Contributor
0 Likes
783
  
  LOOP AT ihead INTO wa_head.
 
at new kunnr.

 IF gd_open <> gc_true.
 
    m_grpid = 'OPEN_ITEMS'.
 
    PERFORM open_bdc_session.
 
  ENDIF.


endat.

    PERFORM create_header_input.
 
    m_count = 0.
 
    LOOP AT iline INTO wa_line WHERE chkno = wa_head-chkno
                               AND   kunnr = wa_head-kunnr
                               AND   rstgr = ' '.
 
      PERFORM create_items_input.
 
    ENDLOOP.
 
    LOOP AT iline INTO wa_line WHERE chkno = wa_head-chkno
                               AND   kunnr = wa_head-kunnr
                               AND   rstgr <> ' '.
 
      CLEAR: m_amt, m_zuonr, m_newbs.
 
 
      IF wa_line-wrbtr < 0.
 
        m_newbs = '04'.
        m_amt = wa_line-wrbtr * -1.
 
      ELSE.
 
        m_newbs = '15'.
        WRITE wa_line-wrbtr TO m_amt.
 
      ENDIF.
 
      CONCATENATE wa_line-rstgr wa_line-vbeln INTO m_zuonr
              SEPARATED BY '-'.
 
      PERFORM bdc_field  USING 'BDC_OKCODE' '=PA'.
      PERFORM bdc_dynpro USING 'SAPDF05X' '3100'.
      PERFORM bdc_field  USING 'BDC_OKCODE' '=KMD'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0700'.
 
      PERFORM bdc_field  USING 'RF05A-NEWBS' m_newbs.
      PERFORM bdc_field  USING 'RF05A-NEWKO' wa_line-kunnr.
      PERFORM bdc_field  USING 'BDC_OKCODE' '/00'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.
 
      PERFORM bdc_field  USING 'BSEG-WRBTR' m_amt.
      PERFORM bdc_field  USING 'BSEG-ZUONR' m_zuonr.
      PERFORM bdc_field  USING 'BSEG-SGTXT' '/'.
      PERFORM bdc_field  USING 'BDC_OKCODE' '=ZK'.
      PERFORM bdc_dynpro USING 'SAPMF05A' '0331'.
      PERFORM bdc_field  USING 'BSEG-RSTGR' wa_line-rstgr.
 
    ENDLOOP.
 
    PERFORM bdc_field  USING 'BDC_OKCODE' '=PA'.
    PERFORM bdc_dynpro USING 'SAPDF05X' '3100'.
 
    PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.
 
    PERFORM bdc_transaction USING gc_tcode.
 
  ENDLOOP.
 
  IF gd_open = gc_true.
 
    PERFORM close_bdc_session.
 
  ENDIF.
endloop.
 
ENDFORM.                    " check_posting

Regards,

Naimesh Patel

Read only

0 Likes
783

Hi Naimesh,

I got the following error.

BDC_INSERT, session not opened.

Please help me to fix this.

Thanks,

Veni.

Read only

0 Likes
783

Hi Naimesh,

I debugged it and it is not going in to IF stmt to open BDC session. Please help me to fix this.

at new kunnr.

IF gd_open <> gc_true.

m_grpid = 'OPEN_ITEMS'.

PERFORM open_bdc_session.

ENDIF.

Thanks,

Veni.

Read only

0 Likes
783

Hi Veni,

Looking at your variables names I think

IF gd_open <> gc_true.

should be

<b>IF gd_open = gc_true.</b>

Regards,

Atish

Read only

0 Likes
783

Hi Atish,

Now it is not going in to the 'IF gd_open = gc_true' for the first time also.

gd_open(01) TYPE c, "Indicator for BDC session

gc_true(1) TYPE c VALUE 'X'. "Generic value for true.

Thanks,

veni.

Read only

0 Likes
783

Hi Veni,

Can you paste your whole code,

Just want to see what is the logic behind gd_open & gc_true

Regards,

Atish

Read only

0 Likes
783

Hi Atish,

Thank you very much. I did the following changes and worked out.

gc_true(1) TYPE c VALUE 'X', "Indicator for value true/false.

from

CONSTANTS: gc_true(1) TYPE c VALUE 'X'.

LOOP AT ihead INTO wa_head.

AT NEW kunnr.

IF gd_open <> gc_true.

m_grpid = 'OPEN_ITEMS'.

PERFORM open_bdc_session.

ENDIF.

ENDAT.

and befor end form,

IF gd_open = gc_true.

PERFORM close_bdc_session.

gd_open = ' '.

ENDIF.

Thanks,

Veni.

Read only

Former Member
0 Likes
783

gc_true(1) TYPE c VALUE 'X', "Indicator for value true/false.

from

CONSTANTS: gc_true(1) TYPE c VALUE 'X'.

LOOP AT ihead INTO wa_head.

AT NEW kunnr.

IF gd_open <> gc_true.

m_grpid = 'OPEN_ITEMS'.

PERFORM open_bdc_session.

ENDIF.

ENDAT.

and befor end form,

IF gd_open = gc_true.

PERFORM close_bdc_session.

gd_open = ' '.

ENDIF.