Wednesday, August 19, 2015

A demo program to create subscreen in your ABAP Program

report  zsub_screen.

TABLES: USR02,       "Logon data
        SSCRFIELDS.  "FIELDS ON SELECTION SCREENS
*---------------------------------------------------------------
* SUBSCREEN 1
*---------------------------------------------------------------
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
   SELECT-OPTIONS: USERNAME FOR USR02-BNAME.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.

*---------------------------------------------------------------
* SUBSCREEN 2
*---------------------------------------------------------------
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.
   SELECT-OPTIONS: LASTLOGI FOR USR02-TRDAT.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.

*---------------------------------------------------------------
* SUBSCREEN 3
*---------------------------------------------------------------
SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.
   SELECT-OPTIONS: CLASSTYP FOR USR02-CLASS.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.

* STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT
SELECTION-SCREEN: FUNCTION KEY 1,
                  FUNCTION KEY 2.

SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,
                  END OF BLOCK SUB.

START-OF-SELECTION.
    SELECT * FROM USR02 WHERE BNAME IN USERNAME
                          AND ERDAT IN LASTLOGI
                          AND CLASS IN CLASSTYP.
       WRITE: / 'User ', USR02-BNAME,
                'Last Login Date ', USR02-TRDAT,
                'Last Login Time ', USR02-LTIME,
                'CLASS ', USR02-CLASS.
    ENDSELECT.
END-OF-SELECTION.

INITIALIZATION.
* SCREEN ICON LEFT AND RIGHT
  SSCRFIELDS-FUNCTXT_01 = '@0D@'.
  SSCRFIELDS-FUNCTXT_02 = '@0E@'.
  SUB-PROG = SY-REPID.
  SUB-DYNNR = 100.

AT SELECTION-SCREEN.
  CASE SY-DYNNR.

    WHEN 100.
      IF SSCRFIELDS-UCOMM = 'FC01'.
        SUB-DYNNR = 300.
      ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
        SUB-DYNNR = 200.
      ENDIF.

    WHEN 200.
      IF SSCRFIELDS-UCOMM = 'FC01'.
        SUB-DYNNR = 100.
      ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
        SUB-DYNNR = 300.
      ENDIF.

    WHEN 300.
      IF SSCRFIELDS-UCOMM = 'FC01'.
        SUB-DYNNR = 200.
      ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
        SUB-DYNNR = 100.
      ENDIF.
  ENDCASE.

Wednesday, June 3, 2015

AUTO invoice create using BAPI with the reference of sales order



 data i_bapivbrk like bapivbrk occurs with header line.
  data i_bapiret1 like bapiret1 occurs with header line.
  data i_bapivbrksuccess like bapivbrksuccess occurs with header line.


  i_bapivbrk-doc_number zsalesdocument.
  i_bapivbrk-ref_doc zsalesdocument.
  i_bapivbrk-ref_doc_ca 'C'.
  append i_bapivbrk.


   call function 'BAPI_BILLINGDOC_CREATEMULTIPLE'
    tables
    billingdatain         i_bapivbrk
    return                i_bapiret1
    success               i_bapivbrksuccess.

   invoice_no i_bapivbrksuccess-bill_doc.

    call function 'BAPI_TRANSACTION_COMMIT'
    exporting
      wait          'X'.

Purcahse order create using BAPI with the reference of purchase requisition



  "---DATA DECALRATION FOR AUTO PO CREATION
tablesbapimepoheader,
        bapimepoheaderx
.

datait_bapimepoitem type bapimepoitem occurs with header line,
      it_bapimepoitemx 
type bapimepoitemx occurs with header line,
      it_poaccount 
type bapimepoaccount occurs with header line,
      it_poaccountx 
type bapimepoaccountx occurs with header line.
datait_return2 like bapiret2 occurs with header line.
dataflines like tline occurs with header line,
      string
(132type cfobject like thead-tdobjectfname  like thead-tdname.

dataline_no type i.
datavendor_no type lifnr.

datantgew type ekpo-ntgew.
databrgew type ekpo-brgew.

datastr type string.
datastr1 type string.

datav_plant(4type c,
      v_whno
(3type c,
      v_sorg
(4type c,
      v_dplnt
(4type c,
      v_ccode
(4type c,
      v_curr
(3type c,
      v_shippt
(4type c,
      v_country
(2type c.

datatemp_char(200type c.

databanfn type vbep-banfn" for purchase requisition number.

  
select single banfn into banfn from vbep where vbeln zsalesdocument" fetching purchse requisition number

  
" for PO Header data fill

   bapimepoheader
-comp_code t001-bukrs.
   bapimepoheader
-doc_type 'ZCOM'.
   bapimepoheader
-item_intvl '00010'.

   bapimepoheader
-vendor VENDOR.
   bapimepoheader
-pmnttrms '0001'.
   bapimepoheader
-purch_org ‘ABC’.
   bapimepoheader
-pur_group 'E15'.
   bapimepoheader
-currency 'USD'.
   
"bapimepoheader-ref_1 = wa_asntab-asnnumber.
   bapimepoheader
-incoterms2 'inco2'.

   bapimepoheaderx
-comp_code 'X'.
   bapimepoheaderx
-doc_type 'X'.
   bapimepoheaderx
-item_intvl 'X'.
   bapimepoheaderx
-vendor 'X'.
   bapimepoheaderx
-pmnttrms 'X'.
   bapimepoheaderx
-purch_org 'X'.
   bapimepoheaderx
-pur_group 'X'.
   bapimepoheaderx
-currency 'X'.
   
"bapimepoheaderx-ref_1 = 'X'.
   bapimepoheaderx
-incoterms2 'X'.

  
" for PO Line item Data FIll

    line_no 
line_no + 10.
    it_bapimepoitem
-po_item '00010'.
    it_bapimepoitem
-material material.
    it_bapimepoitem
-plant PLANT.
    it_bapimepoitem
-quantity '1'.
    it_bapimepoitem
-free_item 'X'.
    it_bapimepoitem
-conf_ctrl '0004'.
    it_bapimepoitem
-incoterms2 'inco2'.

    it_bapimepoitem
-gross_wt brgew.  “ gross weight

    it_bapimepoitem
-preq_no banfn. “ purchase requisition number

    it_bapimepoitem
-net_weight ntgew. “ net weight

    
append it_bapimepoitem to it_bapimepoitem.
    
clear it_bapimepoitem.

    it_bapimepoitemx
-po_item '00010'.
    it_bapimepoitemx
-material 'X'.
    it_bapimepoitemx
-plant 'X'.
    it_bapimepoitemx
-quantity 'X'.
    it_bapimepoitemx
-free_item 'X'.
    it_bapimepoitemx
-conf_ctrl 'X'.
    it_bapimepoitemx
-incoterms2 'X'.
    it_bapimepoitemx
-gross_wt 'X'.
    it_bapimepoitemx
-preq_no  'X'.
    it_bapimepoitemx
-net_weight 'X'.
    
append it_bapimepoitemx to it_bapimepoitemx.
    
clear it_bapimepoitemx.
    
cleartemp_char.

    it_poaccount
-po_item '00010'.
    it_poaccount
-serial_no '01'.
    it_poaccount
-quantity '1'.

    it_poaccount
-costcenter cost_center.
    
append it_poaccount to it_poaccount.

    it_poaccountx
-po_item '00010'.
    it_poaccountx
-serial_no '01'.
    it_poaccountx
-quantity 'X'.
    it_poaccountx
-costcenter 'X'.
    
append it_poaccountx to it_poaccountx.


    
clear po_number.

    
call function 'BAPI_PO_CREATE1'
    
exporting
      poheader         
bapimepoheader
      poheaderx        
bapimepoheaderx
    
importing
      exppurchaseorder 
po_number
    
tables
      
return           it_return2
      poitem           
it_bapimepoitem
      poitemx          
it_bapimepoitemx
      poaccount        
it_poaccount
      poaccountx        
it_poaccountx.

   
call function 'BAPI_TRANSACTION_COMMIT'
    
exporting
      
wait   'X'
    
importing
      
return return.

CREATE TABLE VALUE REQUEST FOR INPUT PARAMETERS IN MODULE POOL PROGRAM




process before output.
 
module status_0100.

process after 
input.
 
module user_command_0100.
 process 
on value-request.
 
fieldt001-bukrs module zsearch_company.

“”””””’’’’’’’’’’’’Start  main module program”””””””””””””””
module zsearch_company input.

  
databegin of t_company occurs 0,
    bukrs 
type t001-bukrs,
    butxt 
type t001-butxt,
      
end of t_company.

select   bukrs  butxt
  
from  t001 into corresponding fields of table t_company
        
where  bukrs  = 'COM1'


  
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    
exporting
      retfield    
'BUKRS' "field name
      dynpprog    
sy-cprog "Program name
      dynpnr      
sy-dynnr   " screen number
      dynprofield 
'T001-BUKRS' "screen field name
      value_org   
'S'

    
tables
      value_tab   
=  t_company.

endmodule.                 " ZSEARCH_COMPANY  INPUT


“”””””’’’’’’’’’’’’end  main module program”””””””””””””””

Monday, January 12, 2015

find duplicate material from a sap table

select
           count(*as c
           v~vhilm

      from likp as l inner join vekp as on l~vbeln v~vbeln_gen
      into corresponding fields of table t_likp
      where l~vkorg v_plant
      and   l~lgnum v_wh
      and   l~erdat in s_grdat
          group by
           v~vhilm.

Drop Down lists in the selection parameters

PROGRAM ztest.   TYPE-POOLS : vrm.   DATA : name TYPE vrm_id,        list TYPE vrm_values,        value LIKE LINE OF list. ...