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

Post values into fb50 t code from zreport

Former Member
0 Likes
1,500

Hi Everybody,

I have a requirement in which i have a zreport and in the report i should place a push button and once the report is generated and when the user clicks the button it should display FB50 t code and post the value from output  into a field in the standard t code. This requirement is only for one field.

I have done till fetching the t code. Now how can i post the particular value into the standard t code field.

Please refer attached file and kindly provide me your solutions please.

Regards,

Sam.

Hi Everybody,

I have a requirement in which i have a zreport and in the report i should place a push button and once the report is generated and when the user clicks the button it should display FB50 t code and post the value from output  into a field in the standard t code. This requirement is only for one field.

I have done till fetching the t code. Now how can i post the particular value into the standard t code field.

Please refer attached file and kindly provide me your solutions please.

Regards,

Sam.

8 REPLIES 8
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,440

Hi Samuel

You just have fill one field when button is clicked..? If yes kindly create a BDC for that field and call it when push button is pressed

Nabheet

Read only

0 Likes
1,440

Hi Nabheet,

Yes my requirement is to post the value from zreport into fb50 t code when the button is clicked.

The value should be posted in fb50.

To achieve this using BDC,  should i download the zreport first?

Regards,

Sam.

Read only

PankajJain777
Explorer
0 Likes
1,440

Hi

Welcome to scn!

Try using bapi BAPI_ACC_GL_POSTING_POST in your report for posting

Reg,

Pankaj Jain

Read only

Former Member
0 Likes
1,440

Hi Samuel,

Consider this as a BDC program. Just trigger that part of the code after user interaction (AT USER-COMMAND <action>.

The best practice would be to create a function module with the BDC code and call the same after user interaction.

Regards,

Koushik

Read only

Former Member
0 Likes
1,440

Hello Everybody,

Iam half way through and stuck in between, Iam not sure what changes are to be done after this. I am pasting my code for your ref. Can anybody help in this regard please.

Note: My  requirement is to fetch the values from zreport output and there in the screen i have place a pish button " post to journal entry" . When i click the button "FB50" t code should trigger and the output value should be posted in the " amount in the document currency" field. Only the posting part is pending.

Please help.

   REPORT  zwip_rm_new1.

   TABLES:afpo,mbew,afko,stpo,stas,makt,marm,aufk,aufm,mara,afru,mseg,resb,jcds,sscrfields.

   TYPE-POOLS:slis, vrm.

   TYPES:BEGIN OF ty_final ,
         aufnr   TYPE afpo-aufnr,
         auart TYPE aufk-auart,
         psmng   TYPE afpo-psmng,
         wemng   TYPE afpo-wemng,
         plnbez  TYPE afko-plnbez,
         gmein   TYPE AFKO-GMEIN,
         werks   TYPE aufk-werks,
         matnr   TYPE makt-matnr,
         matnr1  type resb-matnr,
         maktx   TYPE makt-maktx,
         maktx1   TYPE makt-maktx,
         balqty  TYPE afpo-psmng,
         wipval  TYPE mbew-verpr,
*        auart   TYPE aufk-auart,
         enwrt TYPE resb-enwrt,
         lgort TYPE afpo-lgort,
         DAUAT type afpo-DAUAT,
         elikz type afpo-elikz,
         XLOEK type resb-XLOEK,
         IDAT2 type aufk-IDAT2,
         baugr type resb-baugr,
         rsnum type afko-rsnum,
         rsnum1 type resb-rsnum,
         rspos type resb-rspos,
         stlkn type stas-stlkn,
         stlty type afko-stlty,
         stlnr type afko-stlnr,
         stlal type afko-stlal,
         idnrk type stpo-idnrk,
         END OF ty_final.

   DATA:it_final TYPE TABLE OF ty_final,
        wa_final TYPE ty_final.

   DATA:t_fieldcat  TYPE slis_t_fieldcat_alv,
        w_fieldcat  TYPE slis_fieldcat_alv,
        ls_fieldcat TYPE slis_fieldcat_alv,
        it_sort     TYPE slis_t_sortinfo_alv,
        w_sort      TYPE slis_sortinfo_alv,
        wa_layout   TYPE slis_layout_alv,
        gt_events   TYPE slis_t_event,
        g_repid     LIKE sy-repid,
        gs_variant  LIKE disvariant.
   g_repid = sy-repid.
   gs_variant-report = g_repid.
   wa_layout-zebra      = 'X'.

types: begin of bapiache08,
        bus_act type c,
        username TYPE username,
        doc_date TYPE d,
        psting_date TYPE d,
        fisc_year TYPE d,
        fis_period TYPE d,
        doc_type TYPE c,
        comp_code TYPE c,
        END OF bapiache08.

DATA FLAG.

data: set_PF_STATUS TYPE sy-ucomm,
       user_command TYPE sy-ucomm.

DATA: ok_code TYPE sy-ucomm,
       save_ok TYPE sy-ucomm.

data: t_documentheader TYPE STANDARD TABLE OF BAPIACHE08 WITH HEADER LINE,
       w_documentheader TYPE BAPIACHE08.

data: t_OBJ_TYPE TYPE STANDARD TABLE OF BAPIACHE02-OBJ_TYPE WITH HEADER LINE,
       t_OBJ_KEY  TYPE STANDARD TABLE OF BAPIACHE02-OBJ_KEY WITH HEADER LINE,
       t_OBJ_SYS  TYPE STANDARD TABLE OF BAPIACHE02-OBJ_SYS WITH HEADER LINE,
       t_ACCOUNTGL TYPE STANDARD TABLE OF BAPIACGL08 WITH HEADER LINE,
       t_CURRENCYAMOUNT TYPE STANDARD TABLE OF BAPIACCR08 WITH HEADER LINE,
       t_RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE,
       t_EXTENSION1 TYPE STANDARD TABLE OF BAPIEXTC WITH HEADER LINE.

   PERFORM select.
   PERFORM field.

   PERFORM layout_init USING wa_layout.
   PERFORM display.


   FORM select.

    SELECT  aufnr idat2 from aufk into CORRESPONDING FIELDS OF TABLE it_final
    where auart = 'PP01' and werks = 'palm' and idat2 = '00.00.0000'.

    SHIFT wa_final-aufnr LEFT DELETING LEADING '0'.

  SELECT a~psmng a~wemng a~lgort a~DAUAT  b~aufnr b~plnbez c~auart b~gmein d~xloek d~baugr b~rsnum
    d~rsnum  as rsnum1 d~matnr as matnr1 d~rspos b~stlty b~stlnr b~stlal d~enwrt
  into CORRESPONDING FIELDS OF table  it_final from
              afpo as A
           INNER JOIN afko as b on a~aufnr = b~aufnr
           INNER JOIN AUFK AS C on a~aufnr = c~aufnr
           inner JOIN resb as d on a~aufnr = d~aufnr
*          where b~aufnr IN s_aufnr and b~plnbez in s_plnbez and c~erdat in s_erdat and a~matnr = b~plnbez
           where a~DAUAT = 'PP01' AND a~DAUAT = c~auart and a~elikz ne 'X' and
           d~xloek ne 'X' and a~matnr = d~baugr and b~rsnum = d~rsnum.
    SHIFT wa_final-aufnr LEFT DELETING LEADING '0'.

     LOOP AT it_final INTO wa_final.

       SELECT SINGLE maktx
              FROM makt
              INTO wa_final-maktx
              WHERE matnr = wa_final-plnbez.

         SELECT SINGLE maktx
              FROM makt
              INTO wa_final-maktx1
              WHERE matnr = wa_final-matnr1.

       wa_final-balqty  wa_final-psmng  wa_final-wemng .                 " Production order open qty"

         select SINGLE  stlty stlnr stlal stlkn
             from stas
             into CORRESPONDING FIELDS OF wa_final
             where stlty = wa_final-stlty
             and stlnr = wa_final-stlnr
             and stlal = wa_final-stlal.

      select SINGLE  idnrk
             from stpo
             into CORRESPONDING FIELDS OF wa_final
             where stlty = wa_final-stlty
             and stlnr = wa_final-stlnr
             and stlkn = wa_final-stlkn.

       wa_final-wipval = ( wa_final-enwrt / wa_final-psmng ) * wa_final-balqty.

         SHIFT wa_final-aufnr LEFT DELETING LEADING '0'.
         SHIFT wa_final-matnr1 LEFT DELETING LEADING '0'.

       SHIFT wa_final-aufnr LEFT DELETING LEADING '0'.
       MODIFY it_final FROM wa_final.
     ENDLOOP.

     delete it_final where balqty eq 0.
     delete it_final WHERE auart ne 'PP01'.

   ENDFORM.                    "select

FORM set_pf_status USING rt_extab TYPE slis_t_extab.        "#EC CALLED
DESCRIBE TABLE rt_extab.
SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.
ENDFORM. "Set_pf_status

*&---------------------------------------------------------------------*
*&      Form  field
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

   FORM field" FIELD CATALOGUE

     w_fieldcat-fieldname = 'AUFNR'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 13.
     w_fieldcat-seltext_m = 'Order'.
      w_sort-fieldname = 'AUFNR'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'PLNBEZ'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 14.
     w_fieldcat-seltext_m = 'Finished Material'.
     w_sort-fieldname = 'PLNBEZ'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.

     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'MAKTX'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 35.
     w_fieldcat-seltext_m = 'FG Description'.
      w_sort-fieldname = 'MAKTX'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'PSMNG'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 10.
     w_fieldcat-seltext_m = 'Ordered Qty'.
      w_sort-fieldname = 'PSMNG'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
     w_fieldcat-decimals_out = '0'.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'WEMNG'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 10.
     w_fieldcat-seltext_m = 'GR Qty'.
     w_fieldcat-no_out    = 'X'.
     w_fieldcat-decimals_out = '0'.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.


     w_fieldcat-fieldname = 'GMEIN'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 8.
     w_fieldcat-seltext_m = 'Order Un'.
     w_fieldcat-just      = 'C'.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.


     w_fieldcat-fieldname = 'LGORT'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 8.
     w_fieldcat-seltext_m = 'Stor.Loc.'.
     w_fieldcat-just      = 'C'.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'ENWRT'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 15.
     w_fieldcat-do_sum    = 'total'.
     w_fieldcat-seltext_m = 'Withdrawn Amount'.
      w_sort-fieldname = 'ENWRT'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.


     w_fieldcat-fieldname = 'BALQTY'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 7.
     w_fieldcat-seltext_m = 'WIP Qty'.
      w_sort-fieldname = 'BALQTY'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
      w_fieldcat-decimals_out = '0'.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.

     w_fieldcat-fieldname = 'WIPVAL'.
     w_fieldcat-tabname   = 'it_final'.
     w_fieldcat-outputlen = 15.
     w_fieldcat-do_sum    = 'total'.
     w_fieldcat-seltext_m = 'WIP Amount'.
      w_sort-fieldname = 'WIPVAL'.
     w_sort-tabname   = 'IALV'.
     w_sort-up        = 'A'.
     append w_sort to it_sort.
     APPEND w_fieldcat TO t_fieldcat.
     CLEAR w_fieldcat.


refresh t_documentheader.

t_documentheader-bus_act ='RFBU'.
t_documentheader-username = sy-uname.
*t_documentheader-doc_date = lv_month.
*t_documentheader-psting_date = lv_month.
*t_documentheader-fisc_year = sy-datum(4).
*t_documentheader-fis_period = sy-datum+4(2).
t_documentheader-doc_type = 'SA'.
t_documentheader-comp_code = 'XXX'.
append t_documentheader.

refresh t_accountgl.
t_accountgl-itemno_acc = '1'.
t_accountgl-gl_account = '408010'.
t_accountgl-item_text = ' '.
t_accountgl-doc_type = 'SA'.
t_accountgl-comp_code = 'XXX'.
t_accountgl-pstng_date = sy-datum.
APPEND t_accountgl.
CLEAR  t_accountgl.

t_accountgl-itemno_acc = '2'.
t_accountgl-gl_account = '630300'.
t_accountgl-item_text = ' '.
t_accountgl-doc_type = 'SA'.
t_accountgl-comp_code = 'XXX'.
t_accountgl-pstng_date = sy-datum.
APPEND t_accountgl.
CLEAR  t_accountgl.

refresh t_currencyamount.
t_currencyamount-itemno_acc = '1'.
t_currencyamount-curr_type = '00'.
t_currencyamount-currency = 'INR'.
t_currencyamount-amt_doccur = '10'.
APPEND t_currencyamount.
CLEAR t_currencyamount.

t_currencyamount-itemno_acc = '2'.
t_currencyamount-curr_type = '00'.
t_currencyamount-currency = 'INR'.
t_currencyamount-amt_doccur = '-10'.
APPEND t_currencyamount.


refresh t_return.

   ENDFORM.                    "field

*&---------------------------------------------------------------------*
*&      Form  LAYOUT_INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RS_LAYOUT  text
*----------------------------------------------------------------------*
   FORM layout_init USING rs_layout TYPE slis_layout_alv.

     rs_layout-detail_popup      = space.

   ENDFORM.                    "LAYOUT_INIT
*&---------------------------------------------------------------------*
*&      Form  display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
   FORM display.

     CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = SY-REPID
         I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         i_grid_title                      = 'WIP VALUATION FOR ALL OPEN ORDERS'
         is_layout                         = wa_layout
         it_events                         = gt_events[]
         is_variant                        = gs_variant
         it_fieldcat                       = t_fieldcat
         it_sort                           = it_sort
         i_save                            = 'A'
       TABLES
         t_outtab                          = it_final.

   CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
   EXPORTING
     documentheader       = t_documentheader
  IMPORTING
    OBJ_TYPE              = t_obj_type
    OBJ_KEY               = t_obj_key
    OBJ_SYS               = t_obj_sys
   tables
     accountgl            = t_accountgl
     currencyamount       = t_currencyamount
     RETURN               = t_return.


   ENDFORM.                    "display

*&---------------------------------------------------------------------*
*&      Form  EVENTTAB_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EVENTS  text
*----------------------------------------------------------------------*
   FORM eventtab_build USING rt_events TYPE slis_t_event.

     DATA: ls_event TYPE slis_alv_event.

     CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type = 0
       IMPORTING
         et_events   = rt_events.
     READ TABLE rt_events WITH KEY name = slis_ev_top_of_page
                          INTO ls_event.
     IF sy-subrc = 0.
       MOVE slis_ev_top_of_page TO ls_event-form.
       APPEND ls_event TO rt_events.
     ENDIF.

   ENDFORM.                    "EVENTTAB_BUILD

Regards,

Sam.

Read only

0 Likes
1,440

hi samual,

              

for your requirement, you have to create the bdc but before that you have to

step 1 :- record that t-code (fb50) in shdb t-code. during recoding take mendatory fields into consideration.

step 2: system by default create the progarm.

for that (after recoding your t-code) given name will be display in shdb ,

you have to select recording name and select program --provide some name to that any.

copy that code into your program.

now in another part you have to user this kind of code...

for status

  form SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
     SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'.
endform.

for user_command as you have defined in your progam..

   form SET_USER_COMMAND using UCOMM TYPE SY-UCOMM
           RS_SELFIELD     TYPE SLIS_SELFIELD.

CASE UCOMM.

   WHEN '&IC1'.

       READ TABLE ITAB INDEX rs_selfield-tabindex .

      post_bdc_fb50..( it will be the part of your recording as per in shdb)

  endcase.


hope it helps

regards

vikas

Read only

0 Likes
1,440

Thanks Vikas.

Ill check and let you know.

Regards,

Sam.

Read only

Former Member
0 Likes
1,440

Dear Abapers,

In my requirement  i' am not uploading data from flat file. From zreport output i should navigate to FB50 t code and post the derived output value from zreport into the amount field into FB50.

Kindly suggest me.