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

Questions about creating sets using FM

Former Member
0 Likes
1,632

Hi,

It seems that FM G_SET_CREATION is not a true function module where I could provide all the parameters wit the values and the sets would be created automatically. Somehow, I have to write a program to do the BDC steps. Has anyone written a program to use FMs G_SET_CREATION and G_SET_MAINTENANCE? How would I use these FMs?

Thanks,

Will

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
1,375

Hi Will,

Please try this.

data: num(2) type n value '01',
      fname(132) type c.      

...

loop at itab.
  clear fname.
  concatenate 'RGSBL-FROM(' num ')' into fname.
  
  perform bdc_field using fname itab-field.
  num = num + 1.
endloop.

...

Regards,

Ferry Lianto

12 REPLIES 12
Read only

ferry_lianto
Active Contributor
0 Likes
1,375

Hi Will,

Please check program RGMSETGEN and SAPMGJSX perhaps they may help.

Regards,

Ferry Lianto

Read only

0 Likes
1,375

Hi,

I got a runtime error on SAPMGJSX and RGMSETGEN is an include. Would you think it would be possible to create sets in batch or automate TCODE GS01 and GS02?

Thanks,

WIll

Read only

ferry_lianto
Active Contributor
0 Likes
1,375

Hi Will,

Sorry for late reply.

I think it is possible to create sets in batch or automate tcode GS01/GS02.

Have you tried to record session for GS01/GS02 using transaction SHDB?

Regards,

Ferry Lianto

Read only

0 Likes
1,375

Hi Ferry,

I am actually working on it right now.

I am having problem though with the entries for the FROM column. Would you happen to have sample code to do this?

I am looping through and this what I have

Loop at...

add 1 to l_item.

PERFORM BDC_FIELD USING 'RGSBL-FROM(l_item)'

ITAB-field.

Endloop.

Would this work? to enter multiple entries to the FROm column and to how many there are thatI have to complete creating the basic set?

Thanks,

Will

Read only

ferry_lianto
Active Contributor
0 Likes
1,375

Hi Will,

Please check this sample code in for BDC line item loop.


FORM populate_data .
  data: lv_po(35) type c,
        gv_num(3) type n value '001',
        gv_fname1(132) type c,
        gv_fname2(132) type c,
        gv_fname3(132) type c,
        gv_fname4(132) type c.
 
  sort gt_sdata by BSTKD POSNR.
 
  describe table gt_sdata lines l1_num.
 
  loop at gt_sdata INTO gs_sdata.
 
    if lv_po ne gs_sdata-bstkd.
      lv_po = gs_sdata-bstkd.
 
      clear: gv_fname1, gv_fname2, gv_fname3, GV_FNAME4.
 
      perform bdc_dynpro      using 'SAPMV45A' '0101'.
      perform bdc_field       using 'BDC_CURSOR' 'VBAK-AUART'.
      perform bdc_field       using 'BDC_OKCODE' '/00'.
      perform bdc_field       using 'VBAK-AUART' 'OR'.
      perform bdc_field       using 'VBAK-VKORG' '300'.
      perform bdc_field       using 'VBAK-VTWEG' '20'.
      perform bdc_field       using 'VBAK-SPART' '01'.
 
      perform bdc_dynpro      using 'SAPMV45A' '4001'.
      perform bdc_field       using 'BDC_OKCODE' '=KKAU'.
      perform bdc_field       using 'VBKD-BSTKD' gs_sdata-BSTKD.
      perform bdc_field       using 'VBKD-BSTDK' gs_sdata-BSTDK.
      perform bdc_field       using 'KUAGV-KUNNR' '1195'.
      perform bdc_field       using 'KUWEV-KUNNR' gs_sdata-KUNNR1.
      perform bdc_field       using 'RV45A-KETDAT' GS_SDATA-KETDAT.
      perform bdc_field       using 'RV45A-KPRGBZ' 'D'.
      perform bdc_field       using 'RV45A-DWERK' 'INDY'.
 
      if gv_num = gs_sdata-POSNR.
        concatenate 'RV45A-KWMENG(' gv_num ')' INTO GV_FNAME1.
        concatenate 'VBAP-POSNR(' gv_num ')' INTO GV_FNAME2.
        concatenate 'RV45A-MABNR(' gv_num ')' INTO GV_FNAME3.
        concatenate 'KOMV-KBETR(' gv_num ')' INTO GV_FNAME4.
 
        perform bdc_field       using 'BDC_CURSOR' 'GV_FNAME1'.
        perform bdc_field       using GV_FNAME1 gs_sdata-POSNR.
        perform bdc_field       using GV_FNAME2 gs_sdata-MABNR.
        perform bdc_field       using GV_FNAME3 gs_sdata-KWMENG.
        perform bdc_field       using GV_FNAME4 gs_sdata-KBETR.
 
        gv_num = gv_num + 1.
*        APPEND gs_sdata.
*        Clear gs_sdata.
      endif.
 
      perform bdc_dynpro      using 'SAPMV45A' '4002'.
      perform bdc_field       using 'BDC_OKCODE' '=SICH'.
      perform bdc_field       using 'BDC_CURSOR' 'VBAK-GWLDT'.
      perform bdc_field       using 'VBAK-AUDAT' '08/24/2006'.
      perform bdc_field       using 'VBAK-VKBUR' '30'.
      perform bdc_field       using 'VBAK-GWLDT' GS_SDATA-GWLDT.
      perform bdc_field       using 'VBAK-WAERK' 'USD'.
      perform bdc_field       using 'VBKD-PRSDT' '08/24/2006'.
      perform bdc_field       using 'VBKD-KDGRP' '03'.
 
      clear gs_sdata.
      continue.
    endif.
 
    AT END of BSTKD.
      perform bdc_transaction using 'VA01'.
      clear gs_sdata.
    ENDAT.
 
  endloop.
ENDFORM.                    " populate_data

Hope this will help.

Regards,

Ferry Lianto

Read only

0 Likes
1,375

Hi Ferry,

Thanks so much for the code. here is the partial code when I did the recording:

perform bdc_field using 'RGSBL-FROM(01)'

record-FROM_01_008.

perform bdc_field using 'RGSBL-FROM(02)'

record-FROM_02_009.

perform bdc_field using 'RGSBL-FROM(03)'

record-FROM_03_010.

perform bdc_field using 'RGSBL-FROM(04)'

record-FROM_04_011.

My problem is the second screen of GS01 has a FROM column that is not unique in the field, so when I did the recording it has FROM(01), (02), etc... so it is each row that I have to somehow enter a variable to take on the numerica value instead of hardocoding it to (01) (02) etc.

I tried my code and I am getting an error

<i>Field RGSBL-FROM not found in loop of screen SAPMGSBM 0115</i>

Hope that makes sense.

Thanks,

Will

Message was edited by:

Will Ferrell

Read only

0 Likes
1,375

Hi,

Just use a counter variable.

Eg. data c1(2).

data d1(20).

c1 = 0.

loop...

c1 = c1 + 1.

unpack c1 to c1.

concatenate 'RGSBL-FROM(' c1 ')' to d1.

perform bdc_field using d1 record-from_01_008.

endloop.

Read only

0 Likes
1,375

Hi Ferry

Thanks so much and regards... I see it now.

Thanks Jayanthi .

Read only

0 Likes
1,375

Hi Ferry,

The code worked so well until I was creating a set that has more then 14 rows. The screen can only accept up to 14 rows until then I got an error. I did the recording and I tried the BDC OK_CODE P+ and P++; it did not work. I eventried to use the scroll feature on the right hand side but RGSBL-FROM(14) stays at 14 and did not increment to 15, 16, 17 etc..

Any ideas how I would handle the screen for any sets that is more than 14?

Thanks,

Will

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,375

Hi,

In the FM,just use where -used-list to find sample code.

Read only

0 Likes
1,375

Hi

How ouwlI reference the first row, second row, third row etc for the FROM column when looping through this screen that I have an error?

Thanks,

Will

Message was edited by:

Will Ferrell

Read only

ferry_lianto
Active Contributor
0 Likes
1,376

Hi Will,

Please try this.

data: num(2) type n value '01',
      fname(132) type c.      

...

loop at itab.
  clear fname.
  concatenate 'RGSBL-FROM(' num ')' into fname.
  
  perform bdc_field using fname itab-field.
  num = num + 1.
endloop.

...

Regards,

Ferry Lianto