Sunday, 14 February 2016

Let us ABAP 7.40

C:\Users\Partha\Desktop\HANA\image002.jpg

Today, obviously your company/client running their SAP on latest version ABAP 7.40 (although super latest is 7.50)
Please check it before proceeding further.

You have checked it by now and found its ABAP 7.40
Great!! Now you can dig into the rest of the post. 

You can simply copy paste the code below and enjoy the “NEW WAY” of coding! 

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* On the fly Data declaration for VARIABLE.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

*---------------------------------------------------------------------------------------------------------------
****************************************OLD WAY****************************************
*DATA: v_var1 type string.
*
*v_var1 = 'Hello ABAP 7.40'.
*
*WRITE:/ v_var1.
*---------------------------------------------------------------------------------------------------------------

*---------------------------------------------------------------------------------------------------------------
*****************************************NEW WAY*********************************
DATA(v_var1) = 'Hello ABAP 7.40'.

WRITE:/ v_var1.
*---------------------------------------------------------------------------------------------------------------




*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* On the fly Data declaration for WORK AREA / FIELD-SYMBOL
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

TYPESBEGIN OF ty_ekko,
                  ebeln  TYPE ebeln,
                  bukrs  TYPE bukrs,
                  bsart   TYPE esart,
                  aedat  TYPE erdat,
                  ernam TYPE ernam,
               END OF ty_ekko.

DATAlt_ekko TYPE STANDARD TABLE OF ty_ekko.

SELECT ebeln
                 bukrs
                 bsart
                 aedat
                 ernam
       from ekko
       into TABLE lt_ekko
       where ernam sy-uname.


*---------------------------------------------------------------------------------------------------------------
****************************************OLD WAY***********************************
*DATA: ls_ekko TYPE ekko.
*FIELD-SYMBOLS: <lfs_ekko>.
*DATA: lv_count TYPE i.

*  LOOP AT lt_ekko INTO ls_ekko.
*     WRITE:/ ls_ekko-ebeln,
*             ls_ekko-aedat.
*  ENDLOOP.

*  LOOP AT lt_ekko ASSIGNING <lfs_ekko>.
*     WRITE:/ <lfs_ekko>-ebeln,
*             <lfs_ekko>-aedat.
*  ENDLOOP.

*DESCRIBE TABLE lt_ekko LINES lv_count.
*---------------------------------------------------------------------------------------------------------------
*****************************************NEW WAY*********************************
  LOOP AT lt_ekko INTO DATA(ls_ekko).
     WRITE:/ ls_ekko-ebeln,
                      ls_ekko-aedat.
  ENDLOOP.

  LOOP AT lt_ekko ASSIGNING FIELD-SYMBOL(<lfs_ekko>).
     WRITE:/ <lfs_ekko>-ebeln,
                      <lfs_ekko>-aedat.
  ENDLOOP.

  DESCRIBE TABLE lt_ekko LINES DATA(lv_count).
*---------------------------------------------------------------------------------------------------------------



*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* On the fly READ operation.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*---------------------------------------------------------------------------------------------------------------
****************************************OLD WAY***********************************
*  DATA: ls_ekko_2 TYPE ty_ekko.
*  READ TABLE lt_ekko INTO ls_ekko_2 INDEX 2.
*  IF sy-subrc IS INITIAL.
*  WRITE:/ '2nd PO found'.
*  ENDIF.

*  DATA: ls_ekko_cond TYPE ty_ekko.
*  READ TABLE lt_ekko INTO ls_ekko_cond WITH KEY ebeln = '4500017750'.
*  IF sy-subrc IS INITIAL.
*  WRITE:/ 'PO found'.
*  ENDIF.

*  DATA: ls_ekko_exist TYPE ty_ekko.
*  READ TABLE lt_ekko WITH KEY ebeln = '4500017750'
*                              TRANSPORTING NO FIELDS.
*  IF sy-subrc IS INITIAL.
*    WRITE:/ 'PO Exist'.
*  ENDIF.

*---------------------------------------------------------------------------------------------------------------
*****************************************NEW WAY*********************************
  DATA(ls_ekko_2) = lt_ekko[ ].
  WRITE:'2nd PO found'.

  DATA(ls_ekko_cond) = lt_ekko[ ebeln '4500017750' ].
  WRITE:'PO found'.

  IF line_existslt_ekko[ ebeln '4500017750' ).
    WRITE:'PO Exist'.
  ENDIF.



Here is some more examples which will help you to explore more into ABAP 7.40

C:\Users\Partha\Desktop\HANA\image004.jpg

C:\Users\Partha\Desktop\HANA\image006.jpg 

25 comments:

  1. Thanks for sharing this Information, Got to learn new things from your Blog on SAP SF.SAP SF

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Good one and very informative thanks for sharing it.

    Cloud Inventory Software

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article

    OU Degree 1st Sem Result 2021
    PDUSU BSC 2nd Year Result 2021

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete