Skip to Content
Author's profile photo Andrey Vishnevskiy

Code Samples in New SCN

Hello Colleagues!

My own 2 cents

First of all I’d like to say Thank You for all SCN team for their Great Job! You are doing really amazing things all over here! And I like it very much! 😎

Many folks may blame new SCN. But much much more will appreciate it, I believe!!! So keep going please!!

Good Old Code Button

Actually I’d like to write this blog (as soon as it’s easier now) because I’ve already met some discussions where people provide their suggestions in a way of coding samples. And this is great. But they are doing this in simple way: copy and paste the code. Simple, but not readable. In old SCN it used to be a button to surround the code with some tags which make the code readable.

Where is it now?

ℹ When you’re writing a blog post (as I’m doing right now) or starting a discussion it’s here:

/wp-content/uploads/2012/03/1_81456.png

ℹ And when you post or reply in discussions it’s in Advanced Editor:

/wp-content/uploads/2012/03/2_81457.png

/wp-content/uploads/2012/03/3_81497.png


➖ Here is an example without using Syntax Higlighting.

DATA: current TYPE REF TO cl_crm_bol_entity,

lr_entity       TYPE REF TO cl_crm_bol_entity,

lr_textset_col  TYPE REF TO if_bol_bo_col,

lr_iterator     TYPE REF TO if_bol_bo_col_iterator. 

  value = ”.

  if iterator is bound.

    current ?= iterator->get_current( ).

  else.

    current ?= collection_wrapper->get_current( ).

  endif.

  CHECK current IS BOUND.

  lr_entity ?= current->get_related_entity( ‘BTADVSOpp’ ).

  CHECK lr_entity IS BOUND.

  lr_entity = lr_entity->get_related_entity( ‘BTOrderHeader’ ).


➕ And here is an example with it.

DATA: current TYPE REF TO cl_crm_bol_entity, 
lr_entity       TYPE REF TO cl_crm_bol_entity, 
lr_textset_col  TYPE REF TO if_bol_bo_col, 
lr_iterator     TYPE REF TO if_bol_bo_col_iterator.  

  value = ''. 

  if iterator is bound. 
    current ?= iterator->get_current( ). 
  else. 
    current ?= collection_wrapper->get_current( ). 
  endif. 

  CHECK current IS BOUND. 
  lr_entity ?= current->get_related_entity( 'BTADVSOpp' ). 

  CHECK lr_entity IS BOUND. 
  lr_entity = lr_entity->get_related_entity( 'BTOrderHeader' ).  

Fill the difference please. I personally remember the times when there were ‘code samples’ on SDN forums looked like insertion of the code even without line breaks not to say formatting. Really painful. Always keep in mind that many people are around you and actually they read what you contribute. So please do not be lazy and make your posts pretty. My opinion.

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Andrei,

      have you faced the problem that I've described at http://scn.sap.com/thread/3142933?

      Also it would be great to have an ABAP specific syntax highlighting.

      Best regards
      Gregor

      Author's profile photo Andrey Vishnevskiy
      Andrey Vishnevskiy
      Blog Post Author

      Hi, Gregor.

      Unfortunately, yes. Same experience. But I think it's just the matter of time. And hope it will be fixed soon.

      And ABAP highlighting is a must 🙂

      Author's profile photo Osvaldo Lopez
      Osvaldo Lopez

      Excellent Andrei! Great! Thank you very much!

      Author's profile photo Andrey Vishnevskiy
      Andrey Vishnevskiy
      Blog Post Author

      You're welcome 🙂

      Author's profile photo Phillip Morgan
      Phillip Morgan

      Just what I was looking for!

      Maybe 2 cents but very useful 😉

      Author's profile photo Former Member
      Former Member

      Thank you for sharing!

      Author's profile photo Modadugu Hemanth Kumar
      Modadugu Hemanth Kumar

      Good one... I always use to copy and paste the code (sometimes taking the screenshot). Syntax highlighting is really useful. Thanks for sharing.

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Good One ...Very helpful for me...Thanks for sharing... 🙂

      Author's profile photo Sander Boers
      Sander Boers

      Nice article!

      Since this is the way to post code in the new SCN; is it possible that the article posted below will be updated?

      http://scn.sap.com/thread/1170968

      Author's profile photo Former Member
      Former Member

      Discussion is locked, and new reply can't be posted by normal users.

      Moderators can possibly do it, but I don't know why this link has come up.

      Document by Andrei is newer than linked discussion. I do not see any FAQ article that links to the discussion. How did you find it?

      Author's profile photo Sander Boers
      Sander Boers

      Post code in SCN (first hit), that's why I used the same "post code" in my message 🙂

      Author's profile photo Andrey Vishnevskiy
      Andrey Vishnevskiy
      Blog Post Author

      Hi Sander,

      the post you've mentioned is outdated. I'll be no help here.

      And also I've found out that both ideas:

      Add new style for Code Sample

      and

      ABAP syntax highlighting

      were archived 🙁

      Author's profile photo Former Member
      Former Member

      Perhaps they thought:

      What good is an ABAPer who can't find his way around to show colorful code on a web platform that supports rich text..